Merge remote-tracking branch 'dteviot/master'

This commit is contained in:
Marc Zinnschlag 2015-01-28 19:22:54 +01:00
commit 05be353fec
2 changed files with 22 additions and 27 deletions

View file

@ -68,6 +68,23 @@ void Launcher::DataFilesPage::buildView()
} }
bool Launcher::DataFilesPage::loadSettings() bool Launcher::DataFilesPage::loadSettings()
{
QStringList profiles = mLauncherSettings.getContentLists();
QString currentProfile = mLauncherSettings.getCurrentContentListName();
qDebug() << "current profile is: " << currentProfile;
foreach (const QString &item, profiles)
addProfile (item, false);
// Hack: also add the current profile
if (!currentProfile.isEmpty())
addProfile(currentProfile, true);
return true;
}
void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
{ {
QStringList paths = mGameSettings.getDataDirs(); QStringList paths = mGameSettings.getDataDirs();
@ -82,21 +99,7 @@ bool Launcher::DataFilesPage::loadSettings()
paths.insert(0, mDataLocal); paths.insert(0, mDataLocal);
PathIterator pathIterator(paths); PathIterator pathIterator(paths);
QStringList profiles = mLauncherSettings.getContentLists(); mSelector->setProfileContent(filesInProfile(contentModelName, pathIterator));
QString currentProfile = mLauncherSettings.getCurrentContentListName();
qDebug() << "current profile is: " << currentProfile;
foreach (const QString &item, profiles)
addProfile (item, false);
// Hack: also add the current profile
if (!currentProfile.isEmpty())
addProfile(currentProfile, true);
mSelector->setProfileContent(filesInProfile(currentProfile, pathIterator));
return true;
} }
QStringList Launcher::DataFilesPage::filesInProfile(const QString& profileName, PathIterator& pathIterator) QStringList Launcher::DataFilesPage::filesInProfile(const QString& profileName, PathIterator& pathIterator)
@ -175,7 +178,7 @@ void Launcher::DataFilesPage::setProfile (const QString &previous, const QString
ui.profilesComboBox->setCurrentProfile (ui.profilesComboBox->findText (current)); ui.profilesComboBox->setCurrentProfile (ui.profilesComboBox->findText (current));
loadSettings(); populateFileViews(current);
checkForDefaultProfile(); checkForDefaultProfile();
} }
@ -229,13 +232,6 @@ void Launcher::DataFilesPage::on_newProfileAction_triggered()
mLauncherSettings.setCurrentContentListName(profile); mLauncherSettings.setCurrentContentListName(profile);
addProfile(profile, true); addProfile(profile, true);
mSelector->clearCheckStates();
mSelector->setGameFile();
saveSettings();
emit signalProfileChanged (ui.profilesComboBox->findText(profile));
} }
void Launcher::DataFilesPage::addProfile (const QString &profile, bool setAsCurrent) void Launcher::DataFilesPage::addProfile (const QString &profile, bool setAsCurrent)
@ -262,15 +258,13 @@ void Launcher::DataFilesPage::on_deleteProfileAction_triggered()
// this should work since the Default profile can't be deleted and is always index 0 // this should work since the Default profile can't be deleted and is always index 0
int next = ui.profilesComboBox->currentIndex()-1; int next = ui.profilesComboBox->currentIndex()-1;
// changing the profile forces a reload of plugin file views.
ui.profilesComboBox->setCurrentIndex(next); ui.profilesComboBox->setCurrentIndex(next);
removeProfile(profile); removeProfile(profile);
ui.profilesComboBox->removeItem(ui.profilesComboBox->findText(profile)); ui.profilesComboBox->removeItem(ui.profilesComboBox->findText(profile));
saveSettings();
loadSettings();
checkForDefaultProfile(); checkForDefaultProfile();
} }

View file

@ -82,6 +82,7 @@ namespace Launcher
bool showDeleteMessageBox (const QString &text); bool showDeleteMessageBox (const QString &text);
void addProfile (const QString &profile, bool setAsCurrent); void addProfile (const QString &profile, bool setAsCurrent);
void checkForDefaultProfile(); void checkForDefaultProfile();
void populateFileViews(const QString& contentModelName);
class PathIterator class PathIterator
{ {