Axivion: Fix handling of default dashboard

Update correctly after loading and set new id after
changing the dashboard inside the settings.
Limit updating the QC settings and respectively writing
the Axivion settings to real changes.

Change-Id: I9e04d8e8007caccdd6b081b52d1fd22641919c7e
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Mohammad Mehdi Salem Naraghi <mehdi.salem@qt.io>
This commit is contained in:
Christian Stenger
2024-09-25 14:57:09 +02:00
parent 257eb02f4b
commit c7a0fee1fd
2 changed files with 17 additions and 10 deletions

View File

@@ -245,17 +245,17 @@ void AxivionSettings::disableCertificateValidation(const Utils::Id &id)
m_allServers[index].validateCert = false;
}
void AxivionSettings::updateDashboardServers(const QList<AxivionServer> &other)
bool AxivionSettings::updateDashboardServers(const QList<AxivionServer> &other,
const Utils::Id &selected)
{
if (m_allServers == other)
return;
const Id oldDefault = defaultDashboardId();
if (!Utils::anyOf(other, [&oldDefault](const AxivionServer &s) { return s.id == oldDefault; }))
m_defaultServerId.setValue(other.isEmpty() ? QString{} : other.first().id.toString());
if (selected == oldDefault && m_allServers == other)
return false;
m_defaultServerId.setValue(selected.toString());
m_allServers = other;
emit changed(); // should we be more detailed? (id)
return true;
}
const QList<PathMapping> AxivionSettings::validPathMappings() const
@@ -417,15 +417,22 @@ void AxivionSettingsWidget::apply()
QList<AxivionServer> servers;
for (int i = 0, end = m_dashboardServers->count(); i < end; ++i)
servers.append(m_dashboardServers->itemData(i).value<AxivionServer>());
settings().updateDashboardServers(servers);
settings().toSettings();
if (settings().updateDashboardServers(servers, servers.at(m_dashboardServers->currentIndex()).id))
settings().toSettings();
}
void AxivionSettingsWidget::updateDashboardServers()
{
m_dashboardServers->clear();
for (const AxivionServer &server : settings().allAvailableServers())
const QList<AxivionServer> servers = settings().allAvailableServers();
for (const AxivionServer &server : servers)
m_dashboardServers->addItem(server.displayString(), QVariant::fromValue(server));
int index = Utils::indexOf(servers,
[id = settings().defaultDashboardId()](const AxivionServer &s) {
return id == s.id;
});
if (index != -1)
m_dashboardServers->setCurrentIndex(index);
}
void AxivionSettingsWidget::updateEnabledStates()

View File

@@ -57,7 +57,7 @@ public:
const AxivionServer serverForId(const Utils::Id &id) const;
void disableCertificateValidation(const Utils::Id &id);
const QList<AxivionServer> allAvailableServers() const { return m_allServers; };
void updateDashboardServers(const QList<AxivionServer> &other);
bool updateDashboardServers(const QList<AxivionServer> &other, const Utils::Id &selected);
const QList<PathMapping> validPathMappings() const;
Utils::BoolAspect highlightMarks{this};