mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-26 19:00:53 +00:00
Changed: New methods loadFromSettings and saveToSettings for CProfile and CServer, see #279
--HG-- branch : develop
This commit is contained in:
parent
1ce480a809
commit
162e683803
5 changed files with 97 additions and 76 deletions
|
@ -109,34 +109,7 @@ bool CConfigFile::load(const QString &filename)
|
|||
CServer &server = m_servers[i];
|
||||
|
||||
settings.beginGroup(QString("server_%1").arg(i));
|
||||
|
||||
server.id = settings.value("id").toString();
|
||||
server.name = settings.value("name").toString();
|
||||
server.displayUrl = settings.value("display_url").toString();
|
||||
server.dataDownloadUrl = settings.value("data_download_url").toString();
|
||||
server.dataDownloadFilename = settings.value("data_download_filename").toString();
|
||||
server.dataCompressedSize = settings.value("data_compressed_size").toULongLong();
|
||||
server.dataUncompressedSize = settings.value("data_uncompressed_size").toULongLong();
|
||||
server.clientDownloadUrl = settings.value("client_download_url").toString();
|
||||
server.clientDownloadFilename = settings.value("client_download_filename").toString();
|
||||
#if defined(Q_OS_WIN)
|
||||
server.clientFilename = settings.value("client_filename_windows").toString();
|
||||
server.clientFilenameOld = settings.value("client_filename_old_windows").toString();
|
||||
server.configurationFilename = settings.value("configuration_filename_windows").toString();
|
||||
server.installerFilename = settings.value("installer_filename_windows").toString();
|
||||
#elif defined(Q_OS_MAC)
|
||||
server.clientFilename = settings.value("client_filename_osx").toString();
|
||||
server.clientFilenameOld = settings.value("client_filename_old_osx").toString();
|
||||
server.configurationFilename = settings.value("configuration_filename_osx").toString();
|
||||
server.installerFilename = settings.value("installer_filename_osx").toString();
|
||||
#else
|
||||
server.clientFilename = settings.value("client_filename_linux").toString();
|
||||
server.clientFilenameOld = settings.value("client_filename_old_linux").toString();
|
||||
server.configurationFilename = settings.value("configuration_filename_linux").toString();
|
||||
server.installerFilename = settings.value("installer_filename_linux").toString();
|
||||
#endif
|
||||
server.comments = settings.value("comments").toString();
|
||||
|
||||
server.loadFromSettings(settings);
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
@ -154,16 +127,7 @@ bool CConfigFile::load(const QString &filename)
|
|||
CProfile &profile = m_profiles[i];
|
||||
|
||||
settings.beginGroup(QString("profile_%1").arg(i));
|
||||
|
||||
profile.id = settings.value("id").toString();
|
||||
profile.name = settings.value("name").toString();
|
||||
profile.server = settings.value("server").toString();
|
||||
profile.executable = settings.value("executable").toString();
|
||||
profile.arguments = settings.value("arguments").toString();
|
||||
profile.comments = settings.value("comments").toString();
|
||||
profile.desktopShortcut = settings.value("desktop_shortcut").toBool();
|
||||
profile.menuShortcut = settings.value("menu_shortcut").toBool();
|
||||
|
||||
profile.loadFromSettings(settings);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
|
@ -203,34 +167,7 @@ bool CConfigFile::save() const
|
|||
const CServer &server = m_servers[i];
|
||||
|
||||
settings.beginGroup(QString("server_%1").arg(i));
|
||||
|
||||
settings.setValue("id", server.id);
|
||||
settings.setValue("name", server.name);
|
||||
settings.setValue("display_url", server.displayUrl);
|
||||
settings.setValue("data_download_url", server.dataDownloadUrl);
|
||||
settings.setValue("data_download_filename", server.dataDownloadFilename);
|
||||
settings.setValue("data_compressed_size", server.dataCompressedSize);
|
||||
settings.setValue("data_uncompressed_size", server.dataUncompressedSize);
|
||||
settings.setValue("client_download_url", server.clientDownloadUrl);
|
||||
settings.setValue("client_download_filename", server.clientDownloadFilename);
|
||||
#if defined(Q_OS_WIN)
|
||||
settings.setValue("client_filename_windows", server.clientFilename);
|
||||
settings.setValue("client_filename_old_windows", server.clientFilenameOld);
|
||||
settings.setValue("configuration_filename_windows", server.configurationFilename);
|
||||
settings.setValue("installer_filename_windows", server.installerFilename);
|
||||
#elif defined(Q_OS_MAC)
|
||||
settings.setValue("client_filename_osx", server.clientFilename);
|
||||
settings.setValue("client_filename_old_osx", server.clientFilenameOld);
|
||||
settings.setValue("configuration_filename_osx", server.configurationFilename);
|
||||
settings.setValue("installer_filename_osx", server.installerFilename);
|
||||
#else
|
||||
settings.setValue("client_filename_linux", server.clientFilename);
|
||||
settings.setValue("client_filename_old_linux", server.clientFilenameOld);
|
||||
settings.setValue("configuration_filename_linux", server.configurationFilename);
|
||||
settings.setValue("installer_filename_linux", server.installerFilename);
|
||||
#endif
|
||||
settings.setValue("comments", server.comments);
|
||||
|
||||
server.saveToSettings(settings);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
|
@ -244,16 +181,7 @@ bool CConfigFile::save() const
|
|||
const CProfile &profile = m_profiles[i];
|
||||
|
||||
settings.beginGroup(QString("profile_%1").arg(i));
|
||||
|
||||
settings.setValue("id", profile.id);
|
||||
settings.setValue("name", profile.name);
|
||||
settings.setValue("server", profile.server);
|
||||
settings.setValue("executable", profile.executable);
|
||||
settings.setValue("arguments", profile.arguments);
|
||||
settings.setValue("comments", profile.comments);
|
||||
settings.setValue("desktop_shortcut", profile.desktopShortcut);
|
||||
settings.setValue("menu_shortcut", profile.menuShortcut);
|
||||
|
||||
profile.saveToSettings(settings);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,30 @@
|
|||
|
||||
const CProfile NoProfile;
|
||||
|
||||
void CProfile::loadFromSettings(const QSettings &settings)
|
||||
{
|
||||
id = settings.value("id").toString();
|
||||
name = settings.value("name").toString();
|
||||
server = settings.value("server").toString();
|
||||
executable = settings.value("executable").toString();
|
||||
arguments = settings.value("arguments").toString();
|
||||
comments = settings.value("comments").toString();
|
||||
desktopShortcut = settings.value("desktop_shortcut").toBool();
|
||||
menuShortcut = settings.value("menu_shortcut").toBool();
|
||||
}
|
||||
|
||||
void CProfile::saveToSettings(QSettings &settings) const
|
||||
{
|
||||
settings.setValue("id", id);
|
||||
settings.setValue("name", name);
|
||||
settings.setValue("server", server);
|
||||
settings.setValue("executable", executable);
|
||||
settings.setValue("arguments", arguments);
|
||||
settings.setValue("comments", comments);
|
||||
settings.setValue("desktop_shortcut", desktopShortcut);
|
||||
settings.setValue("menu_shortcut", menuShortcut);
|
||||
}
|
||||
|
||||
QString CProfile::getDirectory() const
|
||||
{
|
||||
return CConfigFile::getInstance()->getProfileDirectory() + "/" + id;
|
||||
|
|
|
@ -37,6 +37,9 @@ public:
|
|||
bool desktopShortcut;
|
||||
bool menuShortcut;
|
||||
|
||||
void loadFromSettings(const QSettings &settings);
|
||||
void saveToSettings(QSettings &settings) const;
|
||||
|
||||
// helpers
|
||||
QString getDirectory() const;
|
||||
QString getClientFullPath() const;
|
||||
|
|
|
@ -24,6 +24,68 @@
|
|||
|
||||
const CServer NoServer;
|
||||
|
||||
void CServer::loadFromSettings(const QSettings &settings)
|
||||
{
|
||||
id = settings.value("id").toString();
|
||||
name = settings.value("name").toString();
|
||||
displayUrl = settings.value("display_url").toString();
|
||||
filesListUrl = settings.value("files_list_url").toString();
|
||||
dataDownloadUrl = settings.value("data_download_url").toString();
|
||||
dataDownloadFilename = settings.value("data_download_filename").toString();
|
||||
dataCompressedSize = settings.value("data_compressed_size").toULongLong();
|
||||
dataUncompressedSize = settings.value("data_uncompressed_size").toULongLong();
|
||||
clientDownloadUrl = settings.value("client_download_url").toString();
|
||||
clientDownloadFilename = settings.value("client_download_filename").toString();
|
||||
#if defined(Q_OS_WIN)
|
||||
clientFilename = settings.value("client_filename_windows").toString();
|
||||
clientFilenameOld = settings.value("client_filename_old_windows").toString();
|
||||
configurationFilename = settings.value("configuration_filename_windows").toString();
|
||||
installerFilename = settings.value("installer_filename_windows").toString();
|
||||
#elif defined(Q_OS_MAC)
|
||||
clientFilename = settings.value("client_filename_osx").toString();
|
||||
clientFilenameOld = settings.value("client_filename_old_osx").toString();
|
||||
configurationFilename = settings.value("configuration_filename_osx").toString();
|
||||
installerFilename = settings.value("installer_filename_osx").toString();
|
||||
#else
|
||||
clientFilename = settings.value("client_filename_linux").toString();
|
||||
clientFilenameOld = settings.value("client_filename_old_linux").toString();
|
||||
configurationFilename = settings.value("configuration_filename_linux").toString();
|
||||
installerFilename = settings.value("installer_filename_linux").toString();
|
||||
#endif
|
||||
comments = settings.value("comments").toString();
|
||||
}
|
||||
|
||||
void CServer::saveToSettings(QSettings &settings) const
|
||||
{
|
||||
settings.setValue("id", id);
|
||||
settings.setValue("name", name);
|
||||
settings.setValue("display_url", displayUrl);
|
||||
settings.setValue("files_list_url", filesListUrl);
|
||||
settings.setValue("data_download_url", dataDownloadUrl);
|
||||
settings.setValue("data_download_filename", dataDownloadFilename);
|
||||
settings.setValue("data_compressed_size", dataCompressedSize);
|
||||
settings.setValue("data_uncompressed_size", dataUncompressedSize);
|
||||
settings.setValue("client_download_url", clientDownloadUrl);
|
||||
settings.setValue("client_download_filename", clientDownloadFilename);
|
||||
#if defined(Q_OS_WIN)
|
||||
settings.setValue("client_filename_windows", clientFilename);
|
||||
settings.setValue("client_filename_old_windows", clientFilenameOld);
|
||||
settings.setValue("configuration_filename_windows", configurationFilename);
|
||||
settings.setValue("installer_filename_windows", installerFilename);
|
||||
#elif defined(Q_OS_MAC)
|
||||
settings.setValue("client_filename_osx", clientFilename);
|
||||
settings.setValue("client_filename_old_osx", clientFilenameOld);
|
||||
settings.setValue("configuration_filename_osx", configurationFilename);
|
||||
settings.setValue("installer_filename_osx", installerFilename);
|
||||
#else
|
||||
settings.setValue("client_filename_linux", clientFilename);
|
||||
settings.setValue("client_filename_old_linux", clientFilenameOld);
|
||||
settings.setValue("configuration_filename_linux", configurationFilename);
|
||||
settings.setValue("installer_filename_linux", installerFilename);
|
||||
#endif
|
||||
settings.setValue("comments", comments);
|
||||
}
|
||||
|
||||
QString CServer::getDirectory() const
|
||||
{
|
||||
return CConfigFile::getInstance()->getInstallationDirectory() + "/" + id;
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
QString id;
|
||||
QString name;
|
||||
QString displayUrl;
|
||||
QString filesListUrl;
|
||||
QString dataDownloadUrl;
|
||||
QString dataDownloadFilename;
|
||||
qint64 dataCompressedSize;
|
||||
|
@ -43,6 +44,9 @@ public:
|
|||
QString installerFilename;
|
||||
QString comments;
|
||||
|
||||
void loadFromSettings(const QSettings &settings);
|
||||
void saveToSettings(QSettings &settings) const;
|
||||
|
||||
// helpers
|
||||
QString getDirectory() const;
|
||||
QString getClientFullPath() const;
|
||||
|
|
Loading…
Reference in a new issue