From eb4a46798d759416eff51584bffaf5dc6de5623c Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 14 Jun 2016 19:45:29 +0200 Subject: [PATCH] Changed: Helpers to get full path of a server or profile --- .../client/ryzom_installer/src/configfile.cpp | 16 +++++++++++++--- .../client/ryzom_installer/src/configfile.h | 6 ++++++ .../ryzom_installer/src/operationdialog.cpp | 14 ++++++-------- .../ryzom_installer/src/profilesdialog.cpp | 4 ++-- .../ryzom_installer/src/uninstalldialog.cpp | 6 +++--- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 6756515ab..4c1ea179c 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -27,6 +27,16 @@ const CServer NoServer; const CProfile NoProfile; +QString CServer::getDirectory() const +{ + return CConfigFile::getInstance()->getInstallationDirectory() + "/" + id; +} + +QString CProfile::getDirectory() const +{ + return CConfigFile::getInstance()->getProfileDirectory() + "/" + id; +} + CConfigFile *CConfigFile::s_instance = NULL; CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true) @@ -614,7 +624,7 @@ QString CConfigFile::getServerClientFullPath(const QString &serverId) const if (server.clientFilename.isEmpty()) return ""; - return getInstallationDirectory() + "/" + server.id + "/" + server.clientFilename; + return server.getDirectory() + "/" + server.clientFilename; } QString CConfigFile::getServerConfigurationFullPath(const QString &serverId) const @@ -623,7 +633,7 @@ QString CConfigFile::getServerConfigurationFullPath(const QString &serverId) con if (server.configurationFilename.isEmpty()) return ""; - return getInstallationDirectory() + "/" + server.id + "/" + server.configurationFilename; + return server.getDirectory() + "/" + server.configurationFilename; } QString CConfigFile::getSrcServerClientBNPFullPath() const @@ -680,7 +690,7 @@ OperationStep CConfigFile::getInstallNextStep() const return currentDirectory.isEmpty() ? ShowInstallWizard:ShowMigrateWizard; } - QString serverDirectory = getInstallationDirectory() + "/" + server.id; + QString serverDirectory = server.getDirectory(); if (getSrcServerDirectory().isEmpty()) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index 0edfee0ed..7f1ea301e 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -42,6 +42,9 @@ public: QString configurationFilename; QString installerFilename; QString comments; + + // helpers + QString getDirectory() const; }; extern const CServer NoServer; @@ -65,6 +68,9 @@ public: QString comments; bool desktopShortcut; bool menuShortcut; + + // helpers + QString getDirectory() const; }; extern const CProfile NoProfile; diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 912fc51eb..3f3a787db 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -382,7 +382,7 @@ void COperationDialog::copyServerFiles() CFilesCopier copier(this); copier.setSourceDirectory(config->getSrcServerDirectory()); - copier.setDestinationDirectory(config->getInstallationDirectory() + "/" + server.id); + copier.setDestinationDirectory(server.getDirectory()); copier.setIncludeFilter(serverFiles); if (copier.exec()) @@ -418,7 +418,7 @@ void COperationDialog::copyProfileFiles() CFilesCopier copier(this); copier.setSourceDirectory(config->getSrcProfileDirectory()); - copier.setDestinationDirectory(config->getProfileDirectory() + "/" + profile.id); + copier.setDestinationDirectory(profile.getDirectory()); copier.setIncludeFilter(profileFiles); if (copier.exec()) @@ -441,7 +441,7 @@ void COperationDialog::extractBnpClient() m_currentOperation = QApplication::tr("Extract client to new location"); m_currentOperationProgressFormat = QApplication::tr("Extracting %1..."); - QString destinationDirectory = config->getInstallationDirectory() + "/" + server.id; + QString destinationDirectory = server.getDirectory(); CFilesExtractor extractor(this); extractor.setSourceFile(config->getSrcServerClientBNPFullPath()); @@ -589,7 +589,7 @@ void COperationDialog::cleanFiles() m_currentOperationProgressFormat = QApplication::tr("Deleting %1..."); CFilesCleaner cleaner(this); - cleaner.setDirectory(config->getInstallationDirectory() + "/" + server.id); + cleaner.setDirectory(server.getDirectory()); cleaner.exec(); emit done(); @@ -720,7 +720,7 @@ void COperationDialog::deleteComponentsServers() emit progress(i++, server.name); - QString path = config->getInstallationDirectory() + "/" + server.id; + QString path = server.getDirectory(); QDir dir(path); @@ -759,9 +759,7 @@ void COperationDialog::deleteComponentsProfiles() emit progress(i++, profile.name); - QString path = config->getProfileDirectory() + "/" + profile.id; - - QDir dir(path); + QString path = profile.getDirectory(); if (dir.exists() && !dir.removeRecursively()) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp index ac126a1b6..85c176219 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp @@ -105,7 +105,7 @@ void CProfilesDialog::displayProfile(int index) executable = CConfigFile::getInstance()->getServerClientFullPath(profile.server); } - QString profileDirectory = CConfigFile::getInstance()->getProfileDirectory() + "/" + profile.id; + QString profileDirectory = profile.getDirectory(); // update all widgets with content of profile profileIdLabel->setText(profile.id); @@ -283,7 +283,7 @@ void CProfilesDialog::onProfileDirectoryClicked() const CProfile &profile = m_model->getProfiles()[m_currentProfileIndex]; - QString profileDirectory = CConfigFile::getInstance()->getProfileDirectory() + "/" + profile.id; + QString profileDirectory = profile.getDirectory(); QDesktopServices::openUrl(QUrl::fromLocalFile(profileDirectory)); } diff --git a/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp index bb514d7bc..62763063b 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp @@ -51,7 +51,7 @@ CUninstallDialog::CUninstallDialog(QWidget *parent):QDialog(parent), m_installer { const CServer &server = config->getServer(row); - if (QFile::exists(config->getInstallationDirectory() + "/" + server.id)) + if (QFile::exists(server.getDirectory())) { m_serversIndices[server.id] = model->rowCount(); @@ -228,7 +228,7 @@ void CUninstallDialog::updateSizes() { const CServer &server = config->getServer(it.key()); - qint64 bytes = getDirectorySize(config->getInstallationDirectory() + "/" + server.id); + qint64 bytes = getDirectorySize(server.getDirectory()); emit updateSize(it.value(), qBytesToHumanReadable(bytes)); @@ -242,7 +242,7 @@ void CUninstallDialog::updateSizes() { const CProfile &profile = config->getProfile(it.key()); - qint64 bytes = getDirectorySize(config->getProfileDirectory() + "/" + profile.id); + qint64 bytes = getDirectorySize(profile.getDirectory()); emit updateSize(it.value(), qBytesToHumanReadable(bytes));