Changed: Delete downloaded files in uninstaller

--HG--
branch : develop
This commit is contained in:
kervala 2016-06-26 19:41:33 +02:00
parent 8d3ca27424
commit fb4461f00b
5 changed files with 63 additions and 2 deletions

View file

@ -38,12 +38,14 @@ struct SComponents
SComponents()
{
installer = true;
downloadedFiles = true;
}
QStringList servers;
QStringList profiles;
bool installer;
bool downloadedFiles;
};
enum OperationStep

View file

@ -243,11 +243,13 @@ void COperationDialog::updateAddRemoveComponents()
// update components to remove
m_removeComponents.profiles << profilesToDelete;
m_removeComponents.installer = false;
m_removeComponents.downloadedFiles = false;
// update components to add
m_addComponents.profiles << profilesToAdd;
m_addComponents.servers << serversToUpdate;
m_addComponents.installer = false;
m_addComponents.downloadedFiles = false;
}
void COperationDialog::processUpdateProfilesNextStep()
@ -351,6 +353,10 @@ void COperationDialog::processUninstallNextStep()
{
QtConcurrent::run(this, &COperationDialog::deleteComponentsProfiles);
}
else if (m_removeComponents.downloadedFiles)
{
QtConcurrent::run(this, &COperationDialog::deleteComponentsDownloadedFiles);
}
else if (m_removeComponents.installer)
{
QtConcurrent::run(this, &COperationDialog::deleteComponentsInstaller);
@ -1154,6 +1160,43 @@ void COperationDialog::deleteComponentsInstaller()
// TODO:
// reset it once it's done
m_removeComponents.installer = false;
emit onProgressSuccess(1);
emit done();
}
void COperationDialog::deleteComponentsDownloadedFiles()
{
m_currentOperation = tr("Delete downloaded files");
m_currentOperationProgressFormat = tr("Deleting %1...");
CConfigFile *config = CConfigFile::getInstance();
QString path = config->getInstallationDirectory();
QDir dir(path);
QStringList filter;
filter << "*.7z";
filter << "*.bnp";
filter << "*.zip";
filter << "*.part";
QStringList files = dir.entryList(filter, QDir::Files);
foreach(const QString &file, files)
{
if (!QFile::remove(file))
{
qDebug() << "Unable to delete" << file;
}
}
// reset it once it's done
m_removeComponents.downloadedFiles = false;
emit onProgressSuccess(1);
emit done();
}

View file

@ -116,8 +116,8 @@ protected:
void addComponentsProfiles();
void deleteComponentsProfiles();
void addComponentsInstaller();
void deleteComponentsInstaller();
void deleteComponentsDownloadedFiles();
void updateAddRemoveComponents();

View file

@ -79,7 +79,14 @@ CUninstallDialog::CUninstallDialog(QWidget *parent):QDialog(parent), m_installer
// installer
m_installerIndex = model->rowCount();
item = new QStandardItem(tr("Ryzom Installer"));
item = new QStandardItem(tr("Installer"));
item->setCheckable(true);
model->appendRow(item);
// downloaded files
m_downloadedFilesIndex = model->rowCount();
item = new QStandardItem(tr("Downloaded Files"));
item->setCheckable(true);
model->appendRow(item);
@ -148,6 +155,10 @@ void CUninstallDialog::setSelectedComponents(const SComponents &components)
// installer
item = model->item(m_installerIndex);
if (item) item->setCheckState(components.installer ? Qt::Checked : Qt::Unchecked);
// downloaded files
item = model->item(m_downloadedFilesIndex);
if (item) item->setCheckState(components.downloadedFiles ? Qt::Checked : Qt::Unchecked);
}
SComponents CUninstallDialog::getSelectedCompenents() const
@ -187,6 +198,10 @@ SComponents CUninstallDialog::getSelectedCompenents() const
item = model->item(m_installerIndex);
res.installer = item && item->checkState() == Qt::Checked;
// downloaded files
item = model->item(m_downloadedFilesIndex);
res.downloadedFiles = item && item->checkState() == Qt::Checked;
return res;
}

View file

@ -61,6 +61,7 @@ private:
IDIndicesMap m_profilesIndices;
int m_installerIndex;
int m_downloadedFilesIndex;
};
#endif