diff --git a/qmlcomponents/applicationlistmodel.cpp b/qmlcomponents/applicationlistmodel.cpp index f8627c86..639a30f2 100644 --- a/qmlcomponents/applicationlistmodel.cpp +++ b/qmlcomponents/applicationlistmodel.cpp @@ -30,12 +30,16 @@ #include #include #include +#include #include #include ApplicationListModel::ApplicationListModel(QObject *parent) : QAbstractListModel(parent) { + //can't use the new syntax as this signal is overloaded + connect(KSycoca::self(), SIGNAL(databaseChanged(const QStringList &)), + this, SLOT(sycocaDbChanged(const QStringList &))); } ApplicationListModel::~ApplicationListModel() @@ -54,6 +58,17 @@ QHash ApplicationListModel::roleNames() const return roleNames; } +void ApplicationListModel::sycocaDbChanged(const QStringList &changes) +{ + if (!changes.contains("apps") && !changes.contains("xdgdata-apps")) { + return; + } + + m_applicationList.clear(); + + loadApplications(); +} + bool appNameLessThan(const ApplicationData &a1, const ApplicationData &a2) { return a1.name.toLower() < a2.name.toLower(); @@ -63,6 +78,8 @@ void ApplicationListModel::loadApplications() { beginResetModel(); + m_applicationList.clear(); + KServiceGroup::Ptr group = KServiceGroup::root(); if (!group || !group->isValid()) return; KServiceGroup::List subGroupList = group->entries(true); diff --git a/qmlcomponents/applicationlistmodel.h b/qmlcomponents/applicationlistmodel.h index 5c508888..15cc5272 100644 --- a/qmlcomponents/applicationlistmodel.h +++ b/qmlcomponents/applicationlistmodel.h @@ -69,6 +69,9 @@ public: Q_INVOKABLE void loadApplications(); +public Q_SLOTS: + void sycocaDbChanged(const QStringList &change); + Q_SIGNALS: void countChanged(); void appOrderChanged();