diff options
| author | Aleix Pol <aleixpol@kde.org> | 2015-09-14 15:22:48 (GMT) |
|---|---|---|
| committer | Aleix Pol <aleixpol@kde.org> | 2015-09-14 15:22:48 (GMT) |
| commit | 6b7acad83b9f7ceeb67cd33a659c2222d0516536 (patch) | |
| tree | 9bd57123de561b9cfbcd5bb0b567fee56af63935 | |
| parent | ed50aecdcedf62f7d5cb156f52d1fa0a90564984 (diff) | |
Expose UpdatesModel::hasUpdates
| -rw-r--r-- | discover/qml/Main.qml | 1 | ||||
| -rw-r--r-- | discover/qml/PresentUpdatesPage.qml | 1 | ||||
| -rw-r--r-- | libmuon/UpdateModel/UpdateModel.cpp | 9 | ||||
| -rw-r--r-- | libmuon/UpdateModel/UpdateModel.h | 6 |
4 files changed, 16 insertions, 1 deletions
diff --git a/discover/qml/Main.qml b/discover/qml/Main.qml index 4bc3402..0ba6093 100644 --- a/discover/qml/Main.qml +++ b/discover/qml/Main.qml @@ -220,6 +220,7 @@ Rectangle } ProgressView { + id: progressBox //used from UpdatesPage.qml Layout.fillWidth: true } } diff --git a/discover/qml/PresentUpdatesPage.qml b/discover/qml/PresentUpdatesPage.qml index cdd9a88..555b74b 100644 --- a/discover/qml/PresentUpdatesPage.qml +++ b/discover/qml/PresentUpdatesPage.qml @@ -11,6 +11,7 @@ ScrollView readonly property Component tools: RowLayout { Button { text: i18n("Update") + enabled: updateModel.hasUpdates onClicked: { var updates = page.Stack.view.push(updatesPage) updates.start() diff --git a/libmuon/UpdateModel/UpdateModel.cpp b/libmuon/UpdateModel/UpdateModel.cpp index 5f9c75e..f0651b5 100644 --- a/libmuon/UpdateModel/UpdateModel.cpp +++ b/libmuon/UpdateModel/UpdateModel.cpp @@ -77,7 +77,7 @@ void UpdateModel::activityChanged() { if(ResourcesModel::global()->isFetching()) { setResources(QList<AbstractResource*>()); - } else if(!m_updates->isProgressing() && m_updates->hasUpdates()) { + } else if(!m_updates->isProgressing()) { m_updates->prepare(); setResources(m_updates->toUpdate()); } @@ -305,6 +305,13 @@ void UpdateModel::setResources(const QList< AbstractResource* >& resources) delete systemItem; } endResetModel(); + + Q_EMIT hasUpdatesChanged(!resources.isEmpty()); +} + +bool UpdateModel::hasUpdates() const +{ + return rowCount() > 0; } ResourcesUpdatesModel* UpdateModel::backend() const diff --git a/libmuon/UpdateModel/UpdateModel.h b/libmuon/UpdateModel/UpdateModel.h index 8fcd29b..4af9cbc 100644 --- a/libmuon/UpdateModel/UpdateModel.h +++ b/libmuon/UpdateModel/UpdateModel.h @@ -32,6 +32,7 @@ class MUONCOMMON_EXPORT UpdateModel : public QAbstractItemModel { Q_OBJECT Q_PROPERTY(ResourcesUpdatesModel* backend READ backend WRITE setBackend) + Q_PROPERTY(bool hasUpdates READ hasUpdates NOTIFY hasUpdatesChanged) public: enum Roles { @@ -59,6 +60,8 @@ public: void checkResources(const QList< AbstractResource* >& resource, bool checked); QHash<int,QByteArray> roleNames() const override; + bool hasUpdates() const; + enum Columns { NameColumn = 0, VersionColumn, @@ -69,6 +72,9 @@ public: public Q_SLOTS: void setBackend(ResourcesUpdatesModel* updates); +Q_SIGNALS: + void hasUpdatesChanged(bool hasUpdates); + private: void activityChanged(); |
