diff options
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 578d4419..7dba6c72 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1230,11 +1230,8 @@ void MainWindow::refreshSavesIfOpen() }
}
-
-void MainWindow::refreshSaveList()
+QDir MainWindow::currentSavesDir() const
{
- ui->savegameList->clear();
-
QDir savesDir;
if (m_OrganizerCore.currentProfile()->localSavesEnabled()) {
savesDir.setPath(m_OrganizerCore.currentProfile()->absolutePath() + "/saves");
@@ -1246,13 +1243,35 @@ void MainWindow::refreshSaveList() savesDir.setPath(m_OrganizerCore.managedGame()->documentsDirectory().absoluteFilePath(QString::fromWCharArray(path)));
}
+ return savesDir;
+}
+
+void MainWindow::startMonitorSaves()
+{
+ stopMonitorSaves();
+
+ QDir savesDir = currentSavesDir();
+
+ m_SavesWatcher.addPath(savesDir.absolutePath());
+}
+
+void MainWindow::stopMonitorSaves()
+{
if (m_SavesWatcher.directories().length() > 0) {
m_SavesWatcher.removePaths(m_SavesWatcher.directories());
}
- m_SavesWatcher.addPath(savesDir.absolutePath());
+}
+
+void MainWindow::refreshSaveList()
+{
+ ui->savegameList->clear();
+
+ startMonitorSaves(); // re-starts monitoring
QStringList filters;
filters << QString("*.") + m_OrganizerCore.managedGame()->savegameExtension();
+
+ QDir savesDir = currentSavesDir();
savesDir.setNameFilters(filters);
QFileInfoList files = savesDir.entryInfoList(QDir::Files, QDir::Time);
@@ -1677,7 +1696,7 @@ bool MainWindow::modifyExecutablesDialog() try {
EditExecutablesDialog dialog(*m_OrganizerCore.executablesList());
if (dialog.exec() == QDialog::Accepted) {
- m_OrganizerCore.setExecutablesDialog(dialog.getExecutablesList());
+ m_OrganizerCore.setExecutablesList(dialog.getExecutablesList());
result = true;
}
refreshExecutablesList();
@@ -1746,7 +1765,11 @@ void MainWindow::on_actionAdd_Profile_triggered() bool repeat = true;
while (repeat) {
ProfilesDialog profilesDialog(m_GamePath, this);
+ // workaround: need to disable monitoring of the saves directory, otherwise the active
+ // profile directory is locked
+ stopMonitorSaves();
profilesDialog.exec();
+ refreshSaveList(); // since the save list may now be outdated we have to refresh it completely
if (refreshProfiles() && !profilesDialog.failed()) {
repeat = false;
}
@@ -2015,7 +2038,6 @@ void MainWindow::addCategoryFilters(QTreeWidgetItem *root, const std::set<int> & }
}
-
void MainWindow::refreshFilters()
{
QItemSelection currentSelection = ui->modList->selectionModel()->selection();
@@ -2039,11 +2061,10 @@ void MainWindow::refreshFilters() addFilterItem(nullptr, tr("<Not Endorsed>"), CategoryFactory::CATEGORY_SPECIAL_NOTENDORSED, ModListSortProxy::TYPE_SPECIAL);
addContentFilters();
-
std::set<int> categoriesUsed;
for (unsigned int modIdx = 0; modIdx < ModInfo::getNumMods(); ++modIdx) {
ModInfo::Ptr modInfo = ModInfo::getByIndex(modIdx);
- BOOST_FOREACH (int categoryID, modInfo->getCategories()) {
+ for (int categoryID : modInfo->getCategories()) {
int currentID = categoryID;
// also add parents so they show up in the tree
while (currentID != 0) {
@@ -2062,7 +2083,11 @@ void MainWindow::refreshFilters() }
}
ui->modList->selectionModel()->select(currentSelection, QItemSelectionModel::Select);
- QModelIndexList matchList = ui->modList->model()->match(ui->modList->model()->index(0, 0), Qt::DisplayRole, currentIndexName);
+ QModelIndexList matchList;
+ if (currentIndexName.isValid()) {
+ matchList = ui->modList->model()->match(ui->modList->model()->index(0, 0), Qt::DisplayRole, currentIndexName);
+ }
+
if (matchList.size() > 0) {
ui->modList->setCurrentIndex(matchList.at(0));
}
@@ -4408,9 +4433,14 @@ void MainWindow::on_bossButton_clicked() // if the game specifies load order by file time, our own load order file needs to be removed because it's outdated.
// refreshESPList will then use the file time as the load order.
if (GameInfo::instance().getLoadOrderMechanism() == GameInfo::TYPE_FILETIME) {
+ qDebug("removing loadorder.txt");
QFile::remove(m_OrganizerCore.currentProfile()->getLoadOrderFileName());
}
m_OrganizerCore.refreshESPList();
+ if (GameInfo::instance().getLoadOrderMechanism() == GameInfo::TYPE_FILETIME) {
+ // the load order should have been retrieved from file time, now save it to our own format
+ m_OrganizerCore.savePluginList();
+ }
}
}
|
