Added ability to only check for updates without installing

For built in components
This commit is contained in:
Gres 2020-03-16 22:09:54 +03:00
parent 3847c8d61b
commit afe2cc1a2c
2 changed files with 10 additions and 4 deletions

View File

@ -243,6 +243,8 @@ std::unique_ptr<Model::Component> Model::parse(const QJsonObject &json) const
const auto object = fileInfo.toObject(); const auto object = fileInfo.toObject();
File file; File file;
file.url = object["url"].toString(); file.url = object["url"].toString();
if (!file.url.isValid())
result->checkOnly = true;
file.rawPath = object["path"].toString(); file.rawPath = object["path"].toString();
file.md5 = object["md5"].toString(); file.md5 = object["md5"].toString();
file.versionDate = file.versionDate =
@ -351,7 +353,7 @@ void Model::updateState(Model::Component &component)
State Model::currentState(const File &file) const State Model::currentState(const File &file) const
{ {
if (!file.url.isValid() || file.expandedPath.isEmpty() || if (file.expandedPath.isEmpty() ||
(file.md5.isEmpty() && !file.versionDate.isValid())) (file.md5.isEmpty() && !file.versionDate.isValid()))
return State::NotAvailable; return State::NotAvailable;
@ -505,11 +507,14 @@ Qt::ItemFlags Model::flags(const QModelIndex &index) const
{ {
auto ptr = static_cast<Component *>(index.internalPointer()); auto ptr = static_cast<Component *>(index.internalPointer());
SOFT_ASSERT(ptr, return {}); SOFT_ASSERT(ptr, return {});
auto result = Qt::ItemIsEnabled | Qt::ItemIsSelectable; auto result = Qt::NoItemFlags | Qt::ItemIsSelectable;
if (index.column() != int(Column::Action))
if (ptr->checkOnly)
return result; return result;
if (ptr->state == State::NotAvailable) result |= Qt::ItemIsEnabled;
if (index.column() != int(Column::Action) ||
ptr->state == State::NotAvailable)
return result; return result;
result |= Qt::ItemIsEditable; result |= Qt::ItemIsEditable;

View File

@ -68,6 +68,7 @@ private:
Action action{Action::NoAction}; Action action{Action::NoAction};
QString version; QString version;
std::vector<File> files; std::vector<File> files;
bool checkOnly{false};
std::vector<std::unique_ptr<Component>> children; std::vector<std::unique_ptr<Component>> children;
Component* parent{nullptr}; Component* parent{nullptr};
int index{-1}; int index{-1};