aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2017-11-30 11:52:42 +0100
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-30 16:52:22 +0100
commit135ea00d88742714e66915b216d0d8d408df7248 (patch)
tree5cf1a16b7096b3783ef537193d678a246d517d6d /desktop-widgets/mainwindow.h
parent625298a7b86688ee70de4bccb8fcff61f96650db (diff)
downloadsubsurface-135ea00d88742714e66915b216d0d8d408df7248.tar.gz
implify recent file handling in mainwindow.cpp
The old code used to be unnecessarily complex: the recent files list was extended for each file and shrunk if a load failed. By adding a file to the recent file list only if the load succeeded, a whole method could be removed. Other changes: keep track of the recent files using a QStringList and clearly separate the actions: - Read recent files from settings [loadRecentFiles()] - Write recent files to settings [updateRecentFiles()] - Update the recent files actions in the menu [updateRecentFilesMenu()] - Add a file to the list of recent files [addRecentFile()] With this reorganization the code hopefully became more clear. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/mainwindow.h')
-rw-r--r--desktop-widgets/mainwindow.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h
index 64b67f7e7..f378d549f 100644
--- a/desktop-widgets/mainwindow.h
+++ b/desktop-widgets/mainwindow.h
@@ -19,6 +19,8 @@
#include "core/windowtitleupdate.h"
#include "core/gpslocation.h"
+#define NUM_RECENT_FILES 4
+
class QSortFilterProxyModel;
class DiveTripModel;
class QItemSelection;
@@ -63,9 +65,10 @@ public:
virtual ~MainWindow();
static MainWindow *instance();
MainTab *information();
- void loadRecentFiles(QSettings *s);
- void addRecentFile(const QStringList &newFiles);
- void removeRecentFile(QStringList failedFiles);
+ void loadRecentFiles();
+ void updateRecentFiles();
+ void updateRecentFilesMenu();
+ void addRecentFile(const QString &file, bool update);
DiveListView *dive_list();
DivePlannerWidget *divePlannerWidget();
PlannerSettingsWidget *divePlannerSettingsWidget();
@@ -218,6 +221,7 @@ private:
struct dive copyPasteDive;
struct dive_components what;
QList<QAction *> profileToolbarActions;
+ QStringList recentFiles;
struct WidgetForQuadrant {
WidgetForQuadrant(QWidget *tl = 0, QWidget *tr = 0, QWidget *bl = 0, QWidget *br = 0) :