Changed: Helpers to get full path of a server or profile
--HG-- branch : develop
This commit is contained in:
parent
5a6a596eea
commit
d6400c9d4e
5 changed files with 30 additions and 16 deletions
|
@ -27,6 +27,16 @@
|
||||||
const CServer NoServer;
|
const CServer NoServer;
|
||||||
const CProfile NoProfile;
|
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::s_instance = NULL;
|
||||||
|
|
||||||
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true)
|
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 "";
|
if (server.clientFilename.isEmpty()) return "";
|
||||||
|
|
||||||
return getInstallationDirectory() + "/" + server.id + "/" + server.clientFilename;
|
return server.getDirectory() + "/" + server.clientFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CConfigFile::getServerConfigurationFullPath(const QString &serverId) const
|
QString CConfigFile::getServerConfigurationFullPath(const QString &serverId) const
|
||||||
|
@ -623,7 +633,7 @@ QString CConfigFile::getServerConfigurationFullPath(const QString &serverId) con
|
||||||
|
|
||||||
if (server.configurationFilename.isEmpty()) return "";
|
if (server.configurationFilename.isEmpty()) return "";
|
||||||
|
|
||||||
return getInstallationDirectory() + "/" + server.id + "/" + server.configurationFilename;
|
return server.getDirectory() + "/" + server.configurationFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CConfigFile::getSrcServerClientBNPFullPath() const
|
QString CConfigFile::getSrcServerClientBNPFullPath() const
|
||||||
|
@ -680,7 +690,7 @@ OperationStep CConfigFile::getInstallNextStep() const
|
||||||
return currentDirectory.isEmpty() ? ShowInstallWizard:ShowMigrateWizard;
|
return currentDirectory.isEmpty() ? ShowInstallWizard:ShowMigrateWizard;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString serverDirectory = getInstallationDirectory() + "/" + server.id;
|
QString serverDirectory = server.getDirectory();
|
||||||
|
|
||||||
if (getSrcServerDirectory().isEmpty())
|
if (getSrcServerDirectory().isEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,6 +42,9 @@ public:
|
||||||
QString configurationFilename;
|
QString configurationFilename;
|
||||||
QString installerFilename;
|
QString installerFilename;
|
||||||
QString comments;
|
QString comments;
|
||||||
|
|
||||||
|
// helpers
|
||||||
|
QString getDirectory() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const CServer NoServer;
|
extern const CServer NoServer;
|
||||||
|
@ -65,6 +68,9 @@ public:
|
||||||
QString comments;
|
QString comments;
|
||||||
bool desktopShortcut;
|
bool desktopShortcut;
|
||||||
bool menuShortcut;
|
bool menuShortcut;
|
||||||
|
|
||||||
|
// helpers
|
||||||
|
QString getDirectory() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const CProfile NoProfile;
|
extern const CProfile NoProfile;
|
||||||
|
|
|
@ -382,7 +382,7 @@ void COperationDialog::copyServerFiles()
|
||||||
|
|
||||||
CFilesCopier copier(this);
|
CFilesCopier copier(this);
|
||||||
copier.setSourceDirectory(config->getSrcServerDirectory());
|
copier.setSourceDirectory(config->getSrcServerDirectory());
|
||||||
copier.setDestinationDirectory(config->getInstallationDirectory() + "/" + server.id);
|
copier.setDestinationDirectory(server.getDirectory());
|
||||||
copier.setIncludeFilter(serverFiles);
|
copier.setIncludeFilter(serverFiles);
|
||||||
|
|
||||||
if (copier.exec())
|
if (copier.exec())
|
||||||
|
@ -418,7 +418,7 @@ void COperationDialog::copyProfileFiles()
|
||||||
|
|
||||||
CFilesCopier copier(this);
|
CFilesCopier copier(this);
|
||||||
copier.setSourceDirectory(config->getSrcProfileDirectory());
|
copier.setSourceDirectory(config->getSrcProfileDirectory());
|
||||||
copier.setDestinationDirectory(config->getProfileDirectory() + "/" + profile.id);
|
copier.setDestinationDirectory(profile.getDirectory());
|
||||||
copier.setIncludeFilter(profileFiles);
|
copier.setIncludeFilter(profileFiles);
|
||||||
|
|
||||||
if (copier.exec())
|
if (copier.exec())
|
||||||
|
@ -441,7 +441,7 @@ void COperationDialog::extractBnpClient()
|
||||||
m_currentOperation = QApplication::tr("Extract client to new location");
|
m_currentOperation = QApplication::tr("Extract client to new location");
|
||||||
m_currentOperationProgressFormat = QApplication::tr("Extracting %1...");
|
m_currentOperationProgressFormat = QApplication::tr("Extracting %1...");
|
||||||
|
|
||||||
QString destinationDirectory = config->getInstallationDirectory() + "/" + server.id;
|
QString destinationDirectory = server.getDirectory();
|
||||||
|
|
||||||
CFilesExtractor extractor(this);
|
CFilesExtractor extractor(this);
|
||||||
extractor.setSourceFile(config->getSrcServerClientBNPFullPath());
|
extractor.setSourceFile(config->getSrcServerClientBNPFullPath());
|
||||||
|
@ -589,7 +589,7 @@ void COperationDialog::cleanFiles()
|
||||||
m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
|
m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
|
||||||
|
|
||||||
CFilesCleaner cleaner(this);
|
CFilesCleaner cleaner(this);
|
||||||
cleaner.setDirectory(config->getInstallationDirectory() + "/" + server.id);
|
cleaner.setDirectory(server.getDirectory());
|
||||||
cleaner.exec();
|
cleaner.exec();
|
||||||
|
|
||||||
emit done();
|
emit done();
|
||||||
|
@ -720,7 +720,7 @@ void COperationDialog::deleteComponentsServers()
|
||||||
|
|
||||||
emit progress(i++, server.name);
|
emit progress(i++, server.name);
|
||||||
|
|
||||||
QString path = config->getInstallationDirectory() + "/" + server.id;
|
QString path = server.getDirectory();
|
||||||
|
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
|
|
||||||
|
@ -759,9 +759,7 @@ void COperationDialog::deleteComponentsProfiles()
|
||||||
|
|
||||||
emit progress(i++, profile.name);
|
emit progress(i++, profile.name);
|
||||||
|
|
||||||
QString path = config->getProfileDirectory() + "/" + profile.id;
|
QString path = profile.getDirectory();
|
||||||
|
|
||||||
QDir dir(path);
|
|
||||||
|
|
||||||
if (dir.exists() && !dir.removeRecursively())
|
if (dir.exists() && !dir.removeRecursively())
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,7 +105,7 @@ void CProfilesDialog::displayProfile(int index)
|
||||||
executable = CConfigFile::getInstance()->getServerClientFullPath(profile.server);
|
executable = CConfigFile::getInstance()->getServerClientFullPath(profile.server);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString profileDirectory = CConfigFile::getInstance()->getProfileDirectory() + "/" + profile.id;
|
QString profileDirectory = profile.getDirectory();
|
||||||
|
|
||||||
// update all widgets with content of profile
|
// update all widgets with content of profile
|
||||||
profileIdLabel->setText(profile.id);
|
profileIdLabel->setText(profile.id);
|
||||||
|
@ -283,7 +283,7 @@ void CProfilesDialog::onProfileDirectoryClicked()
|
||||||
|
|
||||||
const CProfile &profile = m_model->getProfiles()[m_currentProfileIndex];
|
const CProfile &profile = m_model->getProfiles()[m_currentProfileIndex];
|
||||||
|
|
||||||
QString profileDirectory = CConfigFile::getInstance()->getProfileDirectory() + "/" + profile.id;
|
QString profileDirectory = profile.getDirectory();
|
||||||
|
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(profileDirectory));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(profileDirectory));
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ CUninstallDialog::CUninstallDialog(QWidget *parent):QDialog(parent), m_installer
|
||||||
{
|
{
|
||||||
const CServer &server = config->getServer(row);
|
const CServer &server = config->getServer(row);
|
||||||
|
|
||||||
if (QFile::exists(config->getInstallationDirectory() + "/" + server.id))
|
if (QFile::exists(server.getDirectory()))
|
||||||
{
|
{
|
||||||
m_serversIndices[server.id] = model->rowCount();
|
m_serversIndices[server.id] = model->rowCount();
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ void CUninstallDialog::updateSizes()
|
||||||
{
|
{
|
||||||
const CServer &server = config->getServer(it.key());
|
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));
|
emit updateSize(it.value(), qBytesToHumanReadable(bytes));
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ void CUninstallDialog::updateSizes()
|
||||||
{
|
{
|
||||||
const CProfile &profile = config->getProfile(it.key());
|
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));
|
emit updateSize(it.value(), qBytesToHumanReadable(bytes));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue