Changed: Use servers and profiles ID instead of indices for uninstall
--HG-- branch : develop
This commit is contained in:
parent
b952b51d05
commit
5a6a596eea
8 changed files with 30 additions and 16 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -40,8 +40,8 @@ struct SUninstallComponents
|
|||
installer = true;
|
||||
}
|
||||
|
||||
QVector<int> servers;
|
||||
QVector<int> profiles;
|
||||
QStringList servers;
|
||||
QStringList profiles;
|
||||
|
||||
bool installer;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<int, int>::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<int, int>::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<int, int>::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end();
|
||||
IDIndicesMap::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end();
|
||||
|
||||
while(it != iend)
|
||||
{
|
||||
|
|
|
@ -55,8 +55,10 @@ private:
|
|||
void updateButtons();
|
||||
|
||||
// key is original ID, value is row index
|
||||
QMap<int, int> m_serversIndices;
|
||||
QMap<int, int> m_profilesIndices;
|
||||
typedef QMap<QString, int> IDIndicesMap;
|
||||
|
||||
IDIndicesMap m_serversIndices;
|
||||
IDIndicesMap m_profilesIndices;
|
||||
|
||||
int m_installerIndex;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue