summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2016-10-25 13:00:27 +0200
committerAleix Pol <[email protected]>2016-10-25 13:00:27 +0200
commitb2b183dffff3e41a572800f77a571f6d99dad320 (patch)
treeb5eb6af668a042fc50f44814743a69327798803b
parentddd97e7a8ad25cee760dc1fdd09b3311bd07291e (diff)
Check a Category instance category name filters
-rw-r--r--libdiscover/Category/Category.cpp9
-rw-r--r--libdiscover/Category/Category.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/libdiscover/Category/Category.cpp b/libdiscover/Category/Category.cpp
index 3e31fc1..e67b2d3 100644
--- a/libdiscover/Category/Category.cpp
+++ b/libdiscover/Category/Category.cpp
@@ -210,6 +210,15 @@ QVariantList Category::subCategoriesVariant() const
return ret;
}
+bool Category::matchesCategoryName(const QString& name) const
+{
+ for(const auto &filter: m_orFilters) {
+ if (filter.first == CategoryFilter && filter.second == name)
+ return true;
+ }
+ return false;
+}
+
bool Category::contains(Category* cat) const
{
const bool ret = cat == this || (cat && contains(qobject_cast<Category*>(cat->parent())));
diff --git a/libdiscover/Category/Category.h b/libdiscover/Category/Category.h
index 204e0e9..c222685 100644
--- a/libdiscover/Category/Category.h
+++ b/libdiscover/Category/Category.h
@@ -67,6 +67,7 @@ public:
bool blacklistPlugins(const QSet<QString>& pluginName);
bool isAddons() const { return m_isAddons; }
QUrl decoration() const;
+ bool matchesCategoryName(const QString &name) const;
Q_SCRIPTABLE bool contains(Category* cat) const;
Q_SCRIPTABLE bool contains(const QVariantList &cats) const;