mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-20 16:08:44 +00:00
Changed: Use SComponents for added or removed components
This commit is contained in:
parent
de2dc037fd
commit
40073b4e57
7 changed files with 133 additions and 75 deletions
|
@ -125,7 +125,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (parser.isSet(uninstallOption))
|
||||
{
|
||||
SUninstallComponents components;
|
||||
SComponents components;
|
||||
|
||||
// add all servers by default
|
||||
for (int i = 0; i < config.getServersCount(); ++i)
|
||||
|
|
|
@ -193,7 +193,7 @@ void CMainWindow::onUninstall()
|
|||
{
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
SUninstallComponents components;
|
||||
SComponents components;
|
||||
|
||||
// add all servers by default
|
||||
for (int i = 0; i < config->getServersCount(); ++i)
|
||||
|
|
|
@ -33,9 +33,9 @@ public:
|
|||
virtual bool operationShouldStop() =0;
|
||||
};
|
||||
|
||||
struct SUninstallComponents
|
||||
struct SComponents
|
||||
{
|
||||
SUninstallComponents()
|
||||
SComponents()
|
||||
{
|
||||
installer = true;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "config.h"
|
||||
#include "profilesmodel.h"
|
||||
#include "utils.h"
|
||||
#include "nel/misc/path.h"
|
||||
|
||||
#include "filescopier.h"
|
||||
#include "filesextractor.h"
|
||||
|
@ -82,9 +83,9 @@ void COperationDialog::setOperation(OperationType operation)
|
|||
m_operation = operation;
|
||||
}
|
||||
|
||||
void COperationDialog::setUninstallComponents(const SUninstallComponents &components)
|
||||
void COperationDialog::setUninstallComponents(const SComponents &components)
|
||||
{
|
||||
m_components = components;
|
||||
m_removeComponents = components;
|
||||
}
|
||||
|
||||
void COperationDialog::processNextStep()
|
||||
|
@ -191,21 +192,28 @@ void COperationDialog::processInstallNextStep()
|
|||
}
|
||||
}
|
||||
|
||||
void COperationDialog::processUpdateProfilesNextStep()
|
||||
void COperationDialog::updateAddRemoveComponents()
|
||||
{
|
||||
// TODO: check all servers are downloaded
|
||||
// TODO: delete profiles directories that are not used anymore
|
||||
// TODO: create shortcuts
|
||||
|
||||
QStringList serversToUpdate;
|
||||
|
||||
QStringList profilesToDelete;
|
||||
QStringList profilesToAdd;
|
||||
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
// append all old profiles
|
||||
foreach(const CProfile &profile, config->getProfiles())
|
||||
{
|
||||
// append all new profiles
|
||||
profilesToAdd << profile.id;
|
||||
}
|
||||
|
||||
foreach(const CProfile &profile, config->getBackupProfiles())
|
||||
{
|
||||
if (QFile::exists(profile.getDirectory())) profilesToDelete << profile.id;
|
||||
// append all old profiles
|
||||
profilesToDelete << profile.id;
|
||||
|
||||
// remove profiles that didn't exist
|
||||
profilesToAdd.removeAll(profile.id);
|
||||
}
|
||||
|
||||
const CServer &defaultServer = config->getServer();
|
||||
|
@ -226,18 +234,50 @@ void COperationDialog::processUpdateProfilesNextStep()
|
|||
profilesToDelete.removeAll(profile.id);
|
||||
}
|
||||
|
||||
if (!profilesToDelete.isEmpty())
|
||||
{
|
||||
m_components.profiles << profilesToDelete;
|
||||
// update components to remove
|
||||
m_removeComponents.profiles << profilesToDelete;
|
||||
m_removeComponents.installer = false;
|
||||
|
||||
// update components to add
|
||||
m_addComponents.profiles << profilesToAdd;
|
||||
m_addComponents.servers << serversToUpdate;
|
||||
m_addComponents.installer = false;
|
||||
}
|
||||
|
||||
void COperationDialog::processUpdateProfilesNextStep()
|
||||
{
|
||||
// for "update profiles" operations, we set installer to false when components are updated,
|
||||
// since we're not using this variable
|
||||
if (m_addComponents.installer && m_removeComponents.installer)
|
||||
{
|
||||
updateAddRemoveComponents();
|
||||
}
|
||||
// TODO: check all servers are downloaded
|
||||
// TODO: delete profiles directories that are not used anymore
|
||||
// TODO: create shortcuts
|
||||
|
||||
|
||||
if (!m_removeComponents.profiles.isEmpty())
|
||||
{
|
||||
// delete profiles in another thread
|
||||
QtConcurrent::run(this, &COperationDialog::deleteComponentsProfiles);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_addComponents.profiles.isEmpty())
|
||||
{
|
||||
// add profiles in another thread
|
||||
QtConcurrent::run(this, &COperationDialog::addComponentsProfiles);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_addComponents.servers.isEmpty())
|
||||
{
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
const CServer &defaultServer = config->getServer();
|
||||
|
||||
// servers files to download/update
|
||||
foreach(const QString &serverId, serversToUpdate)
|
||||
foreach(const QString &serverId, m_addComponents.servers)
|
||||
{
|
||||
const CServer &server = config->getServer(serverId);
|
||||
|
||||
|
@ -261,8 +301,7 @@ void COperationDialog::processUpdateProfilesNextStep()
|
|||
if (server.dataDownloadUrl != defaultServer.dataDownloadUrl)
|
||||
{
|
||||
// download it
|
||||
// TODO
|
||||
|
||||
downloadData();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -289,21 +328,24 @@ void COperationDialog::processUpdateProfilesNextStep()
|
|||
QString clientFile = config->getInstallationDirectory() + "/" + config->expandVariables(server.clientDownloadFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateAddRemoveEntry();
|
||||
}
|
||||
|
||||
void COperationDialog::processUninstallNextStep()
|
||||
{
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
if (!m_components.servers.isEmpty())
|
||||
if (!m_removeComponents.servers.isEmpty())
|
||||
{
|
||||
QtConcurrent::run(this, &COperationDialog::deleteComponentsServers);
|
||||
}
|
||||
else if (!m_components.profiles.isEmpty())
|
||||
else if (!m_removeComponents.profiles.isEmpty())
|
||||
{
|
||||
QtConcurrent::run(this, &COperationDialog::deleteComponentsProfiles);
|
||||
}
|
||||
else if (m_components.installer)
|
||||
else if (m_removeComponents.installer)
|
||||
{
|
||||
QtConcurrent::run(this, &COperationDialog::deleteComponentsInstaller);
|
||||
}
|
||||
|
@ -916,14 +958,14 @@ void COperationDialog::deleteComponentsServers()
|
|||
m_currentOperationProgressFormat = tr("Deleting %1...");
|
||||
|
||||
emit prepare();
|
||||
emit init(0, m_components.servers.size());
|
||||
emit init(0, m_removeComponents.servers.size());
|
||||
emit start();
|
||||
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach(const QString &serverId, m_components.servers)
|
||||
foreach(const QString &serverId, m_removeComponents.servers)
|
||||
{
|
||||
if (operationShouldStop())
|
||||
{
|
||||
|
@ -949,7 +991,11 @@ void COperationDialog::deleteComponentsServers()
|
|||
}
|
||||
}
|
||||
|
||||
emit success(m_components.servers.size());
|
||||
emit success(m_removeComponents.servers.size());
|
||||
|
||||
// clear list of all servers to uninstall
|
||||
m_removeComponents.servers.clear();
|
||||
|
||||
emit done();
|
||||
}
|
||||
|
||||
|
@ -959,13 +1005,13 @@ void COperationDialog::deleteComponentsProfiles()
|
|||
m_currentOperationProgressFormat = tr("Deleting profile %1...");
|
||||
|
||||
emit prepare();
|
||||
emit init(0, m_components.servers.size());
|
||||
emit init(0, m_removeComponents.servers.size());
|
||||
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach(const QString &profileId, m_components.profiles)
|
||||
foreach(const QString &profileId, m_removeComponents.profiles)
|
||||
{
|
||||
if (operationShouldStop())
|
||||
{
|
||||
|
@ -990,14 +1036,17 @@ void COperationDialog::deleteComponentsProfiles()
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: delete links
|
||||
|
||||
// delete profile
|
||||
config->removeProfile(profileId);
|
||||
}
|
||||
|
||||
// clear list of all profiles to uninstall
|
||||
m_components.profiles.clear();
|
||||
emit success(m_removeComponents.profiles.size());
|
||||
|
||||
// clear list of all profiles to uninstall
|
||||
m_removeComponents.profiles.clear();
|
||||
|
||||
emit success(m_components.servers.size());
|
||||
emit done();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
virtual ~COperationDialog();
|
||||
|
||||
void setOperation(OperationType operation);
|
||||
void setUninstallComponents(const SUninstallComponents &components);
|
||||
void setUninstallComponents(const SComponents &components);
|
||||
|
||||
public slots:
|
||||
void onAbortClicked();
|
||||
|
@ -106,10 +106,18 @@ protected:
|
|||
bool createClientMenuShortcut(int profileIndex);
|
||||
bool createAddRemoveEntry();
|
||||
bool deleteAddRemoveEntry();
|
||||
|
||||
void addComponentsServers();
|
||||
void deleteComponentsServers();
|
||||
|
||||
void addComponentsProfiles();
|
||||
void deleteComponentsProfiles();
|
||||
|
||||
void addComponentsInstaller();
|
||||
void deleteComponentsInstaller();
|
||||
|
||||
void updateAddRemoveComponents();
|
||||
|
||||
// from CFilesCopier
|
||||
virtual void operationPrepare();
|
||||
virtual void operationInit(qint64 current, qint64 total);
|
||||
|
@ -133,7 +141,8 @@ protected:
|
|||
bool m_aborting;
|
||||
|
||||
OperationType m_operation;
|
||||
SUninstallComponents m_components;
|
||||
SComponents m_addComponents;
|
||||
SComponents m_removeComponents;
|
||||
QString m_currentServerId;
|
||||
};
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ void CUninstallDialog::showEvent(QShowEvent *event)
|
|||
QtConcurrent::run(this, &CUninstallDialog::updateSizes);
|
||||
}
|
||||
|
||||
void CUninstallDialog::setSelectedComponents(const SUninstallComponents &components)
|
||||
void CUninstallDialog::setSelectedComponents(const SComponents &components)
|
||||
{
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(componentsTreeView->model());
|
||||
if (model == NULL) return;
|
||||
|
@ -150,9 +150,9 @@ void CUninstallDialog::setSelectedComponents(const SUninstallComponents &compone
|
|||
if (item) item->setCheckState(components.installer ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
|
||||
SUninstallComponents CUninstallDialog::getSelectedCompenents() const
|
||||
SComponents CUninstallDialog::getSelectedCompenents() const
|
||||
{
|
||||
SUninstallComponents res;
|
||||
SComponents res;
|
||||
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(componentsTreeView->model());
|
||||
if (model == NULL) return res;
|
||||
|
|
|
@ -35,8 +35,8 @@ public:
|
|||
CUninstallDialog(QWidget *parent = NULL);
|
||||
virtual ~CUninstallDialog();
|
||||
|
||||
void setSelectedComponents(const SUninstallComponents &components);
|
||||
SUninstallComponents getSelectedCompenents() const;
|
||||
void setSelectedComponents(const SComponents &components);
|
||||
SComponents getSelectedCompenents() const;
|
||||
|
||||
signals:
|
||||
void updateSize(int row, const QString &text);
|
||||
|
|
Loading…
Reference in a new issue