Commit cd06be7b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Notify the view about subcategories changing

parent 2ea4c928
......@@ -186,23 +186,28 @@ void Category::addSubcategory(QVector< Category* >& list, Category* newcat)
list << newcat;
}
void Category::blacklistPluginsInVector(const QSet<QString>& pluginNames, QVector<Category *>& subCategories)
bool Category::blacklistPluginsInVector(const QSet<QString>& pluginNames, QVector<Category *>& subCategories)
{
bool ret = false;
for(QVector<Category*>::iterator it = subCategories.begin(), itEnd = subCategories.end(); it!=itEnd; ) {
if ((*it)->blacklistPlugins(pluginNames)) {
delete *it;
it = subCategories.erase(it);
ret = true;
} else
++it;
}
return ret;
}
bool Category::blacklistPlugins(const QSet<QString>& pluginNames)
{
if (m_plugins.subtract(pluginNames).isEmpty())
if (m_plugins.subtract(pluginNames).isEmpty()) {
return true;
}
blacklistPluginsInVector(pluginNames, m_subCategories);
if (blacklistPluginsInVector(pluginNames, m_subCategories))
Q_EMIT subCategoriesChanged();
return false;
}
......
......@@ -48,7 +48,7 @@ public:
Q_PROPERTY(QString icon READ icon CONSTANT)
Q_PROPERTY(QObject* parent READ parent CONSTANT)
Q_PROPERTY(QUrl decoration READ decoration CONSTANT)
Q_PROPERTY(QVariantList subcategories READ subCategoriesVariant CONSTANT)
Q_PROPERTY(QVariantList subcategories READ subCategoriesVariant NOTIFY subCategoriesChanged)
explicit Category(QSet<QString> pluginNames, QObject* parent = nullptr);
Category(const QString& name, const QString& iconName, const QVector< QPair< FilterType, QString > >& orFilters, const QSet<QString> &pluginName, const QVector<Category *>& subCategories, const QUrl& decoration, bool isAddons);
......@@ -73,7 +73,10 @@ public:
Q_SCRIPTABLE bool contains(const QVariantList &cats) const;
static bool categoryLessThan(Category *c1, const Category *c2);
static void blacklistPluginsInVector(const QSet<QString>& pluginNames, QVector<Category *>& subCategories);
static bool blacklistPluginsInVector(const QSet<QString>& pluginNames, QVector<Category *>& subCategories);
Q_SIGNALS:
void subCategoriesChanged();
private:
QString m_name;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment