Commit ed891891 authored by Mikel Johnson's avatar Mikel Johnson Committed by Alexander Lohnau
Browse files

Add favorites placeholder to Kicker's rootModel

parent 00661fb2
......@@ -72,6 +72,7 @@ RootModel::RootModel(QObject *parent) : AppsModel(QString(), parent)
, m_showRecentContacts(false)
, m_recentOrdering(RecentUsageModel::Recent)
, m_showPowerSession(true)
, m_showFavoritesPlaceholder(false)
, m_recentAppsModel(nullptr)
, m_recentDocsModel(nullptr)
, m_recentContactsModel(nullptr)
......@@ -256,6 +257,22 @@ void RootModel::setShowPowerSession(bool show)
}
}
bool RootModel::showFavoritesPlaceholder() const
{
return m_showFavoritesPlaceholder;
}
void RootModel::setShowFavoritesPlaceholder(bool show)
{
if (show != m_showFavoritesPlaceholder) {
m_showFavoritesPlaceholder = show;
refresh();
emit showFavoritesPlaceholderChanged();
}
}
AbstractModel* RootModel::favoritesModel()
{
return m_favorites;
......@@ -398,6 +415,21 @@ void RootModel::refresh()
++separatorPosition;
}
if(m_showFavoritesPlaceholder) {
//This entry is a placeholder and shouldn't ever be visible
QList<AbstractEntry *> placeholderList;
AppsModel *placeholderModel = new AppsModel(placeholderList, false, this);
//Favorites group containing a placeholder entry, so it would be considered as a group, not an entry
QList<AbstractEntry *> placeholderEntry;
placeholderEntry.append(new GroupEntry(this, i18n("This shouldn't be visible! Use KICKER_FAVORITES_MODEL"), QStringLiteral("dialog-warning"), placeholderModel));
AppsModel *favoritesPlaceholderModel = new AppsModel(placeholderEntry, false, this);
favoritesPlaceholderModel->setDescription(QStringLiteral("KICKER_FAVORITES_MODEL")); // Intentionally no i18n.
m_entryList.prepend(new GroupEntry(this, i18n("Favorites"), QStringLiteral("bookmarks"), favoritesPlaceholderModel));
++separatorPosition;
}
if (m_showRecentContacts) {
m_recentContactsModel = new RecentContactsModel(this);
m_entryList.prepend(new GroupEntry(this, i18n("Recent Contacts"), QString("view-history"), m_recentContactsModel));
......
......@@ -59,6 +59,7 @@ class RootModel : public AppsModel
Q_PROPERTY(bool showRecentContacts READ showRecentContacts WRITE setShowRecentContacts NOTIFY showRecentContactsChanged)
Q_PROPERTY(int recentOrdering READ recentOrdering WRITE setRecentOrdering NOTIFY recentOrderingChanged)
Q_PROPERTY(bool showPowerSession READ showPowerSession WRITE setShowPowerSession NOTIFY showPowerSessionChanged)
Q_PROPERTY(bool showFavoritesPlaceholder READ showFavoritesPlaceholder WRITE setShowFavoritesPlaceholder NOTIFY showFavoritesPlaceholderChanged)
public:
explicit RootModel(QObject *parent = nullptr);
......@@ -89,6 +90,9 @@ class RootModel : public AppsModel
bool showPowerSession() const;
void setShowPowerSession(bool show);
bool showFavoritesPlaceholder() const;
void setShowFavoritesPlaceholder(bool show);
AbstractModel* favoritesModel() override;
AbstractModel* systemFavoritesModel();
......@@ -103,6 +107,7 @@ class RootModel : public AppsModel
void showPowerSessionChanged() const;
void recentOrderingChanged() const;
void recentAppsModelChanged() const;
void showFavoritesPlaceholderChanged() const;
protected Q_SLOTS:
void refresh() override;
......@@ -118,6 +123,7 @@ class RootModel : public AppsModel
bool m_showRecentContacts;
int m_recentOrdering;
bool m_showPowerSession;
bool m_showFavoritesPlaceholder;
RecentUsageModel *m_recentAppsModel;
RecentUsageModel *m_recentDocsModel;
......
Markdown is supported
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