Changed: Implement components selection for uninstaller
--HG-- branch : develop
This commit is contained in:
parent
2e02f20c83
commit
ba8520f6d4
7 changed files with 181 additions and 52 deletions
|
@ -107,14 +107,12 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (parser.isSet(uninstallOption))
|
if (parser.isSet(uninstallOption))
|
||||||
{
|
{
|
||||||
QVector<int> selectedServers;
|
SUninstallComponents components;
|
||||||
QVector<int> selectedProfiles;
|
|
||||||
bool selectedInstaller = true;
|
|
||||||
|
|
||||||
// add all servers by default
|
// add all servers by default
|
||||||
for (int i = 0; i < config.getServersCount(); ++i)
|
for (int i = 0; i < config.getServersCount(); ++i)
|
||||||
{
|
{
|
||||||
selectedServers << i;
|
components.servers << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// show uninstall wizard dialog if not in silent mode
|
// show uninstall wizard dialog if not in silent mode
|
||||||
|
@ -122,25 +120,22 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
CUninstallWizardDialog dialog;
|
CUninstallWizardDialog dialog;
|
||||||
|
|
||||||
if (dialog.exec())
|
dialog.setSelectedComponents(components);
|
||||||
{
|
|
||||||
selectedServers = dialog.getSelectedServers();
|
// TODO: check real return codes from Uninstallers
|
||||||
selectedProfiles = dialog.getSelectedProfiles();
|
if (!dialog.exec()) return 1;
|
||||||
selectedInstaller = dialog.isInstallerSelected();
|
|
||||||
}
|
components = dialog.getSelectedCompenents();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
COperationDialog dialog;
|
||||||
COperationDialog dialog;
|
|
||||||
|
|
||||||
dialog.setOperation(COperationDialog::OperationUninstall);
|
dialog.setOperation(COperationDialog::OperationUninstall);
|
||||||
|
dialog.setUninstallComponents(components);
|
||||||
|
|
||||||
// TODO: set all components to uninstall
|
// TODO: set all components to uninstall
|
||||||
|
|
||||||
if (dialog.exec()) return 0;
|
return dialog.exec() ? 0 : 1;
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (step == CConfigFile::ShowMigrateWizard)
|
if (step == CConfigFile::ShowMigrateWizard)
|
||||||
|
|
|
@ -129,15 +129,33 @@ void CMainWindow::onProfiles()
|
||||||
|
|
||||||
void CMainWindow::onUninstall()
|
void CMainWindow::onUninstall()
|
||||||
{
|
{
|
||||||
CUninstallWizardDialog dialog(this);
|
CConfigFile *config = CConfigFile::getInstance();
|
||||||
|
|
||||||
|
SUninstallComponents components;
|
||||||
|
|
||||||
|
// add all servers by default
|
||||||
|
for (int i = 0; i < config->getServersCount(); ++i)
|
||||||
|
{
|
||||||
|
components.servers << i;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
CUninstallWizardDialog dialog(this);
|
||||||
|
|
||||||
|
dialog.setSelectedComponents(components);
|
||||||
|
|
||||||
|
if (!dialog.exec()) return;
|
||||||
|
|
||||||
|
components = dialog.getSelectedCompenents();
|
||||||
|
}
|
||||||
|
|
||||||
|
COperationDialog dialog;
|
||||||
|
|
||||||
|
dialog.setOperation(COperationDialog::OperationUninstall);
|
||||||
|
dialog.setUninstallComponents(components);
|
||||||
|
|
||||||
if (dialog.exec())
|
if (dialog.exec())
|
||||||
{
|
{
|
||||||
COperationDialog dialog(&dialog);
|
|
||||||
|
|
||||||
dialog.setOperation(COperationDialog::OperationUninstall);
|
|
||||||
|
|
||||||
dialog.exec();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,4 +33,17 @@ public:
|
||||||
virtual bool operationShouldStop() =0;
|
virtual bool operationShouldStop() =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SUninstallComponents
|
||||||
|
{
|
||||||
|
SUninstallComponents()
|
||||||
|
{
|
||||||
|
installer = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<int> servers;
|
||||||
|
QVector<int> profiles;
|
||||||
|
|
||||||
|
bool installer;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -89,6 +89,11 @@ void COperationDialog::setOperation(Operation operation)
|
||||||
m_operation = operation;
|
m_operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void COperationDialog::setUninstallComponents(const SUninstallComponents &components)
|
||||||
|
{
|
||||||
|
m_components = components;
|
||||||
|
}
|
||||||
|
|
||||||
void COperationDialog::processNextStep()
|
void COperationDialog::processNextStep()
|
||||||
{
|
{
|
||||||
switch (m_operation)
|
switch (m_operation)
|
||||||
|
@ -202,6 +207,25 @@ void COperationDialog::processInstallNextStep()
|
||||||
|
|
||||||
void COperationDialog::processUninstallNextStep()
|
void COperationDialog::processUninstallNextStep()
|
||||||
{
|
{
|
||||||
|
CConfigFile *config = CConfigFile::getInstance();
|
||||||
|
|
||||||
|
if (!m_components.servers.isEmpty())
|
||||||
|
{
|
||||||
|
QtConcurrent::run(this, &COperationDialog::deleteComponentsServers);
|
||||||
|
}
|
||||||
|
else if (!m_components.profiles.isEmpty())
|
||||||
|
{
|
||||||
|
QtConcurrent::run(this, &COperationDialog::deleteComponentsProfiles);
|
||||||
|
}
|
||||||
|
else if (m_components.installer)
|
||||||
|
{
|
||||||
|
QtConcurrent::run(this, &COperationDialog::deleteComponentsInstaller);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// done
|
||||||
|
accept();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void COperationDialog::showEvent(QShowEvent *e)
|
void COperationDialog::showEvent(QShowEvent *e)
|
||||||
|
@ -644,6 +668,48 @@ bool COperationDialog::createAddRemoveEntry()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void COperationDialog::deleteComponentsServers()
|
||||||
|
{
|
||||||
|
m_currentOperation = QApplication::tr("Delete client files");
|
||||||
|
m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
|
||||||
|
|
||||||
|
// connect(m_downloader, SIGNAL(downloadPrepare()), SLOT(onProgressPrepare()));
|
||||||
|
// connect(m_downloader, SIGNAL(downloadInit(qint64, qint64)), SLOT(onProgressInit(qint64, qint64)));
|
||||||
|
// connect(m_downloader, SIGNAL(downloadStart()), SLOT(onProgressStart()));
|
||||||
|
// connect(m_downloader, SIGNAL(downloadStop()), SLOT(onProgressStop()));
|
||||||
|
// connect(m_downloader, SIGNAL(downloadProgress(qint64, QString)), SLOT(onProgressProgress(qint64, QString)));
|
||||||
|
|
||||||
|
|
||||||
|
CConfigFile *config = CConfigFile::getInstance();
|
||||||
|
|
||||||
|
foreach(int serverIndex, m_components.servers)
|
||||||
|
{
|
||||||
|
const CServer &server = config->getServer(serverIndex);
|
||||||
|
|
||||||
|
QString path = config->getInstallationDirectory() + "/" + server.id;
|
||||||
|
|
||||||
|
QDir dir(path);
|
||||||
|
|
||||||
|
if (!dir.exists() || !dir.removeRecursively())
|
||||||
|
{
|
||||||
|
emit onProgressFail(tr("Uninstall to delete files for client %1").arg(server.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit onProgressSuccess(m_components.servers.size());
|
||||||
|
emit done();
|
||||||
|
}
|
||||||
|
|
||||||
|
void COperationDialog::deleteComponentsProfiles()
|
||||||
|
{
|
||||||
|
emit done();
|
||||||
|
}
|
||||||
|
|
||||||
|
void COperationDialog::deleteComponentsInstaller()
|
||||||
|
{
|
||||||
|
emit done();
|
||||||
|
}
|
||||||
|
|
||||||
void COperationDialog::operationPrepare()
|
void COperationDialog::operationPrepare()
|
||||||
{
|
{
|
||||||
emit prepare();
|
emit prepare();
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
void setOperation(Operation operation);
|
void setOperation(Operation operation);
|
||||||
|
void setUninstallComponents(const SUninstallComponents &components);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onAbortClicked();
|
void onAbortClicked();
|
||||||
|
@ -106,6 +107,9 @@ protected:
|
||||||
bool createDefaultProfile();
|
bool createDefaultProfile();
|
||||||
bool createDefaultShortcuts();
|
bool createDefaultShortcuts();
|
||||||
bool createAddRemoveEntry();
|
bool createAddRemoveEntry();
|
||||||
|
void deleteComponentsServers();
|
||||||
|
void deleteComponentsProfiles();
|
||||||
|
void deleteComponentsInstaller();
|
||||||
|
|
||||||
// from CFilesCopier
|
// from CFilesCopier
|
||||||
virtual void operationPrepare();
|
virtual void operationPrepare();
|
||||||
|
@ -128,6 +132,7 @@ protected:
|
||||||
bool m_aborting;
|
bool m_aborting;
|
||||||
|
|
||||||
Operation m_operation;
|
Operation m_operation;
|
||||||
|
SUninstallComponents m_components;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -44,6 +44,8 @@ CUninstallWizardDialog::CUninstallWizardDialog(QWidget *parent):QDialog(parent),
|
||||||
|
|
||||||
model->setHorizontalHeaderLabels(columns);
|
model->setHorizontalHeaderLabels(columns);
|
||||||
|
|
||||||
|
QStandardItem *item = NULL;
|
||||||
|
|
||||||
// clients
|
// clients
|
||||||
for (int row = 0; row < serverCount; ++row)
|
for (int row = 0; row < serverCount; ++row)
|
||||||
{
|
{
|
||||||
|
@ -53,9 +55,8 @@ CUninstallWizardDialog::CUninstallWizardDialog(QWidget *parent):QDialog(parent),
|
||||||
{
|
{
|
||||||
m_serversIndices[row] = model->rowCount();
|
m_serversIndices[row] = model->rowCount();
|
||||||
|
|
||||||
QStandardItem *item = new QStandardItem(tr("Client for %1").arg(server.name));
|
item = new QStandardItem(tr("Client for %1").arg(server.name));
|
||||||
item->setCheckable(true);
|
item->setCheckable(true);
|
||||||
item->setCheckState(Qt::Checked);
|
|
||||||
model->appendRow(item);
|
model->appendRow(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +70,7 @@ CUninstallWizardDialog::CUninstallWizardDialog(QWidget *parent):QDialog(parent),
|
||||||
|
|
||||||
const CProfile &profile = config->getProfile(row);
|
const CProfile &profile = config->getProfile(row);
|
||||||
|
|
||||||
QStandardItem *item = new QStandardItem(tr("Profile #%1: %2").arg(profile.id).arg(profile.name));
|
item = new QStandardItem(tr("Profile #%1: %2").arg(profile.id).arg(profile.name));
|
||||||
item->setCheckable(true);
|
item->setCheckable(true);
|
||||||
model->appendRow(item);
|
model->appendRow(item);
|
||||||
|
|
||||||
|
@ -77,9 +78,8 @@ CUninstallWizardDialog::CUninstallWizardDialog(QWidget *parent):QDialog(parent),
|
||||||
|
|
||||||
m_installerIndex = model->rowCount();
|
m_installerIndex = model->rowCount();
|
||||||
|
|
||||||
QStandardItem *item = new QStandardItem(tr("Ryzom Installer"));
|
item = new QStandardItem(tr("Ryzom Installer"));
|
||||||
item->setCheckable(true);
|
item->setCheckable(true);
|
||||||
item->setCheckState(Qt::Checked);
|
|
||||||
model->appendRow(item);
|
model->appendRow(item);
|
||||||
|
|
||||||
componentsTreeView->setModel(model);
|
componentsTreeView->setModel(model);
|
||||||
|
@ -100,58 +100,89 @@ CUninstallWizardDialog::~CUninstallWizardDialog()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<int> CUninstallWizardDialog::getSelectedServers() const
|
void CUninstallWizardDialog::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
QVector<int> res;
|
QDialog::showEvent(event);
|
||||||
|
|
||||||
|
QtConcurrent::run(this, &CUninstallWizardDialog::updateSizes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CUninstallWizardDialog::setSelectedComponents(const SUninstallComponents &components)
|
||||||
|
{
|
||||||
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(componentsTreeView->model());
|
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(componentsTreeView->model());
|
||||||
if (model == NULL) return res;
|
if (model == NULL) return;
|
||||||
|
|
||||||
|
QStandardItem *item = NULL;
|
||||||
|
|
||||||
|
// servers
|
||||||
QMap<int, int>::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end();
|
QMap<int, int>::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end();
|
||||||
|
|
||||||
while (it != iend)
|
while (it != iend)
|
||||||
{
|
{
|
||||||
QStandardItem *item = model->item(m_installerIndex);
|
item = model->item(it.value());
|
||||||
|
|
||||||
if (item && item->checkState() == Qt::Checked) res << it.value();
|
if (item) item->setCheckState(components.servers.indexOf(it.key()) > -1 ? Qt::Checked : Qt::Unchecked);
|
||||||
|
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
// profiles
|
||||||
|
it = m_profilesIndices.begin(), iend = m_profilesIndices.end();
|
||||||
|
|
||||||
|
while (it != iend)
|
||||||
|
{
|
||||||
|
item = model->item(it.value());
|
||||||
|
|
||||||
|
if (item) item->setCheckState(components.profiles.indexOf(it.key()) > -1 ? Qt::Checked : Qt::Unchecked);
|
||||||
|
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
|
// installer
|
||||||
|
item = model->item(m_installerIndex);
|
||||||
|
if (item) item->setCheckState(components.installer ? Qt::Checked : Qt::Unchecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<int> CUninstallWizardDialog::getSelectedProfiles() const
|
SUninstallComponents CUninstallWizardDialog::getSelectedCompenents() const
|
||||||
{
|
{
|
||||||
QVector<int> res;
|
SUninstallComponents res;
|
||||||
|
|
||||||
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(componentsTreeView->model());
|
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(componentsTreeView->model());
|
||||||
if (model == NULL) return res;
|
if (model == NULL) return res;
|
||||||
|
|
||||||
QMap<int, int>::const_iterator it = m_profilesIndices.begin(), iend = m_profilesIndices.end();
|
QStandardItem *item = NULL;
|
||||||
|
|
||||||
|
// servers
|
||||||
|
QMap<int, int>::const_iterator it = m_serversIndices.begin(), iend = m_serversIndices.end();
|
||||||
|
|
||||||
while (it != iend)
|
while (it != iend)
|
||||||
{
|
{
|
||||||
QStandardItem *item = model->item(m_installerIndex);
|
item = model->item(it.value());
|
||||||
|
|
||||||
if (item && item->checkState() == Qt::Checked) res << it.value();
|
if (item && item->checkState() == Qt::Checked) res.servers << it.key();
|
||||||
|
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// profiles
|
||||||
|
it = m_profilesIndices.begin(), iend = m_profilesIndices.end();
|
||||||
|
|
||||||
|
while (it != iend)
|
||||||
|
{
|
||||||
|
item = model->item(it.value());
|
||||||
|
|
||||||
|
if (item && item->checkState() == Qt::Checked) res.profiles << it.key();
|
||||||
|
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
|
// installer
|
||||||
|
item = model->item(m_installerIndex);
|
||||||
|
res.installer = item && item->checkState() == Qt::Checked;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUninstallWizardDialog::isInstallerSelected() const
|
|
||||||
{
|
|
||||||
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(componentsTreeView->model());
|
|
||||||
if (model == NULL) return false;
|
|
||||||
|
|
||||||
QStandardItem *item = model->item(m_installerIndex);
|
|
||||||
|
|
||||||
return item && item->checkState() == Qt::Checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CUninstallWizardDialog::accept()
|
void CUninstallWizardDialog::accept()
|
||||||
{
|
{
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#define UNINSTALLWIZARDDIALOG_H
|
#define UNINSTALLWIZARDDIALOG_H
|
||||||
|
|
||||||
#include "ui_uninstallwizard.h"
|
#include "ui_uninstallwizard.h"
|
||||||
|
#include "operation.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wizard displayed at first launch, that asks user to choose source and destination directories.
|
* Wizard displayed at first launch, that asks user to choose source and destination directories.
|
||||||
|
@ -33,8 +34,8 @@ public:
|
||||||
CUninstallWizardDialog(QWidget *parent = NULL);
|
CUninstallWizardDialog(QWidget *parent = NULL);
|
||||||
virtual ~CUninstallWizardDialog();
|
virtual ~CUninstallWizardDialog();
|
||||||
|
|
||||||
QVector<int> getSelectedServers() const;
|
void setSelectedComponents(const SUninstallComponents &components);
|
||||||
QVector<int> getSelectedProfiles() const;
|
SUninstallComponents getSelectedCompenents() const;
|
||||||
|
|
||||||
bool isInstallerSelected() const;
|
bool isInstallerSelected() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue