Commit a0ca2d1b authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Kicker] Move autoPopulate to AppsModel

Kickoff uses AppsModel instead of RootModel but since RootModel inherits AppsModel we can just move everything over here.

Differential Revision: https://phabricator.kde.org/D10506
parent 20fefd0b
......@@ -33,6 +33,7 @@
AppsModel::AppsModel(const QString &entryPath, bool paginate, int pageSize, bool flat,
bool sorted, bool separators, QObject *parent)
: AbstractModel(parent)
, m_complete(false)
, m_paginate(paginate)
, m_pageSize(pageSize)
, m_deleteEntriesOnDestruction(true)
......@@ -40,6 +41,7 @@ AppsModel::AppsModel(const QString &entryPath, bool paginate, int pageSize, bool
, m_showSeparators(separators)
, m_showTopLevelItems(false)
, m_appletInterface(nullptr)
, m_autoPopulate(true)
, m_description(i18n("Applications"))
, m_entryPath(entryPath)
, m_staticEntryList(false)
......@@ -55,6 +57,7 @@ AppsModel::AppsModel(const QString &entryPath, bool paginate, int pageSize, bool
AppsModel::AppsModel(const QList<AbstractEntry *> entryList, bool deleteEntriesOnDestruction, QObject *parent)
: AbstractModel(parent)
, m_complete(false)
, m_paginate(false)
, m_pageSize(24)
, m_deleteEntriesOnDestruction(deleteEntriesOnDestruction)
......@@ -62,6 +65,7 @@ AppsModel::AppsModel(const QList<AbstractEntry *> entryList, bool deleteEntriesO
, m_showSeparators(false)
, m_showTopLevelItems(false)
, m_appletInterface(nullptr)
, m_autoPopulate(true)
, m_description(i18n("Applications"))
, m_entryPath(QString())
, m_staticEntryList(true)
......@@ -97,6 +101,20 @@ AppsModel::~AppsModel()
}
}
bool AppsModel::autoPopulate() const
{
return m_autoPopulate;
}
void AppsModel::setAutoPopulate(bool populate)
{
if (m_autoPopulate != populate) {
m_autoPopulate = populate;
emit autoPopulateChanged();
}
}
QString AppsModel::description() const
{
return m_description;
......@@ -419,6 +437,10 @@ QStringList AppsModel::hiddenEntries() const
void AppsModel::refresh()
{
if (m_complete) {
return;
}
if (m_staticEntryList) {
return;
}
......@@ -691,3 +713,17 @@ void AppsModel::entryChanged(AbstractEntry *entry)
emit dataChanged(idx, idx);
}
}
void AppsModel::classBegin()
{
}
void AppsModel::componentComplete()
{
m_complete = true;
if (m_autoPopulate) {
refresh();
}
}
......@@ -24,15 +24,20 @@
#include "abstractmodel.h"
#include "appentry.h"
#include <QQmlParserStatus>
#include <KServiceGroup>
class AppGroupEntry;
class QTimer;
class AppsModel : public AbstractModel
class AppsModel : public AbstractModel, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(bool autoPopulate READ autoPopulate WRITE setAutoPopulate NOTIFY autoPopulateChanged)
Q_PROPERTY(bool paginate READ paginate WRITE setPaginate NOTIFY paginateChanged)
Q_PROPERTY(int pageSize READ pageSize WRITE setPageSize NOTIFY pageSizeChanged)
......@@ -60,6 +65,9 @@ class AppsModel : public AbstractModel
Q_INVOKABLE bool trigger(int row, const QString &actionId, const QVariant &argument) override;
bool autoPopulate() const;
void setAutoPopulate(bool populate);
Q_INVOKABLE AbstractModel *modelForRow(int row) override;
Q_INVOKABLE int rowForModel(AbstractModel *model) override;
......@@ -93,8 +101,12 @@ class AppsModel : public AbstractModel
void entryChanged(AbstractEntry *entry) override;
void classBegin() override;
void componentComplete() override;
Q_SIGNALS:
void cleared() const;
void autoPopulateChanged() const;
void paginateChanged() const;
void pageSizeChanged() const;
void flatChanged() const;
......@@ -111,6 +123,8 @@ class AppsModel : public AbstractModel
protected:
void refreshInternal();
bool m_complete;
bool m_paginate;
int m_pageSize;
......@@ -129,6 +143,8 @@ class AppsModel : public AbstractModel
void processServiceGroup(KServiceGroup::Ptr group);
void sortEntries();
bool m_autoPopulate;
QString m_description;
QString m_entryPath;
bool m_staticEntryList;
......
......@@ -63,10 +63,8 @@ AbstractModel *GroupEntry::childModel() const
}
RootModel::RootModel(QObject *parent) : AppsModel(QString(), parent)
, m_complete(false)
, m_favorites(new KAStatsFavoritesModel(this))
, m_systemModel(nullptr)
, m_autoPopulate(true)
, m_showAllApps(false)
, m_showRecentApps(true)
, m_showRecentDocs(true)
......@@ -145,20 +143,6 @@ bool RootModel::trigger(int row, const QString& actionId, const QVariant& argume
return AppsModel::trigger(row, actionId, argument);
}
bool RootModel::autoPopulate() const
{
return m_autoPopulate;
}
void RootModel::setAutoPopulate(bool populate)
{
if (m_autoPopulate != populate) {
m_autoPopulate = populate;
emit autoPopulateChanged();
}
}
bool RootModel::showAllApps() const
{
return m_showAllApps;
......@@ -269,19 +253,6 @@ AbstractModel* RootModel::systemFavoritesModel()
return nullptr;
}
void RootModel::classBegin()
{
}
void RootModel::componentComplete()
{
m_complete = true;
if (m_autoPopulate) {
refresh();
}
}
void RootModel::refresh()
{
if (!m_complete) {
......
......@@ -22,8 +22,6 @@
#include "appsmodel.h"
#include <QQmlParserStatus>
class KAStatsFavoritesModel;
class RecentContactsModel;
class RecentUsageModel;
......@@ -49,12 +47,9 @@ class GroupEntry : public AbstractGroupEntry
QPointer<AbstractModel> m_childModel;
};
class RootModel : public AppsModel, public QQmlParserStatus
class RootModel : public AppsModel
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(bool autoPopulate READ autoPopulate WRITE setAutoPopulate NOTIFY autoPopulateChanged)
Q_PROPERTY(QObject* systemFavoritesModel READ systemFavoritesModel NOTIFY systemFavoritesModelChanged)
Q_PROPERTY(bool showAllApps READ showAllApps WRITE setShowAllApps NOTIFY showAllAppsChanged)
......@@ -72,9 +67,6 @@ class RootModel : public AppsModel, public QQmlParserStatus
Q_INVOKABLE bool trigger(int row, const QString &actionId, const QVariant &argument) override;
bool autoPopulate() const;
void setAutoPopulate(bool populate);
bool showAllApps() const;
void setShowAllApps(bool show);
......@@ -96,13 +88,9 @@ class RootModel : public AppsModel, public QQmlParserStatus
AbstractModel* favoritesModel() override;
AbstractModel* systemFavoritesModel();
void classBegin() override;
void componentComplete() override;
Q_SIGNALS:
void refreshed() const;
void systemFavoritesModelChanged() const;
void autoPopulateChanged() const;
void showAllAppsChanged() const;
void showRecentAppsChanged() const;
void showRecentDocsChanged() const;
......@@ -115,13 +103,9 @@ class RootModel : public AppsModel, public QQmlParserStatus
void refresh() override;
private:
bool m_complete;
KAStatsFavoritesModel *m_favorites;
SystemModel *m_systemModel;
bool m_autoPopulate;
bool m_showAllApps;
bool m_showRecentApps;
bool m_showRecentDocs;
......
......@@ -68,6 +68,8 @@ Item {
Kicker.AppsModel {
id: rootModel
autoPopulate: false
appletInterface: plasmoid
appNameFormat: plasmoid.configuration.showAppsByName ? 0 : 1
......
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