From bcf4f962098a5e48eb3662b045d8692b50cf0eda Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Mon, 18 Feb 2013 23:10:50 +0100 Subject: [PATCH] Added writing masters/plugins to openmw.cfg --- apps/launcher/datafilespage.cpp | 21 +++++---------------- apps/launcher/settings/gamesettings.hpp | 12 ++++++++++++ apps/launcher/settings/settingsbase.hpp | 7 +------ 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index ed24f881b..e0ebefa58 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -57,7 +57,6 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam { // Models mDataFilesModel = new DataFilesModel(this); - mDataFilesModel->setObjectName(QString("mDataFilesModel")); mMastersProxyModel = new QSortFilterProxyModel(); mMastersProxyModel->setFilterRegExp(QString("^.*\\.esm")); @@ -65,14 +64,11 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam mMastersProxyModel->setSourceModel(mDataFilesModel); mPluginsProxyModel = new QSortFilterProxyModel(); - mPluginsProxyModel->setObjectName(QString("mPluginsProxyModel")); mPluginsProxyModel->setFilterRegExp(QString("^.*\\.esp")); mPluginsProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); mPluginsProxyModel->setSourceModel(mDataFilesModel); mFilterProxyModel = new QSortFilterProxyModel(); - mFilterProxyModel->setObjectName(QString("mFilterProxyModel")); - mFilterProxyModel->setDynamicSortFilter(true); mFilterProxyModel->setSourceModel(mPluginsProxyModel); @@ -155,7 +151,6 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam QList sizeList; sizeList << mLauncherSettings.value(QString("General/MastersTable/width"), QString("200")).toInt(); sizeList << mLauncherSettings.value(QString("General/PluginTable/width"), QString("340")).toInt(); - qDebug() << sizeList; mSplitter->setSizes(sizeList); @@ -279,20 +274,15 @@ void DataFilesPage::setupDataFiles() void DataFilesPage::loadSettings() { - qDebug() << "load settings"; QString profile = mLauncherSettings.value(QString("Profiles/CurrentProfile")); - qDebug() << mLauncherSettings.values(QString("Profiles/Default"), Qt::MatchStartsWith); - if (profile.isEmpty()) return; - mDataFilesModel->uncheckAll(); QStringList masters = mLauncherSettings.values(QString("Profiles/") + profile + QString("/master"), Qt::MatchExactly); QStringList plugins = mLauncherSettings.values(QString("Profiles/") + profile + QString("/plugin"), Qt::MatchExactly); - qDebug() << "masters to check " << plugins; foreach (const QString &master, masters) { QModelIndex index = mDataFilesModel->indexFromItem(mDataFilesModel->findItem(master)); @@ -316,21 +306,23 @@ void DataFilesPage::saveSettings() mLauncherSettings.setValue(QString("Profiles/CurrentProfile"), profile); } - qDebug() << "save settings" << profile; mLauncherSettings.remove(QString("Profiles/") + profile + QString("/master")); mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin")); + mGameSettings.remove(QString("master")); + mGameSettings.remove(QString("plugin")); + QStringList items = mDataFilesModel->checkedItems(); foreach(const QString &item, items) { if (item.endsWith(QString(".esm"), Qt::CaseInsensitive)) { - qDebug() << "setting " << item; mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/master"), item); + mGameSettings.setMultiValue(QString("master"), item); } else if (item.endsWith(QString(".esp"), Qt::CaseInsensitive)) { - qDebug() << "setting " << item; mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/plugin"), item); + mGameSettings.setMultiValue(QString("plugin"), item); } } @@ -500,7 +492,6 @@ void DataFilesPage::filterChanged(const QString filter) void DataFilesPage::profileChanged(const QString &previous, const QString ¤t) { - qDebug() << "Profile is changed from: " << previous << " to " << current; // Prevent the deletion of the default profile if (current == QLatin1String("Default")) { mDeleteProfileAction->setEnabled(false); @@ -527,7 +518,6 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre void DataFilesPage::profileRenamed(const QString &previous, const QString ¤t) { - qDebug() << "rename"; if (previous.isEmpty()) return; @@ -577,7 +567,6 @@ void DataFilesPage::showContextMenu(const QPoint &point) : mCheckAction->setEnabled(true); } - // Show menu mContextMenu->exec(globalPos); diff --git a/apps/launcher/settings/gamesettings.hpp b/apps/launcher/settings/gamesettings.hpp index 717ce6e87..8aac1552d 100644 --- a/apps/launcher/settings/gamesettings.hpp +++ b/apps/launcher/settings/gamesettings.hpp @@ -29,6 +29,18 @@ public: mSettings.insert(key, value); } + inline void setMultiValue(const QString &key, const QString &value) + { + QStringList values = mSettings.values(key); + if (!values.contains(value)) + mSettings.insertMulti(key, value); + } + + inline void remove(const QString &key) + { + mSettings.remove(key); + } + inline QStringList getDataDirs() { return mDataDirs; } inline void addDataDir(const QString &dir) { if(!dir.isEmpty()) mDataDirs.append(dir); } inline QString getDataLocal() {return mDataLocal; } diff --git a/apps/launcher/settings/settingsbase.hpp b/apps/launcher/settings/settingsbase.hpp index 361884da6..e70bc0d72 100644 --- a/apps/launcher/settings/settingsbase.hpp +++ b/apps/launcher/settings/settingsbase.hpp @@ -32,15 +32,10 @@ public: inline void setMultiValue(const QString &key, const QString &value) { QStringList values = mSettings.values(key); - if (!values.contains(value)) { - qDebug() << "inserting " << value; + if (!values.contains(value)) mSettings.insertMulti(key, value); - } else { - qDebug() << "not inserting " << value; - } } - inline void remove(const QString &key) { mSettings.remove(key);