mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
watch for sycoca changes
when a new app is installed
This commit is contained in:
parent
25e1e12c4d
commit
ffa4137cd0
2 changed files with 20 additions and 0 deletions
|
|
@ -30,12 +30,16 @@
|
||||||
#include <KService>
|
#include <KService>
|
||||||
#include <KServiceGroup>
|
#include <KServiceGroup>
|
||||||
#include <KServiceTypeTrader>
|
#include <KServiceTypeTrader>
|
||||||
|
#include <KSycoca>
|
||||||
#include <KSycocaEntry>
|
#include <KSycocaEntry>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
ApplicationListModel::ApplicationListModel(QObject *parent)
|
ApplicationListModel::ApplicationListModel(QObject *parent)
|
||||||
: QAbstractListModel(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()
|
ApplicationListModel::~ApplicationListModel()
|
||||||
|
|
@ -54,6 +58,17 @@ QHash<int, QByteArray> ApplicationListModel::roleNames() const
|
||||||
return roleNames;
|
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)
|
bool appNameLessThan(const ApplicationData &a1, const ApplicationData &a2)
|
||||||
{
|
{
|
||||||
return a1.name.toLower() < a2.name.toLower();
|
return a1.name.toLower() < a2.name.toLower();
|
||||||
|
|
@ -63,6 +78,8 @@ void ApplicationListModel::loadApplications()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
|
||||||
|
m_applicationList.clear();
|
||||||
|
|
||||||
KServiceGroup::Ptr group = KServiceGroup::root();
|
KServiceGroup::Ptr group = KServiceGroup::root();
|
||||||
if (!group || !group->isValid()) return;
|
if (!group || !group->isValid()) return;
|
||||||
KServiceGroup::List subGroupList = group->entries(true);
|
KServiceGroup::List subGroupList = group->entries(true);
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,9 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void loadApplications();
|
Q_INVOKABLE void loadApplications();
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void sycocaDbChanged(const QStringList &change);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void countChanged();
|
void countChanged();
|
||||||
void appOrderChanged();
|
void appOrderChanged();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue