Check if any components flagged as updateable

This commit is contained in:
elecpower
2022-09-06 09:29:41 +10:00
committed by Peter Feerick
parent d9237cc320
commit 2578c759ce
4 changed files with 46 additions and 35 deletions
+9 -2
View File
@@ -376,6 +376,11 @@ void UpdateInterface::initParamFolders(UpdateParameters * params)
} }
} }
bool UpdateInterface::isUpdateable()
{
return g.component[settingsIdx].checkForUpdate();
}
void UpdateInterface::resetRunEnvironment() void UpdateInterface::resetRunEnvironment()
{ {
progress = nullptr; progress = nullptr;
@@ -1459,11 +1464,13 @@ void UpdateFactories::setRunUpdate(const QString & name)
} }
} }
const QMap<QString, int> UpdateFactories::sortedComponentsList() const QMap<QString, int> UpdateFactories::sortedComponentsList(bool updateableOnly)
{ {
QMap<QString, int> map; QMap<QString, int> map;
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) { foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
if (updateableOnly && !factory->instance()->isUpdateable())
continue;
map.insert(factory->name(), factory->instance()->settingsIdx); map.insert(factory->name(), factory->instance()->settingsIdx);
} }
@@ -1582,7 +1589,7 @@ const bool UpdateFactories::updatesAvailable(QStringList & names)
names.clear(); names.clear();
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) { foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
if (factory->instance()->isUpdateAvailable()) { if (factory->instance()->isUpdateable() && factory->instance()->isUpdateAvailable()) {
names.append(factory->name()); names.append(factory->name());
ret = true; ret = true;
} }
+2 -1
View File
@@ -169,6 +169,7 @@ class UpdateInterface : public QWidget
UpdateParameters * getRunParams() { return runParams; } UpdateParameters * getRunParams() { return runParams; }
void resetRunEnvironment(); void resetRunEnvironment();
void setRunUpdate() { runParams->data.flags |= UPDFLG_Update; } void setRunUpdate() { runParams->data.flags |= UPDFLG_Update; }
bool isUpdateable();
bool repoReleasesMetaData(); bool repoReleasesMetaData();
bool repoReleaseAssetsMetaData(); bool repoReleaseAssetsMetaData();
@@ -272,7 +273,7 @@ class UpdateFactories : public QWidget
void resetRunEnvironment(const QString & name); void resetRunEnvironment(const QString & name);
void resetAllRunEnvironments(); void resetAllRunEnvironments();
void setRunUpdate(const QString & name); void setRunUpdate(const QString & name);
const QMap<QString, int> sortedComponentsList(); const QMap<QString, int> sortedComponentsList(bool updateableOnly = false);
void clearRelease(const QString & name); void clearRelease(const QString & name);
const QString currentRelease(const QString & name); const QString currentRelease(const QString & name);
+5
View File
@@ -86,6 +86,11 @@ void Updates::autoUpdates()
void Updates::manualUpdates() void Updates::manualUpdates()
{ {
if (factories->sortedComponentsList(true).isEmpty()) {
QMessageBox::warning(this, CPN_STR_APP_NAME, tr("No components have been flagged to check in Update Settings!"));
return;
}
factories->resetAllRunEnvironments(); factories->resetAllRunEnvironments();
UpdatesDialog *dlg = new UpdatesDialog(this, factories); UpdatesDialog *dlg = new UpdatesDialog(this, factories);
+30 -32
View File
@@ -36,7 +36,7 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
{ {
// downloading the release meta data takes a few seconds for each component so display progress // downloading the release meta data takes a few seconds for each component so display progress
QDialog *status = new QDialog(parent); QDialog *status = new QDialog(parent);
status->setWindowTitle(tr("Progress")); status->setWindowTitle(tr("Downloading Release Metadata"));
QVBoxLayout *layout = new QVBoxLayout(status); QVBoxLayout *layout = new QVBoxLayout(status);
QLabel *msg = new QLabel(status); QLabel *msg = new QLabel(status);
msg->setFixedWidth(400); msg->setFixedWidth(400);
@@ -141,7 +141,7 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
grid->addItem(spacer, row, col++); grid->addItem(spacer, row, col++);
QMapIterator<QString, int> it(factories->sortedComponentsList()); QMapIterator<QString, int> it(factories->sortedComponentsList(true));
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
@@ -149,44 +149,42 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
const QString name = it.key(); const QString name = it.key();
if (g.component[i].checkForUpdate()) { row++;
row++; col = 0;
col = 0;
msg->setText(tr("Retrieving latest release information for %1").arg(name)); msg->setText(tr("Retrieving latest release information for %1").arg(name));
chkUpdate[i] = new QCheckBox(); chkUpdate[i] = new QCheckBox();
chkUpdate[i]->setProperty("index", i); chkUpdate[i]->setProperty("index", i);
chkUpdate[i]->setChecked(!factories->isLatestRelease(name)); chkUpdate[i]->setChecked(!factories->isLatestRelease(name));
grid->addWidget(chkUpdate[i], row, col++); grid->addWidget(chkUpdate[i], row, col++);
grid->setAlignment(chkUpdate[i], Qt::AlignHCenter); grid->setAlignment(chkUpdate[i], Qt::AlignHCenter);
QLabel *lblName = new QLabel(name); QLabel *lblName = new QLabel(name);
grid->addWidget(lblName, row, col++); grid->addWidget(lblName, row, col++);
QLabel *lblRC = new QLabel(ComponentData::releaseChannelsList().at(g.component[i].releaseChannel())); QLabel *lblRC = new QLabel(ComponentData::releaseChannelsList().at(g.component[i].releaseChannel()));
grid->addWidget(lblRC, row, col++); grid->addWidget(lblRC, row, col++);
lblCurrentRel[i] = new QLabel(factories->currentRelease(name)); lblCurrentRel[i] = new QLabel(factories->currentRelease(name));
grid->addWidget(lblCurrentRel[i], row, col++); grid->addWidget(lblCurrentRel[i], row, col++);
lblUpdateRel[i] = new QLabel(factories->updateRelease(name)); lblUpdateRel[i] = new QLabel(factories->updateRelease(name));
grid->addWidget(lblUpdateRel[i], row, col++); grid->addWidget(lblUpdateRel[i], row, col++);
btnOptions[i] = new QPushButton(tr("Options")); btnOptions[i] = new QPushButton(tr("Options"));
connect(btnOptions[i], &QPushButton::clicked, [=]() { connect(btnOptions[i], &QPushButton::clicked, [=]() {
UpdateOptionsDialog *dlg = new UpdateOptionsDialog(this, factories, i); UpdateOptionsDialog *dlg = new UpdateOptionsDialog(this, factories, i);
connect(dlg, &UpdateOptionsDialog::changed, [=](const int i) { connect(dlg, &UpdateOptionsDialog::changed, [=](const int i) {
QString name = g.component[i].name(); QString name = g.component[i].name();
chkUpdate[i]->setChecked(!factories->isLatestRelease(name)); chkUpdate[i]->setChecked(!factories->isLatestRelease(name));
lblCurrentRel[i]->setText(factories->currentRelease(name)); lblCurrentRel[i]->setText(factories->currentRelease(name));
lblUpdateRel[i]->setText(factories->updateRelease(name)); lblUpdateRel[i]->setText(factories->updateRelease(name));
});
dlg->exec();
dlg->deleteLater();
}); });
dlg->exec();
dlg->deleteLater();
});
grid->addWidget(btnOptions[i], row, col++); grid->addWidget(btnOptions[i], row, col++);
}
} }
ui->grpComponents->setLayout(grid); ui->grpComponents->setLayout(grid);