diff options
| author | Aleix Pol <aleixpol@kde.org> | 2015-09-09 22:14:35 (GMT) |
|---|---|---|
| committer | Aleix Pol <aleixpol@kde.org> | 2015-09-09 22:15:20 (GMT) |
| commit | c96be2ee53f7b78032b0e04c1da979c863b43add (patch) | |
| tree | 9bc08d66548ce615d8ef5364ee26716b98d94bde | |
| parent | 3f455d7183acba9c28f6ec0dc4d6a4e72a0e01ae (diff) | |
Introduce a separate "Updates" section
| -rw-r--r-- | discover/qml/Main.qml | 11 | ||||
| -rw-r--r-- | discover/qml/PresentUpdatesPage.qml | 80 | ||||
| -rw-r--r-- | discover/resources.qrc | 1 | ||||
| -rw-r--r-- | libmuon/UpdateModel/UpdateModel.cpp | 10 | ||||
| -rw-r--r-- | libmuon/UpdateModel/UpdateModel.h | 6 | ||||
| -rw-r--r-- | libmuon/declarative/MuonDeclarativePlugin.cpp | 2 |
6 files changed, 108 insertions, 2 deletions
diff --git a/discover/qml/Main.qml b/discover/qml/Main.qml index e9f1d4d..4bc3402 100644 --- a/discover/qml/Main.qml +++ b/discover/qml/Main.qml @@ -37,6 +37,7 @@ Rectangle //toplevels property Component topBrowsingComp: Qt.createComponent("qrc:/qml/BrowsingPage.qml") property Component topInstalledComp: Qt.createComponent("qrc:/qml/InstalledPage.qml") + property Component topUpdateComp: Qt.createComponent("qrc:/qml/PresentUpdatesPage.qml") property Component topSourcesComp: Qt.createComponent("qrc:/qml/SourcesPage.qml") property Component currentTopLevel: defaultStartup ? topBrowsingComp : loadingComponent property bool defaultStartup: true @@ -103,12 +104,20 @@ Rectangle }, TopLevelPageData { iconName: "applications-other" - text: ResourcesModel.updatesCount==0 ? i18n("Installed") : i18np("Installed (%1 update)", "Installed (%1 updates)", ResourcesModel.updatesCount) + text: i18n("Installed") component: topInstalledComp objectName: "installed" shortcut: "Alt+I" }, TopLevelPageData { + iconName: "system-software-update" + text: ResourcesModel.updatesCount==0 ? i18n("No Updates") : i18n("Update (%1)", ResourcesModel.updatesCount) + enabled: ResourcesModel.updatesCount>0 + component: topUpdateComp + objectName: "update" + shortcut: "Alt+U" + }, + TopLevelPageData { iconName: "repository" text: i18n("Sources") component: topSourcesComp diff --git a/discover/qml/PresentUpdatesPage.qml b/discover/qml/PresentUpdatesPage.qml new file mode 100644 index 0000000..cdd9a88 --- /dev/null +++ b/discover/qml/PresentUpdatesPage.qml @@ -0,0 +1,80 @@ +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 +import QtQuick 2.1 +import org.kde.muon 1.0 +import org.kde.kquickcontrolsaddons 2.0 + +ScrollView +{ + id: page + readonly property real proposedMargin: (width-app.actualWidth)/2 + readonly property Component tools: RowLayout { + Button { + text: i18n("Update") + onClicked: { + var updates = page.Stack.view.push(updatesPage) + updates.start() + } + } + } + + Component { + id: updatesPage + UpdatesPage {} + } + + ColumnLayout + { + x: proposedMargin + width: app.actualWidth + Repeater { + id: rep + model: UpdateModel { + id: updateModel + backend: ResourcesUpdatesModel { + id: updates + } + } + delegate: ColumnLayout { + id: col + property var currentRow: index + Label { + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + text: display + } + Repeater { + model: ColumnProxyModel { + rootIndex: updateModel.index(col.currentRow, 0) + } + delegate: GridItem { + Layout.fillWidth: true + height: 32 + RowLayout { + anchors.fill: parent + spacing: 5 + CheckBox { + anchors.verticalCenter: parent.verticalCenter + checked: model.checked + } + + QIconItem { + Layout.fillHeight: true + anchors.verticalCenter: parent.verticalCenter + width: 30 + icon: decoration + } + + Label { + id: label + Layout.fillWidth: true + text: i18n("%1 (%2) - %3", display, version, size) + elide: Text.ElideRight + } + } + } + } + } + } + } +} diff --git a/discover/resources.qrc b/discover/resources.qrc index df45dcf..5d6e2f7 100644 --- a/discover/resources.qrc +++ b/discover/resources.qrc @@ -20,6 +20,7 @@ <file>qml/ProgressView.qml</file> <file>qml/BrowsingPage.qml</file> <file>qml/InstalledPage.qml</file> + <file>qml/PresentUpdatesPage.qml</file> <file>qml/Information.qml</file> <file>qml/SourcesPage.qml</file> <file>qml/FeaturedModel.qml</file> diff --git a/libmuon/UpdateModel/UpdateModel.cpp b/libmuon/UpdateModel/UpdateModel.cpp index 1fd82e8..5f9c75e 100644 --- a/libmuon/UpdateModel/UpdateModel.cpp +++ b/libmuon/UpdateModel/UpdateModel.cpp @@ -53,7 +53,11 @@ UpdateModel::~UpdateModel() QHash<int,QByteArray> UpdateModel::roleNames() const { - return QAbstractItemModel::roleNames().unite({ { Qt::CheckStateRole, "checked"} } ); + return QAbstractItemModel::roleNames().unite({ + { Qt::CheckStateRole, "checked" }, + { VersionRole, "version" }, + { SizeRole, "size" } + } ); } void UpdateModel::setBackend(ResourcesUpdatesModel* updates) @@ -117,6 +121,10 @@ QVariant UpdateModel::data(const QModelIndex &index, int role) const return item->checked(); } break; + case VersionRole: + return item->version(); + case SizeRole: + return KFormat().formatByteSize(item->size()); default: break; } diff --git a/libmuon/UpdateModel/UpdateModel.h b/libmuon/UpdateModel/UpdateModel.h index 434eba9..8fcd29b 100644 --- a/libmuon/UpdateModel/UpdateModel.h +++ b/libmuon/UpdateModel/UpdateModel.h @@ -33,6 +33,12 @@ class MUONCOMMON_EXPORT UpdateModel : public QAbstractItemModel Q_OBJECT Q_PROPERTY(ResourcesUpdatesModel* backend READ backend WRITE setBackend) public: + + enum Roles { + VersionRole = Qt::UserRole + 1, + SizeRole + }; + explicit UpdateModel(QObject *parent = nullptr); ~UpdateModel(); diff --git a/libmuon/declarative/MuonDeclarativePlugin.cpp b/libmuon/declarative/MuonDeclarativePlugin.cpp index 048234e..6b7dab5 100644 --- a/libmuon/declarative/MuonDeclarativePlugin.cpp +++ b/libmuon/declarative/MuonDeclarativePlugin.cpp @@ -32,6 +32,7 @@ #include <ReviewsBackend/Rating.h> #include <ReviewsBackend/AbstractReviewsBackend.h> #include <ReviewsBackend/ReviewsModel.h> +#include <UpdateModel/UpdateModel.h> #include <ScreenshotsModel.h> #include <ApplicationAddonsModel.h> #include <MessageActionsModel.h> @@ -63,6 +64,7 @@ void MuonDeclarativePlugin::registerTypes(const char*) qmlRegisterType<ScreenshotsModel>("org.kde.muon", 1, 0, "ScreenshotsModel"); qmlRegisterType<ApplicationProxyModelHelper>("org.kde.muon", 1, 0, "ApplicationProxyModel"); qmlRegisterType<MessageActionsModel>("org.kde.muon", 1, 0, "MessageActionsModel"); + qmlRegisterType<UpdateModel>("org.kde.muon", 1, 0, "UpdateModel"); qmlRegisterUncreatableType<QAction>("org.kde.muon", 1, 0, "QAction", "Use QQC Action"); qmlRegisterType<Rating>(); |
