From 94bf161016140ac58d6918e0316ff29317f62e29 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 14 Jun 2016 19:43:45 +0200 Subject: [PATCH] Changed: Use servers and profiles ID instead of indices for uninstall --- .../tools/client/ryzom_installer/src/configfile.cpp | 11 +++++++++++ .../tools/client/ryzom_installer/src/configfile.h | 1 + code/ryzom/tools/client/ryzom_installer/src/main.cpp | 2 +- .../tools/client/ryzom_installer/src/mainwindow.cpp | 2 +- .../tools/client/ryzom_installer/src/operation.h | 4 ++-- .../client/ryzom_installer/src/operationdialog.cpp | 8 ++++---- .../client/ryzom_installer/src/uninstalldialog.cpp | 12 ++++++------ .../client/ryzom_installer/src/uninstalldialog.h | 6 ++++-- 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 7367cddba..6756515ab 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -277,6 +277,17 @@ CProfile CConfigFile::getProfile(int i) const return m_profiles.at(i); } +CProfile CConfigFile::getProfile(const QString &id) const +{ + for (int i = 0; i < m_profiles.size(); ++i) + { + if (m_profiles[i].id == id) return m_profiles[i]; + } + + // default profile + return getProfile(); +} + void CConfigFile::setProfile(int i, const CProfile &profile) { m_profiles[i] = profile; diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index 1122ca78e..0edfee0ed 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -106,6 +106,7 @@ public: int getProfilesCount() const; CProfile getProfile(int i = -1) const; + CProfile getProfile(const QString &id) const; void setProfile(int i, const CProfile &profile); int addProfile(const CProfile &profile); void removeProfile(int i); diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index be15c75c3..4d91fa088 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) // add all servers by default for (int i = 0; i < config.getServersCount(); ++i) { - components.servers << i; + components.servers << config.getServer(i).id; } // show uninstall wizard dialog if not in silent mode diff --git a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp index cbdea44b0..52109f703 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp @@ -197,7 +197,7 @@ void CMainWindow::onUninstall() // add all servers by default for (int i = 0; i < config->getServersCount(); ++i) { - components.servers << i; + components.servers << config->getServer(i).id; } { diff --git a/code/ryzom/tools/client/ryzom_installer/src/operation.h b/code/ryzom/tools/client/ryzom_installer/src/operation.h index cdcd64a93..e8e0af678 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operation.h +++ b/code/ryzom/tools/client/ryzom_installer/src/operation.h @@ -40,8 +40,8 @@ struct SUninstallComponents installer = true; } - QVector servers; - QVector profiles; + QStringList servers; + QStringList profiles; bool installer; }; diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 0f2c2d731..912fc51eb 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -708,7 +708,7 @@ void COperationDialog::deleteComponentsServers() int i = 0; - foreach(int serverIndex, m_components.servers) + foreach(const QString &serverId, m_components.servers) { if (operationShouldStop()) { @@ -716,7 +716,7 @@ void COperationDialog::deleteComponentsServers() return; } - const CServer &server = config->getServer(serverIndex); + const CServer &server = config->getServer(serverId); emit progress(i++, server.name); @@ -747,7 +747,7 @@ void COperationDialog::deleteComponentsProfiles() int i = 0; - foreach(int profileIndex, m_components.profiles) + foreach(const QString &profileId, m_components.profiles) { if (operationShouldStop()) { @@ -755,7 +755,7 @@ void COperationDialog::deleteComponentsProfiles() return; } - const CProfile &profile = config->getProfile(profileIndex); + const CProfile &profile = config->getProfile(profileId); emit progress(i++, profile.name); diff --git a/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp index aee6290f1..bb514d7bc 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp @@ -53,7 +53,7 @@ CUninstallDialog::CUninstallDialog(QWidget *parent):QDialog(parent), m_installer if (QFile::exists(config->getInstallationDirectory() + "/" + server.id)) { - m_serversIndices[row] = model->rowCount(); + m_serversIndices[server.id] = model->rowCount(); item = new QStandardItem(tr("Client for %1").arg(server.name)); item->setCheckable(true); @@ -66,10 +66,10 @@ CUninstallDialog::CUninstallDialog(QWidget *parent):QDialog(parent), m_installer // profiles for (int row = 0; row < profilesCount; ++row) { - m_profilesIndices[row] = model->rowCount(); - const CProfile &profile = config->getProfile(row); + m_profilesIndices[profile.id] = model->rowCount(); + item = new QStandardItem(tr("Profile #%1: %2").arg(profile.id).arg(profile.name)); item->setCheckable(true); model->appendRow(item); @@ -122,7 +122,7 @@ void CUninstallDialog::setSelectedComponents(const SUninstallComponents &compone QStandardItem *item = NULL; // servers - QMap::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end(); + IDIndicesMap::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end(); while (it != iend) { @@ -160,7 +160,7 @@ SUninstallComponents CUninstallDialog::getSelectedCompenents() const QStandardItem *item = NULL; // servers - QMap::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end(); + IDIndicesMap::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end(); while (it != iend) { @@ -222,7 +222,7 @@ void CUninstallDialog::updateSizes() CConfigFile *config = CConfigFile::getInstance(); // clients - QMap::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end(); + IDIndicesMap::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end(); while(it != iend) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.h b/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.h index d9bea4449..08f7f536d 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.h +++ b/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.h @@ -55,8 +55,10 @@ private: void updateButtons(); // key is original ID, value is row index - QMap m_serversIndices; - QMap m_profilesIndices; + typedef QMap IDIndicesMap; + + IDIndicesMap m_serversIndices; + IDIndicesMap m_profilesIndices; int m_installerIndex; };