mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Reorganised DataFilesPage.cpp code.
Removed some recursive calling of saveSettings() and loadSettings().
This commit is contained in:
parent
70e4f821ba
commit
e298589e7f
2 changed files with 22 additions and 27 deletions
|
@ -69,19 +69,6 @@ void Launcher::DataFilesPage::buildView()
|
|||
|
||||
bool Launcher::DataFilesPage::loadSettings()
|
||||
{
|
||||
QStringList paths = mGameSettings.getDataDirs();
|
||||
|
||||
foreach (const QString &path, paths)
|
||||
mSelector->addFiles(path);
|
||||
|
||||
mDataLocal = mGameSettings.getDataLocal();
|
||||
|
||||
if (!mDataLocal.isEmpty())
|
||||
mSelector->addFiles(mDataLocal);
|
||||
|
||||
paths.insert (0, mDataLocal);
|
||||
PathIterator pathIterator (paths);
|
||||
|
||||
QStringList profiles = mLauncherSettings.getContentLists();
|
||||
QString currentProfile = mLauncherSettings.getCurrentContentListName();
|
||||
|
||||
|
@ -94,11 +81,27 @@ bool Launcher::DataFilesPage::loadSettings()
|
|||
if (!currentProfile.isEmpty())
|
||||
addProfile(currentProfile, true);
|
||||
|
||||
mSelector->setProfileContent(filesInProfile(currentProfile, pathIterator));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
|
||||
{
|
||||
QStringList paths = mGameSettings.getDataDirs();
|
||||
|
||||
foreach(const QString &path, paths)
|
||||
mSelector->addFiles(path);
|
||||
|
||||
mDataLocal = mGameSettings.getDataLocal();
|
||||
|
||||
if (!mDataLocal.isEmpty())
|
||||
mSelector->addFiles(mDataLocal);
|
||||
|
||||
paths.insert(0, mDataLocal);
|
||||
PathIterator pathIterator(paths);
|
||||
|
||||
mSelector->setProfileContent(filesInProfile(contentModelName, pathIterator));
|
||||
}
|
||||
|
||||
QStringList Launcher::DataFilesPage::filesInProfile(const QString& profileName, PathIterator& pathIterator)
|
||||
{
|
||||
QStringList files = mLauncherSettings.getContentListFiles(profileName);
|
||||
|
@ -175,7 +178,7 @@ void Launcher::DataFilesPage::setProfile (const QString &previous, const QString
|
|||
|
||||
ui.profilesComboBox->setCurrentProfile (ui.profilesComboBox->findText (current));
|
||||
|
||||
loadSettings();
|
||||
populateFileViews(current);
|
||||
|
||||
checkForDefaultProfile();
|
||||
}
|
||||
|
@ -229,13 +232,6 @@ void Launcher::DataFilesPage::on_newProfileAction_triggered()
|
|||
mLauncherSettings.setCurrentContentListName(profile);
|
||||
|
||||
addProfile(profile, true);
|
||||
mSelector->clearCheckStates();
|
||||
|
||||
mSelector->setGameFile();
|
||||
|
||||
saveSettings();
|
||||
|
||||
emit signalProfileChanged (ui.profilesComboBox->findText(profile));
|
||||
}
|
||||
|
||||
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
|
||||
int next = ui.profilesComboBox->currentIndex()-1;
|
||||
|
||||
// changing the profile forces a reload of plugin file views.
|
||||
ui.profilesComboBox->setCurrentIndex(next);
|
||||
|
||||
removeProfile(profile);
|
||||
ui.profilesComboBox->removeItem(ui.profilesComboBox->findText(profile));
|
||||
|
||||
saveSettings();
|
||||
|
||||
loadSettings();
|
||||
|
||||
checkForDefaultProfile();
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ namespace Launcher
|
|||
bool showDeleteMessageBox (const QString &text);
|
||||
void addProfile (const QString &profile, bool setAsCurrent);
|
||||
void checkForDefaultProfile();
|
||||
void populateFileViews(const QString& contentModelName);
|
||||
|
||||
class PathIterator
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue