From afe2cc1a2c489b13a4b05bdca8f45d0cb1feb2a0 Mon Sep 17 00:00:00 2001 From: Gres Date: Mon, 16 Mar 2020 22:09:54 +0300 Subject: [PATCH] Added ability to only check for updates without installing For built in components --- src/service/updates.cpp | 13 +++++++++---- src/service/updates.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/service/updates.cpp b/src/service/updates.cpp index d3a7100..9f62a8f 100644 --- a/src/service/updates.cpp +++ b/src/service/updates.cpp @@ -243,6 +243,8 @@ std::unique_ptr Model::parse(const QJsonObject &json) const const auto object = fileInfo.toObject(); File file; file.url = object["url"].toString(); + if (!file.url.isValid()) + result->checkOnly = true; file.rawPath = object["path"].toString(); file.md5 = object["md5"].toString(); file.versionDate = @@ -351,7 +353,7 @@ void Model::updateState(Model::Component &component) State Model::currentState(const File &file) const { - if (!file.url.isValid() || file.expandedPath.isEmpty() || + if (file.expandedPath.isEmpty() || (file.md5.isEmpty() && !file.versionDate.isValid())) return State::NotAvailable; @@ -505,11 +507,14 @@ Qt::ItemFlags Model::flags(const QModelIndex &index) const { auto ptr = static_cast(index.internalPointer()); SOFT_ASSERT(ptr, return {}); - auto result = Qt::ItemIsEnabled | Qt::ItemIsSelectable; - if (index.column() != int(Column::Action)) + auto result = Qt::NoItemFlags | Qt::ItemIsSelectable; + + if (ptr->checkOnly) return result; - if (ptr->state == State::NotAvailable) + result |= Qt::ItemIsEnabled; + if (index.column() != int(Column::Action) || + ptr->state == State::NotAvailable) return result; result |= Qt::ItemIsEditable; diff --git a/src/service/updates.h b/src/service/updates.h index 32c9687..a5c6010 100644 --- a/src/service/updates.h +++ b/src/service/updates.h @@ -68,6 +68,7 @@ private: Action action{Action::NoAction}; QString version; std::vector files; + bool checkOnly{false}; std::vector> children; Component* parent{nullptr}; int index{-1};