Check if any components flagged as updateable
This commit is contained in:
@@ -376,6 +376,11 @@ void UpdateInterface::initParamFolders(UpdateParameters * params)
|
||||
}
|
||||
}
|
||||
|
||||
bool UpdateInterface::isUpdateable()
|
||||
{
|
||||
return g.component[settingsIdx].checkForUpdate();
|
||||
}
|
||||
|
||||
void UpdateInterface::resetRunEnvironment()
|
||||
{
|
||||
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;
|
||||
|
||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
||||
if (updateableOnly && !factory->instance()->isUpdateable())
|
||||
continue;
|
||||
map.insert(factory->name(), factory->instance()->settingsIdx);
|
||||
}
|
||||
|
||||
@@ -1582,7 +1589,7 @@ const bool UpdateFactories::updatesAvailable(QStringList & names)
|
||||
names.clear();
|
||||
|
||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
||||
if (factory->instance()->isUpdateAvailable()) {
|
||||
if (factory->instance()->isUpdateable() && factory->instance()->isUpdateAvailable()) {
|
||||
names.append(factory->name());
|
||||
ret = true;
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@ class UpdateInterface : public QWidget
|
||||
UpdateParameters * getRunParams() { return runParams; }
|
||||
void resetRunEnvironment();
|
||||
void setRunUpdate() { runParams->data.flags |= UPDFLG_Update; }
|
||||
bool isUpdateable();
|
||||
|
||||
bool repoReleasesMetaData();
|
||||
bool repoReleaseAssetsMetaData();
|
||||
@@ -272,7 +273,7 @@ class UpdateFactories : public QWidget
|
||||
void resetRunEnvironment(const QString & name);
|
||||
void resetAllRunEnvironments();
|
||||
void setRunUpdate(const QString & name);
|
||||
const QMap<QString, int> sortedComponentsList();
|
||||
const QMap<QString, int> sortedComponentsList(bool updateableOnly = false);
|
||||
|
||||
void clearRelease(const QString & name);
|
||||
const QString currentRelease(const QString & name);
|
||||
|
||||
@@ -86,6 +86,11 @@ void Updates::autoUpdates()
|
||||
|
||||
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();
|
||||
|
||||
UpdatesDialog *dlg = new UpdatesDialog(this, factories);
|
||||
|
||||
@@ -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
|
||||
QDialog *status = new QDialog(parent);
|
||||
status->setWindowTitle(tr("Progress"));
|
||||
status->setWindowTitle(tr("Downloading Release Metadata"));
|
||||
QVBoxLayout *layout = new QVBoxLayout(status);
|
||||
QLabel *msg = new QLabel(status);
|
||||
msg->setFixedWidth(400);
|
||||
@@ -141,7 +141,7 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||
grid->addItem(spacer, row, col++);
|
||||
|
||||
QMapIterator<QString, int> it(factories->sortedComponentsList());
|
||||
QMapIterator<QString, int> it(factories->sortedComponentsList(true));
|
||||
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
@@ -149,44 +149,42 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
|
||||
|
||||
const QString name = it.key();
|
||||
|
||||
if (g.component[i].checkForUpdate()) {
|
||||
row++;
|
||||
col = 0;
|
||||
row++;
|
||||
col = 0;
|
||||
|
||||
msg->setText(tr("Retrieving latest release information for %1").arg(name));
|
||||
chkUpdate[i] = new QCheckBox();
|
||||
chkUpdate[i]->setProperty("index", i);
|
||||
chkUpdate[i]->setChecked(!factories->isLatestRelease(name));
|
||||
grid->addWidget(chkUpdate[i], row, col++);
|
||||
grid->setAlignment(chkUpdate[i], Qt::AlignHCenter);
|
||||
msg->setText(tr("Retrieving latest release information for %1").arg(name));
|
||||
chkUpdate[i] = new QCheckBox();
|
||||
chkUpdate[i]->setProperty("index", i);
|
||||
chkUpdate[i]->setChecked(!factories->isLatestRelease(name));
|
||||
grid->addWidget(chkUpdate[i], row, col++);
|
||||
grid->setAlignment(chkUpdate[i], Qt::AlignHCenter);
|
||||
|
||||
QLabel *lblName = new QLabel(name);
|
||||
grid->addWidget(lblName, row, col++);
|
||||
QLabel *lblName = new QLabel(name);
|
||||
grid->addWidget(lblName, row, col++);
|
||||
|
||||
QLabel *lblRC = new QLabel(ComponentData::releaseChannelsList().at(g.component[i].releaseChannel()));
|
||||
grid->addWidget(lblRC, row, col++);
|
||||
QLabel *lblRC = new QLabel(ComponentData::releaseChannelsList().at(g.component[i].releaseChannel()));
|
||||
grid->addWidget(lblRC, row, col++);
|
||||
|
||||
lblCurrentRel[i] = new QLabel(factories->currentRelease(name));
|
||||
grid->addWidget(lblCurrentRel[i], row, col++);
|
||||
lblCurrentRel[i] = new QLabel(factories->currentRelease(name));
|
||||
grid->addWidget(lblCurrentRel[i], row, col++);
|
||||
|
||||
lblUpdateRel[i] = new QLabel(factories->updateRelease(name));
|
||||
grid->addWidget(lblUpdateRel[i], row, col++);
|
||||
lblUpdateRel[i] = new QLabel(factories->updateRelease(name));
|
||||
grid->addWidget(lblUpdateRel[i], row, col++);
|
||||
|
||||
btnOptions[i] = new QPushButton(tr("Options"));
|
||||
connect(btnOptions[i], &QPushButton::clicked, [=]() {
|
||||
UpdateOptionsDialog *dlg = new UpdateOptionsDialog(this, factories, i);
|
||||
connect(dlg, &UpdateOptionsDialog::changed, [=](const int i) {
|
||||
QString name = g.component[i].name();
|
||||
chkUpdate[i]->setChecked(!factories->isLatestRelease(name));
|
||||
lblCurrentRel[i]->setText(factories->currentRelease(name));
|
||||
lblUpdateRel[i]->setText(factories->updateRelease(name));
|
||||
});
|
||||
dlg->exec();
|
||||
dlg->deleteLater();
|
||||
btnOptions[i] = new QPushButton(tr("Options"));
|
||||
connect(btnOptions[i], &QPushButton::clicked, [=]() {
|
||||
UpdateOptionsDialog *dlg = new UpdateOptionsDialog(this, factories, i);
|
||||
connect(dlg, &UpdateOptionsDialog::changed, [=](const int i) {
|
||||
QString name = g.component[i].name();
|
||||
chkUpdate[i]->setChecked(!factories->isLatestRelease(name));
|
||||
lblCurrentRel[i]->setText(factories->currentRelease(name));
|
||||
lblUpdateRel[i]->setText(factories->updateRelease(name));
|
||||
});
|
||||
dlg->exec();
|
||||
dlg->deleteLater();
|
||||
});
|
||||
|
||||
grid->addWidget(btnOptions[i], row, col++);
|
||||
}
|
||||
grid->addWidget(btnOptions[i], row, col++);
|
||||
}
|
||||
|
||||
ui->grpComponents->setLayout(grid);
|
||||
|
||||
Reference in New Issue
Block a user