Commit 6108ce12 authored by Sergei Lopatin's avatar Sergei Lopatin Committed by Eike Hein
Browse files

Show root items in kicker menu

Summary:
BUG: 358291

For some reason kicker appsmodel ignores root items (apps and separators). This patch added support for them.

Reviewers: #plasma, hein

Reviewed By: #plasma, hein

Subscribers: davidedmundson, ngraham, hein, mart, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8816
parent 1663e9de
......@@ -38,6 +38,7 @@ AppsModel::AppsModel(const QString &entryPath, bool paginate, int pageSize, bool
, 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 @@ AppsModel::AppsModel(const QList<AbstractEntry *> entryList, bool deleteEntriesO
, 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 @@ void AppsModel::setShowSeparators(bool showSeparators) {
}
}
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 @@ void AppsModel::refreshInternal()
m_sorted, m_showSeparators, m_appNameFormat);
m_entryList << groupEntry;
}
} else if (p->isType(KST_KService) && m_showTopLevelItems) {
const KService::Ptr service(static_cast<KService*>(p.data()));
if (service->noDisplay()) {
continue;
}
bool found = false;
foreach (const AbstractEntry *entry, m_entryList) {
if (entry->type() == AbstractEntry::RunnableType
&& static_cast<const AppEntry *>(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;
}
}
......
......@@ -39,6 +39,7 @@ class AppsModel : public AbstractModel
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 @@ class AppsModel : public AbstractModel
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 @@ class AppsModel : public AbstractModel
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 @@ class AppsModel : public AbstractModel
bool m_deleteEntriesOnDestruction;
int m_separatorCount;
bool m_showSeparators;
bool m_showTopLevelItems;
QObject *m_appletInterface;
......
......@@ -310,6 +310,8 @@ void RootModel::refresh()
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<GroupEntry*>(model->index(i, 0).internalPointer());
AbstractModel *subModel = subGroupEntry->childModel();
......@@ -369,6 +371,8 @@ void RootModel::refresh()
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<AbstractEntry *>(model->index(i, 0).internalPointer());
......
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