diff --git a/applets/kicker/plugin/appsmodel.h b/applets/kicker/plugin/appsmodel.h --- a/applets/kicker/plugin/appsmodel.h +++ b/applets/kicker/plugin/appsmodel.h @@ -39,6 +39,7 @@ Q_PROPERTY(bool flat READ flat WRITE setFlat NOTIFY flatChanged) Q_PROPERTY(bool sorted READ sorted WRITE setSorted NOTIFY sortedChanged) Q_PROPERTY(bool showSeparators READ showSeparators WRITE setShowSeparators NOTIFY showSeparatorsChanged) + Q_PROPERTY(bool showTopLevelItems READ showTopLevelItems WRITE setShowTopLevelItems NOTIFY showTopLevelItemsChanged) Q_PROPERTY(int appNameFormat READ appNameFormat WRITE setAppNameFormat NOTIFY appNameFormatChanged) Q_PROPERTY(QObject* appletInterface READ appletInterface WRITE setAppletInterface NOTIFY appletInterfaceChanged); @@ -79,6 +80,9 @@ bool showSeparators() const; void setShowSeparators(bool showSeparators); + bool showTopLevelItems() const; + void setShowTopLevelItems(bool showTopLevelItems); + int appNameFormat() const; void setAppNameFormat(int format); @@ -96,6 +100,7 @@ void flatChanged() const; void sortedChanged() const; void showSeparatorsChanged() const; + void showTopLevelItemsChanged() const; void appNameFormatChanged() const; void appletInterfaceChanged() const; void hiddenEntriesChanged() const; @@ -113,6 +118,7 @@ bool m_deleteEntriesOnDestruction; int m_separatorCount; bool m_showSeparators; + bool m_showTopLevelItems; QObject *m_appletInterface; diff --git a/applets/kicker/plugin/appsmodel.cpp b/applets/kicker/plugin/appsmodel.cpp --- a/applets/kicker/plugin/appsmodel.cpp +++ b/applets/kicker/plugin/appsmodel.cpp @@ -38,6 +38,7 @@ , m_deleteEntriesOnDestruction(true) , m_separatorCount(0) , m_showSeparators(separators) +, m_showTopLevelItems(false) , m_appletInterface(nullptr) , m_description(i18n("Applications")) , m_entryPath(entryPath) @@ -59,6 +60,7 @@ , m_deleteEntriesOnDestruction(deleteEntriesOnDestruction) , m_separatorCount(0) , m_showSeparators(false) +, m_showTopLevelItems(false) , m_appletInterface(nullptr) , m_description(i18n("Applications")) , m_entryPath(QString()) @@ -363,6 +365,21 @@ } } +bool AppsModel::showTopLevelItems() const +{ + return m_showTopLevelItems; +} + +void AppsModel::setShowTopLevelItems(bool showTopLevelItems) { + if (m_showTopLevelItems != showTopLevelItems) { + m_showTopLevelItems = showTopLevelItems; + + refresh(); + + emit showTopLevelItemsChanged(); + } +} + int AppsModel::appNameFormat() const { return m_appNameFormat; @@ -461,6 +478,43 @@ m_sorted, m_showSeparators, m_appNameFormat); m_entryList << groupEntry; } + } else if (p->isType(KST_KService) && m_showTopLevelItems) { + const KService::Ptr service(static_cast(p.data())); + + if (service->noDisplay()) { + continue; + } + + bool found = false; + + foreach (const AbstractEntry *entry, m_entryList) { + if (entry->type() == AbstractEntry::RunnableType + && static_cast(entry)->service()->storageId() == service->storageId()) { + found = true; + } + } + + if (!found) { + m_entryList << new AppEntry(this, service, m_appNameFormat); + } + } else if (p->isType(KST_KServiceSeparator) && m_showSeparators && m_showTopLevelItems) { + if (!m_entryList.count()) { + continue; + } + + if (m_entryList.last()->type() == AbstractEntry::SeparatorType) { + continue; + } + + m_entryList << new SeparatorEntry(this); + ++m_separatorCount; + } + } + + if (m_entryList.count()) { + while (m_entryList.last()->type() == AbstractEntry::SeparatorType) { + m_entryList.removeLast(); + --m_separatorCount; } } diff --git a/applets/kicker/plugin/rootmodel.cpp b/applets/kicker/plugin/rootmodel.cpp --- a/applets/kicker/plugin/rootmodel.cpp +++ b/applets/kicker/plugin/rootmodel.cpp @@ -310,6 +310,8 @@ foreach (const AbstractEntry *groupEntry, m_entryList) { AbstractModel *model = groupEntry->childModel(); + if (!model) continue; + for (int i = 0; i < model->count(); ++i) { GroupEntry *subGroupEntry = static_cast(model->index(i, 0).internalPointer()); AbstractModel *subModel = subGroupEntry->childModel(); @@ -369,6 +371,8 @@ foreach (const AbstractEntry *groupEntry, m_entryList) { AbstractModel *model = groupEntry->childModel(); + if (!model) continue; + for (int i = 0; i < model->count(); ++i) { AbstractEntry *appEntry = static_cast(model->index(i, 0).internalPointer());