Allow to filter tags by hidden + favorite

This in preparation to not populate context-menus with unused tags.
This commit is contained in:
Robin Gareus 2018-01-31 14:02:44 +01:00
parent 17cdc8114c
commit 09ca375e15
2 changed files with 16 additions and 3 deletions

View file

@ -89,7 +89,13 @@ public:
void reset_tags (PluginInfoPtr const&);
std::string get_tags_as_string (PluginInfoPtr const&) const;
std::vector<std::string> get_tags (PluginInfoPtr const&) const;
std::vector<std::string> get_all_tags (bool favorites_only) const;
enum TagFilter {
All,
OnlyFavorites,
NoHidden
};
std::vector<std::string> get_all_tags (enum TagFilter) const;
/** plugins were added to or removed from one of the PluginInfoLists */
PBD::Signal0<void> PluginListChanged;

View file

@ -1650,7 +1650,7 @@ PluginManager::sanitize_tag (const std::string to_sanitize) const
}
std::vector<std::string>
PluginManager::get_all_tags (bool favorites_only) const
PluginManager::get_all_tags (TagFilter tag_filter) const
{
std::vector<std::string> ret;
@ -1661,7 +1661,7 @@ PluginManager::get_all_tags (bool favorites_only) const
}
/* if favorites_only then we need to check the info ptr and maybe skip */
if (favorites_only) {
if (tag_filter == OnlyFavorites) {
PluginStatus stat ((*pt).type, (*pt).unique_id);
PluginStatusList::const_iterator i = find (statuses.begin(), statuses.end(), stat);
if ((i != statuses.end()) && (i->status == Favorite)) {
@ -1670,6 +1670,13 @@ PluginManager::get_all_tags (bool favorites_only) const
continue;
}
}
if (tag_filter == NoHidden) {
PluginStatus stat ((*pt).type, (*pt).unique_id);
PluginStatusList::const_iterator i = find (statuses.begin(), statuses.end(), stat);
if ((i != statuses.end()) && (i->status == Hidden)) {
continue;
}
}
/* parse each plugin's tag string into separate tags */
vector<string> tags;