diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-09-28 20:22:07 +0200 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-09-28 20:22:07 +0200 |
| commit | 34ce22bfd3ff80ed63a5d24869d9875a01bd478c (patch) | |
| tree | 2c0df211e6d410d7d50d0d84318eaff72b129708 /src/mainwindow.cpp | |
| parent | 154d83e479baecf8c0c670c6b8d5d72e3c2299d1 (diff) | |
Allow MO2 to find game saves into subdirectories.
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a20dfd06..03675a2b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1932,11 +1932,21 @@ void MainWindow::refreshSaveList() QDir savesDir = currentSavesDir(); savesDir.setNameFilters(filters); + savesDir.setFilter(QDir::Files); + QDirIterator it(savesDir, QDirIterator::Subdirectories); log::debug("reading save games from {}", savesDir.absolutePath()); - QFileInfoList files = savesDir.entryInfoList(QDir::Files, QDir::Time); + QFileInfoList files; + while (it.hasNext()) { + it.next(); + files.append(it.fileInfo()); + } + std::sort(files.begin(), files.end(), [](auto const& lhs, auto const& rhs) { + return lhs.fileTime(QFileDevice::FileModificationTime) < rhs.fileTime(QFileDevice::FileModificationTime); + }); + for (const QFileInfo &file : files) { - QListWidgetItem *item = new QListWidgetItem(file.fileName()); + QListWidgetItem *item = new QListWidgetItem(savesDir.relativeFilePath(file.absoluteFilePath())); item->setData(Qt::UserRole, file.absoluteFilePath()); ui->savegameList->addItem(item); } |
