summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-05-10 19:51:43 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-05-12 12:33:55 -0700
commit75767c456a2889d213621866a9f7fbb108f3366d (patch)
tree1f941f73a58718affe6c199c510e08e0eec75f95 /desktop-widgets/mainwindow.h
parent114b3d9d470e65c25bcb5711daf053478f30e319 (diff)
downloadsubsurface-75767c456a2889d213621866a9f7fbb108f3366d.tar.gz
Turn application state into enum
The application state was encoded in a QByteArray. Thus, there was no compile-time checking. Typos would lead to silent failures. Turn the application state into an enum. Use the enum-class construct, so that the values don't polute the global namespace. Moreover, this makes them strongly typed, i.e. they don't auto-convert to integers. A disadvantage is that the enums now have to be cast to int explicitly when used to index an array. Replace two hash-maps in MainWindow to arrays of fixed sizes. Move the application-state details into their own files. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/mainwindow.h')
-rw-r--r--desktop-widgets/mainwindow.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h
index 805900a74..a929cf764 100644
--- a/desktop-widgets/mainwindow.h
+++ b/desktop-widgets/mainwindow.h
@@ -19,6 +19,7 @@
#include "ui_plannerDetails.h"
#include "desktop-widgets/notificationwidget.h"
#include "desktop-widgets/filterwidget2.h"
+#include "core/applicationstate.h"
#include "core/gpslocation.h"
#include "core/dive.h"
@@ -56,7 +57,7 @@ public:
INFO_MAXIMIZED,
PROFILE_MAXIMIZED,
LIST_MAXIMIZED,
- EDIT
+ EDIT,
};
MainWindow();
@@ -75,8 +76,8 @@ public:
void setToolButtonsEnabled(bool enabled);
void printPlan();
void checkSurvey();
- void setApplicationState(const QByteArray& state);
- void setStateProperties(const QByteArray& state, const PropertyList& tl, const PropertyList& tr, const PropertyList& bl,const PropertyList& br);
+ void setApplicationState(ApplicationState state);
+ void setStateProperties(ApplicationState state, const PropertyList& tl, const PropertyList& tr, const PropertyList& bl,const PropertyList& br);
bool inPlanner();
NotificationWidget *getNotificationWidget();
void enableDisableCloudActions();
@@ -212,7 +213,7 @@ private:
void toggleCollapsible(bool toggle);
void showFilterIfEnabled();
void updateLastUsedDir(const QString &s);
- void registerApplicationState(const QByteArray& state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight);
+ void registerApplicationState(ApplicationState state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight);
void enterState(CurrentState);
bool filesAsArguments;
UpdateManager *updateManager;
@@ -249,8 +250,8 @@ private:
PropertyList bottomRight;
};
- QHash<QByteArray, WidgetForQuadrant> applicationState;
- QHash<QByteArray, PropertiesForQuadrant> stateProperties;
+ WidgetForQuadrant applicationState[(size_t)ApplicationState::Count];
+ PropertiesForQuadrant stateProperties[(size_t)ApplicationState::Count];
GpsLocation *locationProvider;
QMenu *connections;