Changed: Delete downloaded files in uninstaller
This commit is contained in:
parent
a7f1e4e8e8
commit
87312ab4f0
5 changed files with 63 additions and 2 deletions
|
@ -38,12 +38,14 @@ struct SComponents
|
||||||
SComponents()
|
SComponents()
|
||||||
{
|
{
|
||||||
installer = true;
|
installer = true;
|
||||||
|
downloadedFiles = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList servers;
|
QStringList servers;
|
||||||
QStringList profiles;
|
QStringList profiles;
|
||||||
|
|
||||||
bool installer;
|
bool installer;
|
||||||
|
bool downloadedFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OperationStep
|
enum OperationStep
|
||||||
|
|
|
@ -243,11 +243,13 @@ void COperationDialog::updateAddRemoveComponents()
|
||||||
// update components to remove
|
// update components to remove
|
||||||
m_removeComponents.profiles << profilesToDelete;
|
m_removeComponents.profiles << profilesToDelete;
|
||||||
m_removeComponents.installer = false;
|
m_removeComponents.installer = false;
|
||||||
|
m_removeComponents.downloadedFiles = false;
|
||||||
|
|
||||||
// update components to add
|
// update components to add
|
||||||
m_addComponents.profiles << profilesToAdd;
|
m_addComponents.profiles << profilesToAdd;
|
||||||
m_addComponents.servers << serversToUpdate;
|
m_addComponents.servers << serversToUpdate;
|
||||||
m_addComponents.installer = false;
|
m_addComponents.installer = false;
|
||||||
|
m_addComponents.downloadedFiles = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void COperationDialog::processUpdateProfilesNextStep()
|
void COperationDialog::processUpdateProfilesNextStep()
|
||||||
|
@ -351,6 +353,10 @@ void COperationDialog::processUninstallNextStep()
|
||||||
{
|
{
|
||||||
QtConcurrent::run(this, &COperationDialog::deleteComponentsProfiles);
|
QtConcurrent::run(this, &COperationDialog::deleteComponentsProfiles);
|
||||||
}
|
}
|
||||||
|
else if (m_removeComponents.downloadedFiles)
|
||||||
|
{
|
||||||
|
QtConcurrent::run(this, &COperationDialog::deleteComponentsDownloadedFiles);
|
||||||
|
}
|
||||||
else if (m_removeComponents.installer)
|
else if (m_removeComponents.installer)
|
||||||
{
|
{
|
||||||
QtConcurrent::run(this, &COperationDialog::deleteComponentsInstaller);
|
QtConcurrent::run(this, &COperationDialog::deleteComponentsInstaller);
|
||||||
|
@ -1154,6 +1160,43 @@ void COperationDialog::deleteComponentsInstaller()
|
||||||
|
|
||||||
// TODO:
|
// 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 onProgressSuccess(1);
|
||||||
emit done();
|
emit done();
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,8 @@ protected:
|
||||||
void addComponentsProfiles();
|
void addComponentsProfiles();
|
||||||
void deleteComponentsProfiles();
|
void deleteComponentsProfiles();
|
||||||
|
|
||||||
void addComponentsInstaller();
|
|
||||||
void deleteComponentsInstaller();
|
void deleteComponentsInstaller();
|
||||||
|
void deleteComponentsDownloadedFiles();
|
||||||
|
|
||||||
void updateAddRemoveComponents();
|
void updateAddRemoveComponents();
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,14 @@ CUninstallDialog::CUninstallDialog(QWidget *parent):QDialog(parent), m_installer
|
||||||
// installer
|
// installer
|
||||||
m_installerIndex = model->rowCount();
|
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);
|
item->setCheckable(true);
|
||||||
model->appendRow(item);
|
model->appendRow(item);
|
||||||
|
|
||||||
|
@ -148,6 +155,10 @@ void CUninstallDialog::setSelectedComponents(const SComponents &components)
|
||||||
// installer
|
// installer
|
||||||
item = model->item(m_installerIndex);
|
item = model->item(m_installerIndex);
|
||||||
if (item) item->setCheckState(components.installer ? Qt::Checked : Qt::Unchecked);
|
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
|
SComponents CUninstallDialog::getSelectedCompenents() const
|
||||||
|
@ -187,6 +198,10 @@ SComponents CUninstallDialog::getSelectedCompenents() const
|
||||||
item = model->item(m_installerIndex);
|
item = model->item(m_installerIndex);
|
||||||
res.installer = item && item->checkState() == Qt::Checked;
|
res.installer = item && item->checkState() == Qt::Checked;
|
||||||
|
|
||||||
|
// downloaded files
|
||||||
|
item = model->item(m_downloadedFilesIndex);
|
||||||
|
res.downloadedFiles = item && item->checkState() == Qt::Checked;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ private:
|
||||||
IDIndicesMap m_profilesIndices;
|
IDIndicesMap m_profilesIndices;
|
||||||
|
|
||||||
int m_installerIndex;
|
int m_installerIndex;
|
||||||
|
int m_downloadedFilesIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue