Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/filelist.cc
| Show First 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | static void filelist_readjob_asset_library(FileListReadJob *job_params, | ||||||||
| float *progress); | float *progress); | ||||||||
| static void filelist_readjob_main_assets(FileListReadJob *job_params, | static void filelist_readjob_main_assets(FileListReadJob *job_params, | ||||||||
| bool *stop, | bool *stop, | ||||||||
| bool *do_update, | bool *do_update, | ||||||||
| float *progress); | float *progress); | ||||||||
| /* helper, could probably go in BKE actually? */ | /* helper, could probably go in BKE actually? */ | ||||||||
| static int groupname_to_code(const char *group); | static int groupname_to_code(const char *group); | ||||||||
| static uint64_t groupname_to_filter_id(const char *group); | |||||||||
| static void filelist_cache_clear(FileListEntryCache *cache, size_t new_size); | static void filelist_cache_clear(FileListEntryCache *cache, size_t new_size); | ||||||||
| static bool filelist_intern_entry_is_main_file(const FileListInternEntry *intern_entry); | static bool filelist_intern_entry_is_main_file(const FileListInternEntry *intern_entry); | ||||||||
| /* ********** Sort helpers ********** */ | /* ********** Sort helpers ********** */ | ||||||||
| struct FileSortData { | struct FileSortData { | ||||||||
| bool inverted; | bool inverted; | ||||||||
| ▲ Show 20 Lines • Show All 411 Lines • ▼ Show 20 Lines | static bool is_filtered_file(FileListInternEntry *file, | ||||||||
| const char * /*root*/, | const char * /*root*/, | ||||||||
| FileListFilter *filter) | FileListFilter *filter) | ||||||||
| { | { | ||||||||
| return is_filtered_file_type(file, filter) && | return is_filtered_file_type(file, filter) && | ||||||||
| (is_filtered_file_relpath(file, filter) || is_filtered_file_name(file, filter)); | (is_filtered_file_relpath(file, filter) || is_filtered_file_name(file, filter)); | ||||||||
| } | } | ||||||||
| static bool is_filtered_id_file_type(const FileListInternEntry *file, | static bool is_filtered_id_file_type(const FileListInternEntry *file, | ||||||||
| const char *id_group, | const short id_code, | ||||||||
| const char *name, | const char *name, | ||||||||
| const FileListFilter *filter) | const FileListFilter *filter) | ||||||||
| { | { | ||||||||
| if (!is_filtered_file_type(file, filter)) { | if (!is_filtered_file_type(file, filter)) { | ||||||||
| return false; | return false; | ||||||||
| } | } | ||||||||
| /* We only check for types if some type are enabled in filtering. */ | /* We only check for types if some type are enabled in filtering. */ | ||||||||
| if ((filter->filter || filter->filter_id) && (filter->flags & FLF_DO_FILTER)) { | if ((filter->filter || filter->filter_id) && (filter->flags & FLF_DO_FILTER)) { | ||||||||
| if (id_group) { | if (id_code) { | ||||||||
| if (!name && (filter->flags & FLF_HIDE_LIB_DIR)) { | if (!name && (filter->flags & FLF_HIDE_LIB_DIR)) { | ||||||||
| return false; | return false; | ||||||||
| } | } | ||||||||
| uint64_t filter_id = groupname_to_filter_id(id_group); | const uint64_t filter_id = BKE_idtype_idcode_to_idfilter(id_code); | ||||||||
| if (!(filter_id & filter->filter_id)) { | if (!(filter_id & filter->filter_id)) { | ||||||||
| return false; | return false; | ||||||||
| } | } | ||||||||
| } | } | ||||||||
| } | } | ||||||||
| return true; | return true; | ||||||||
| } | } | ||||||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | static bool is_filtered_asset(FileListInternEntry *file, FileListFilter *filter) | ||||||||
| filter_search[string_length - 1] = '\0'; | filter_search[string_length - 1] = '\0'; | ||||||||
| if (BLI_strcasestr(file->name, filter_search + 1) != nullptr) { | if (BLI_strcasestr(file->name, filter_search + 1) != nullptr) { | ||||||||
| return true; | return true; | ||||||||
| } | } | ||||||||
| return asset_tag_matches_filter(filter_search + 1, asset_data); | return asset_tag_matches_filter(filter_search + 1, asset_data); | ||||||||
| } | } | ||||||||
| static bool is_filtered_lib_type(FileListInternEntry *file, | static bool is_filtered_lib_type(FileListInternEntry *file, | ||||||||
| const char *root, | const char * /*root*/, | ||||||||
HooglyBooglyUnsubmitted Not Done Inline Actions
HooglyBoogly: | |||||||||
| FileListFilter *filter) | FileListFilter *filter) | ||||||||
| { | { | ||||||||
| char path[FILE_MAX_LIBEXTRA], dir[FILE_MAX_LIBEXTRA], *group, *name; | if (file->typeflag & FILE_TYPE_BLENDERLIB) { | ||||||||
| return is_filtered_id_file_type(file, file->blentype, file->name, filter); | |||||||||
| BLI_path_join(path, sizeof(path), root, file->relpath); | |||||||||
| if (BLO_library_path_explode(path, dir, &group, &name)) { | |||||||||
| return is_filtered_id_file_type(file, group, name, filter); | |||||||||
| } | } | ||||||||
| return is_filtered_file_type(file, filter); | return is_filtered_file_type(file, filter); | ||||||||
| } | } | ||||||||
| static bool is_filtered_lib(FileListInternEntry *file, const char *root, FileListFilter *filter) | static bool is_filtered_lib(FileListInternEntry *file, const char *root, FileListFilter *filter) | ||||||||
| { | { | ||||||||
| return is_filtered_lib_type(file, root, filter) && is_filtered_file_relpath(file, filter); | return is_filtered_lib_type(file, root, filter) && is_filtered_file_relpath(file, filter); | ||||||||
| } | } | ||||||||
| static bool is_filtered_main(FileListInternEntry *file, | static bool is_filtered_main(FileListInternEntry *file, | ||||||||
| const char * /*dir*/, | const char * /*dir*/, | ||||||||
| FileListFilter *filter) | FileListFilter *filter) | ||||||||
| { | { | ||||||||
| return !is_filtered_hidden(file->relpath, filter, file); | return !is_filtered_hidden(file->relpath, filter, file); | ||||||||
| } | } | ||||||||
| static bool is_filtered_main_assets(FileListInternEntry *file, | static bool is_filtered_main_assets(FileListInternEntry *file, | ||||||||
| const char * /*dir*/, | const char * /*dir*/, | ||||||||
| FileListFilter *filter) | FileListFilter *filter) | ||||||||
| { | { | ||||||||
| /* "Filtered" means *not* being filtered out... So return true if the file should be visible. */ | /* "Filtered" means *not* being filtered out... So return true if the file should be visible. */ | ||||||||
| return is_filtered_id_file_type(file, file->relpath, file->name, filter) && | return is_filtered_id_file_type(file, file->blentype, file->name, filter) && | ||||||||
| is_filtered_asset(file, filter); | is_filtered_asset(file, filter); | ||||||||
| } | } | ||||||||
| static bool is_filtered_asset_library(FileListInternEntry *file, | static bool is_filtered_asset_library(FileListInternEntry *file, | ||||||||
| const char *root, | const char *root, | ||||||||
| FileListFilter *filter) | FileListFilter *filter) | ||||||||
| { | { | ||||||||
| if (filelist_intern_entry_is_main_file(file)) { | if (filelist_intern_entry_is_main_file(file)) { | ||||||||
| ▲ Show 20 Lines • Show All 1,984 Lines • ▼ Show 20 Lines | static int groupname_to_code(const char *group) | ||||||||
| lslash = (char *)BLI_path_slash_rfind(buf); | lslash = (char *)BLI_path_slash_rfind(buf); | ||||||||
| if (lslash) { | if (lslash) { | ||||||||
| lslash[0] = '\0'; | lslash[0] = '\0'; | ||||||||
| } | } | ||||||||
| return buf[0] ? BKE_idtype_idcode_from_name(buf) : 0; | return buf[0] ? BKE_idtype_idcode_from_name(buf) : 0; | ||||||||
| } | } | ||||||||
| static uint64_t groupname_to_filter_id(const char *group) | |||||||||
| { | |||||||||
| int id_code = groupname_to_code(group); | |||||||||
| return BKE_idtype_idcode_to_idfilter(id_code); | |||||||||
| } | |||||||||
| /** | /** | ||||||||
| * From here, we are in 'Job Context', | * From here, we are in 'Job Context', | ||||||||
| * i.e. have to be careful about sharing stuff between background working thread. | * i.e. have to be careful about sharing stuff between background working thread. | ||||||||
| * and main one (used by UI among other things). | * and main one (used by UI among other things). | ||||||||
| */ | */ | ||||||||
| struct TodoDir { | struct TodoDir { | ||||||||
| int level; | int level; | ||||||||
| char *dir; | char *dir; | ||||||||
| ▲ Show 20 Lines • Show All 1,157 Lines • Show Last 20 Lines | |||||||||