diff --git a/applets/kicker/plugin/recentusagemodel.h b/applets/kicker/plugin/recentusagemodel.h --- a/applets/kicker/plugin/recentusagemodel.h +++ b/applets/kicker/plugin/recentusagemodel.h @@ -22,6 +22,7 @@ #include "forwardingmodel.h" +#include #include class GroupSortProxy : public QSortFilterProxyModel @@ -52,9 +53,10 @@ QPointer m_parentModel; }; -class RecentUsageModel : public ForwardingModel +class RecentUsageModel : public ForwardingModel, public QQmlParserStatus { Q_OBJECT + Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(int ordering READ ordering WRITE setOrdering NOTIFY orderingChanged) @@ -82,6 +84,9 @@ void setOrdering(int ordering); int ordering() const; + void classBegin() override; + void componentComplete() override; + Q_SIGNALS: void orderingChanged(int ordering); @@ -100,6 +105,8 @@ QPointer m_activitiesModel; Ordering m_ordering; + + bool m_complete; }; #endif diff --git a/applets/kicker/plugin/recentusagemodel.cpp b/applets/kicker/plugin/recentusagemodel.cpp --- a/applets/kicker/plugin/recentusagemodel.cpp +++ b/applets/kicker/plugin/recentusagemodel.cpp @@ -46,7 +46,7 @@ using namespace KAStats; using namespace KAStats::Terms; -GroupSortProxy::GroupSortProxy(QAbstractItemModel *sourceModel) : QSortFilterProxyModel(nullptr) +GroupSortProxy::GroupSortProxy(QAbstractItemModel *sourceModel) : QSortFilterProxyModel(sourceModel) { sourceModel->setParent(this); setSourceModel(sourceModel); @@ -57,7 +57,7 @@ { } -InvalidAppsFilterProxy::InvalidAppsFilterProxy(AbstractModel *parentModel, QAbstractItemModel *sourceModel) : QSortFilterProxyModel(nullptr) +InvalidAppsFilterProxy::InvalidAppsFilterProxy(AbstractModel *parentModel, QAbstractItemModel *sourceModel) : QSortFilterProxyModel(sourceModel) , m_parentModel(parentModel) { connect(parentModel, &AbstractModel::favoritesModelChanged, this, &InvalidAppsFilterProxy::connectNewFavoritesModel); @@ -116,8 +116,8 @@ : ForwardingModel(parent) , m_usage(usage) , m_ordering((Ordering)ordering) +, m_complete(false) { - refresh(); } RecentUsageModel::~RecentUsageModel() @@ -395,9 +395,25 @@ return m_ordering; } +void RecentUsageModel::classBegin() +{ +} + +void RecentUsageModel::componentComplete() +{ + m_complete = true; + + refresh(); +} + void RecentUsageModel::refresh() { - QAbstractItemModel *oldModel = sourceModel(); + if (!m_complete) { + return; + } + + setSourceModel(nullptr); + delete m_activitiesModel; auto query = UsedResources | (m_ordering == Recent ? RecentlyUsedFirst : HighScoredFirst) @@ -441,6 +457,4 @@ } setSourceModel(model); - - delete oldModel; } diff --git a/applets/kickoff/package/contents/config/main.xml b/applets/kickoff/package/contents/config/main.xml --- a/applets/kickoff/package/contents/config/main.xml +++ b/applets/kickoff/package/contents/config/main.xml @@ -37,7 +37,7 @@ - bookmark:t,application:t,computer:t,used:t,leave:t + bookmark:t,application:t,computer:t,used:t,oftenUsed:f,leave:t diff --git a/applets/kickoff/package/contents/ui/ConfigButtons.qml b/applets/kickoff/package/contents/ui/ConfigButtons.qml --- a/applets/kickoff/package/contents/ui/ConfigButtons.qml +++ b/applets/kickoff/package/contents/ui/ConfigButtons.qml @@ -37,6 +37,7 @@ "application": { icon: "applications-other", text: i18n("Applications")}, "computer": { icon: "pm", text: i18n("Computer")}, "used": { icon: "view-history", text: i18n("History")}, + "oftenUsed": { icon: "office-chart-pie", text: i18n("Often Used")}, "leave": { icon: "system-log-out", text: i18n("Leave")} } diff --git a/applets/kickoff/package/contents/ui/FullRepresentation.qml b/applets/kickoff/package/contents/ui/FullRepresentation.qml --- a/applets/kickoff/package/contents/ui/FullRepresentation.qml +++ b/applets/kickoff/package/contents/ui/FullRepresentation.qml @@ -157,6 +157,11 @@ source: Qt.resolvedUrl("RecentlyUsedView.qml") } PlasmaExtras.ConditionalLoader { + id: oftenUsedPage + when: mainTabGroup.currentTab == oftenUsedPage + source: Qt.resolvedUrl("OftenUsedView.qml") + } + PlasmaExtras.ConditionalLoader { id: leavePage when: mainTabGroup.currentTab == leavePage source: Qt.resolvedUrl("LeaveView.qml") @@ -537,6 +542,8 @@ return {id: "computerButton", tab: systemPage, iconSource: pmSource.data["PowerDevil"] && pmSource.data["PowerDevil"]["Is Lid Present"] ? "computer-laptop" : "computer", text: i18n("Computer")}; case "used": return {id: "usedButton", tab: recentlyUsedPage, iconSource: "view-history", text: i18n("History")}; + case "oftenUsed": + return {id: "usedButton", tab: oftenUsedPage, iconSource: "office-chart-pie", text: i18n("Often Used")}; case "leave": return {id: "leaveButton", tab: leavePage, iconSource: "system-log-out", text: i18n("Leave")}; } diff --git a/applets/kickoff/package/contents/ui/OftenUsedView.qml b/applets/kickoff/package/contents/ui/OftenUsedView.qml new file mode 100644 --- /dev/null +++ b/applets/kickoff/package/contents/ui/OftenUsedView.qml @@ -0,0 +1,33 @@ +/* + Copyright (C) 2011 Martin Gräßlin + Copyright (C) 2012 Marco Martin + Copyright (C) 2015 Eike Hein + Copyright (C) 2017 Ivan Cukic + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +import QtQuick 2.0 +import org.kde.plasma.components 2.0 as PlasmaComponents + +import org.kde.plasma.private.kicker 0.1 as Kicker + +BaseView { + objectName: "OftenUsedView" + + model: Kicker.RecentUsageModel { + favoritesModel: globalFavorites + ordering: 1 // Popular / Often Used + } +}