diff options
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 19b97fd45..02ac2337b 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -757,9 +757,8 @@ void MainWindow::addRecentFile(const QStringList &newFiles) QStringList files; QSettings s; - if (newFiles.isEmpty()) { + if (newFiles.isEmpty()) return; - } s.beginGroup("Recent_Files"); @@ -792,11 +791,11 @@ void MainWindow::addRecentFile(const QStringList &newFiles) files.removeLast(); } - for (int c = 0; c < 4; c++) { - QString key = QString("File_%1").arg(c + 1); + for (int c = 1; c <= 4; c++) { + QString key = QString("File_%1").arg(c); - if (files.count() > c) { - s.setValue(key, files.at(c)); + if (files.count() >= c) { + s.setValue(key, files.at(c - 1)); } else { if (s.contains(key)) { s.remove(key); @@ -809,6 +808,47 @@ void MainWindow::addRecentFile(const QStringList &newFiles) loadRecentFiles(&s); } +void MainWindow::removeRecentFile(QStringList failedFiles) +{ + QStringList files; + QSettings s; + + if (failedFiles.isEmpty()) + return; + + s.beginGroup("Recent_Files"); + + for (int c = 1; c <= 4; c++) { + QString key = QString("File_%1").arg(c); + + if (s.contains(key)) { + QString file = s.value(key).toString(); + files.append(file); + } else { + break; + } + } + + foreach (QString file, failedFiles) + files.removeAll(file); + + for (int c = 1; c <= 4; c++) { + QString key = QString("File_%1").arg(c); + + if (files.count() >= c) { + s.setValue(key, files.at(c - 1)); + } else { + if (s.contains(key)) + s.remove(key); + } + } + + s.endGroup(); + s.sync(); + + loadRecentFiles(&s); +} + void MainWindow::recentFileTriggered(bool checked) { Q_UNUSED(checked); @@ -925,6 +965,7 @@ void MainWindow::loadFiles(const QStringList fileNames) char *error = NULL; QByteArray fileNamePtr; + QStringList failedParses; for (int i = 0; i < fileNames.size(); ++i) { fileNamePtr = QFile::encodeName(fileNames.at(i)); @@ -933,6 +974,7 @@ void MainWindow::loadFiles(const QStringList fileNames) setTitle(MWTF_FILENAME); if (error != NULL) { + failedParses.append(fileNames.at(i)); showError(error); free(error); } @@ -940,6 +982,7 @@ void MainWindow::loadFiles(const QStringList fileNames) process_dives(false, false); addRecentFile(fileNames); + removeRecentFile(failedParses); refreshDisplay(); ui.actionAutoGroup->setChecked(autogroup); |