diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 5452b7398..734277b97 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -42,44 +42,19 @@ void Launcher::DataFilesPage::loadSettings() QString profileName = ui.profilesComboBox->currentText(); - QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/game"), Qt::MatchExactly); - QStringList addons = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/addon"), Qt::MatchExactly); + QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName, Qt::MatchExactly); - mSelector->clearCheckStates(); - - QString gameFile (""); + QStringList filepaths; - if (files.size()>0) + foreach (const QString &file, files) { - gameFile = pathIterator.findFirstPath (files.at(0)); + QString filepath = pathIterator.findFirstPath (file); - if (!gameFile.isEmpty()) - mSelector->setGameFile (gameFile); -/* else - { - //throw gamefile error here. - }*/ + if (!filepath.isEmpty()) + filepaths << filepath; } - QStringList missingFiles; - QStringList foundFiles; - - foreach (const QString &addon, addons) - { - QString filePath = pathIterator.findFirstPath (addon); - - if (filePath.isEmpty()) - missingFiles << addon; - else - foundFiles << filePath; - } -/* - if (missingFiles.size() > 0) - { - //throw addons error here. - } -*/ - mSelector->setCheckStates (foundFiles); + mSelector->setProfileContent (filepaths); } void Launcher::DataFilesPage::saveSettings(const QString &profile) @@ -94,8 +69,7 @@ void Launcher::DataFilesPage::saveSettings(const QString &profile) removeProfile (profileName); - mGameSettings.remove(QString("game")); - mGameSettings.remove(QString("addon")); + mGameSettings.remove(QString("content")); //set the value of the current profile (not necessarily the profile being saved!) mLauncherSettings.setValue(QString("Profiles/currentprofile"), ui.profilesComboBox->currentText()); @@ -103,10 +77,10 @@ void Launcher::DataFilesPage::saveSettings(const QString &profile) foreach(const ContentSelectorModel::EsmFile *item, items) { if (item->gameFiles().size() == 0) { - mLauncherSettings.setMultiValue(QString("Profiles/") + profileName + QString("/game"), item->fileName()); + mLauncherSettings.setMultiValue(QString("Profiles/") + profileName, item->fileName()); mGameSettings.setMultiValue(QString("content"), item->fileName()); } else { - mLauncherSettings.setMultiValue(QString("Profiles/") + profileName + QString("/addon"), item->fileName()); + mLauncherSettings.setMultiValue(QString("Profiles/") + profileName, item->fileName()); mGameSettings.setMultiValue(QString("content"), item->fileName()); } } @@ -225,13 +199,26 @@ void Launcher::DataFilesPage::setupDataFiles() if (!mDataLocal.isEmpty()) mSelector->addFiles(mDataLocal); - QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/")); - QString profile = mLauncherSettings.value(QString("Profiles/currentprofile")); + QStringList profiles; + QString currentProfile = mLauncherSettings.getSettings().value("Profiles/currentprofile"); + + foreach (QString key, mLauncherSettings.getSettings().keys()) + { + if (key.contains("Profiles/")) + { + QString profile = key.mid (9); + if (profile != "currentprofile") + { + if (!profiles.contains(profile)) + profiles << profile; + } + } + } foreach (const QString &item, profiles) addProfile (item, false); - setProfile (ui.profilesComboBox->findText(profile), false); + setProfile (ui.profilesComboBox->findText(currentProfile), false); loadSettings(); } diff --git a/apps/launcher/settings/gamesettings.cpp b/apps/launcher/settings/gamesettings.cpp index 83c099529..41113c35a 100644 --- a/apps/launcher/settings/gamesettings.cpp +++ b/apps/launcher/settings/gamesettings.cpp @@ -9,6 +9,7 @@ #include #include + /** * Workaround for problems with whitespaces in paths in older versions of Boost library */ diff --git a/apps/launcher/settings/launchersettings.cpp b/apps/launcher/settings/launchersettings.cpp index 7c97144ea..705453555 100644 --- a/apps/launcher/settings/launchersettings.cpp +++ b/apps/launcher/settings/launchersettings.cpp @@ -5,6 +5,8 @@ #include #include +#include + Launcher::LauncherSettings::LauncherSettings() { } @@ -44,12 +46,9 @@ QStringList Launcher::LauncherSettings::subKeys(const QString &key) QStringList result; foreach (const QString ¤tKey, keys) { - if (keyRe.indexIn(currentKey) != -1) { - QString prefixedKey = keyRe.cap(1); if(prefixedKey.startsWith(key)) { - QString subKey = prefixedKey.remove(key); if (!subKey.isEmpty()) result.append(subKey); diff --git a/components/contentselector/view/contentselector.cpp b/components/contentselector/view/contentselector.cpp index b962fa9ce..e9599de49 100644 --- a/components/contentselector/view/contentselector.cpp +++ b/components/contentselector/view/contentselector.cpp @@ -12,8 +12,6 @@ #include #include -#include - ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) : QObject(parent) { @@ -63,6 +61,35 @@ void ContentSelectorView::ContentSelector::buildAddonView() connect(ui.addonView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotAddonTableItemClicked(const QModelIndex &))); } +void ContentSelectorView::ContentSelector::setProfileContent(const QStringList &fileList) +{ + clearCheckStates(); + bool foundGamefile = false; + + foreach (const QString &filepath, fileList) + { + if (!foundGamefile) + { + const ContentSelectorModel::EsmFile *file = mContentModel->item(filepath); + + foundGamefile = (file->isGameFile()); + + if (foundGamefile) + { + setGameFile (filepath); + break; + } + } + } + +/* if (!foundGameFile) + { + //throw gamefile error here. + }*/ + + setCheckStates (fileList); +} + void ContentSelectorView::ContentSelector::setGameFile(const QString &filename) { int index = -1; @@ -92,7 +119,6 @@ void ContentSelectorView::ContentSelector::setCheckStates(const QStringList &lis { if (list.isEmpty()) { - qDebug() << "refreshing model"; slotCurrentGameFileIndexChanged (ui.gameFileView->currentIndex()); } else diff --git a/components/contentselector/view/contentselector.hpp b/components/contentselector/view/contentselector.hpp index da1c39973..a25eb20ae 100644 --- a/components/contentselector/view/contentselector.hpp +++ b/components/contentselector/view/contentselector.hpp @@ -29,6 +29,7 @@ namespace ContentSelectorView QString currentFile() const; void addFiles(const QString &path); + void setProfileContent (const QStringList &fileList); void clearCheckStates(); void setCheckStates (const QStringList &list);