Commit 91a7b635 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Be faster when all KNS categories fail at once (i.e. when you are offline)

BUG: 454442
parent 0f45fa26
Pipeline #221498 passed with stage
in 2 minutes and 1 second
......@@ -20,6 +20,13 @@ CategoryModel::CategoryModel(QObject *parent)
t->setSingleShot(true);
connect(t, &QTimer::timeout, this, &CategoryModel::populateCategories);
connect(ResourcesModel::global(), &ResourcesModel::backendsChanged, t, QOverload<>::of(&QTimer::start));
// Use a timer so to compress the rootCategoriesChanged signal
// It generally triggers when KNS is unavailable at large (as explained in bug 454442)
m_rootCategoriesChanged = new QTimer(this);
m_rootCategoriesChanged->setInterval(0);
m_rootCategoriesChanged->setSingleShot(true);
connect(m_rootCategoriesChanged, &QTimer::timeout, this, &CategoryModel::rootCategoriesChanged);
}
CategoryModel *CategoryModel::global()
......@@ -52,7 +59,7 @@ void CategoryModel::populateCategories()
}
if (m_rootCategories != ret) {
m_rootCategories = ret;
Q_EMIT rootCategoriesChanged();
m_rootCategoriesChanged->start();
}
}
......@@ -67,7 +74,7 @@ void CategoryModel::blacklistPlugin(const QString &name)
{
const bool ret = Category::blacklistPluginsInVector({name}, m_rootCategories);
if (ret) {
Q_EMIT rootCategoriesChanged();
m_rootCategoriesChanged->start();
}
}
......
......@@ -13,6 +13,8 @@
#include "discovercommon_export.h"
class QTimer;
class DISCOVERCOMMON_EXPORT CategoryModel : public QObject
{
Q_OBJECT
......@@ -35,6 +37,7 @@ Q_SIGNALS:
void rootCategoriesChanged();
private:
QTimer *m_rootCategoriesChanged;
QVector<Category *> m_rootCategories;
};
......
Supports Markdown
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