Commit 2b6140a9 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Get all category management code together

parent 985f5c39
......@@ -187,18 +187,24 @@ void Category::addSubcategory(QVector< Category* >& list, Category* newcat)
list << newcat;
}
bool Category::blacklistPlugins(const QSet<QString>& pluginNames)
void Category::blacklistPluginsInVector(const QSet<QString>& pluginNames, QVector<Category *>& subCategories)
{
for(QVector<Category*>::iterator it = m_subCategories.begin(), itEnd = m_subCategories.end(); it!=itEnd; ) {
for(QVector<Category*>::iterator it = subCategories.begin(), itEnd = subCategories.end(); it!=itEnd; ) {
if ((*it)->blacklistPlugins(pluginNames)) {
delete *it;
it = m_subCategories.erase(it);
it = subCategories.erase(it);
} else
++it;
}
m_plugins.subtract(pluginNames);
}
bool Category::blacklistPlugins(const QSet<QString>& pluginNames)
{
if (m_plugins.subtract(pluginNames).isEmpty())
return true;
return m_plugins.isEmpty();
blacklistPluginsInVector(pluginNames, m_subCategories);
return false;
}
QUrl Category::decoration() const
......
......@@ -73,6 +73,7 @@ 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);
private:
QString m_name;
......
......@@ -72,14 +72,7 @@ QVariantList CategoryModel::rootCategoriesVL() const
void CategoryModel::blacklistPlugin(const QString &name)
{
const QSet<QString> plugins = {name};
for(auto it = m_rootCategories.begin(), itEnd = m_rootCategories.end(); it!=itEnd; ) {
if ((*it)->blacklistPlugins(plugins)) {
delete *it;
it = m_rootCategories.erase(it);
} else
++it;
}
Category::blacklistPluginsInVector({name}, m_rootCategories);
}
static Category* recFindCategory(Category* root, const QString& 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