mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Mainwindow: simplify application-state code
The way the application state would enable/disable widgets was very "dynamic". A property-list would be generated and put in a set of arrays. Very hard to figure out what is going on. Replace these property-list by flags and explicit old-fashioned boolean expressions. Join the two arrays (widget- and property-lists) into an array of a unified data structure. Replace the macro that sets the widgets by a simple static function. Factor out the four loops that added widgets to the quadrants into a simple static function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
75767c456a
commit
ca6aa38139
2 changed files with 57 additions and 82 deletions
|
@ -77,7 +77,6 @@ public:
|
|||
void printPlan();
|
||||
void checkSurvey();
|
||||
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();
|
||||
|
@ -213,7 +212,6 @@ private:
|
|||
void toggleCollapsible(bool toggle);
|
||||
void showFilterIfEnabled();
|
||||
void updateLastUsedDir(const QString &s);
|
||||
void registerApplicationState(ApplicationState state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight);
|
||||
void enterState(CurrentState);
|
||||
bool filesAsArguments;
|
||||
UpdateManager *updateManager;
|
||||
|
@ -231,27 +229,27 @@ private:
|
|||
QStringList recentFiles;
|
||||
QAction *actionsRecent[NUM_RECENT_FILES];
|
||||
|
||||
struct WidgetForQuadrant {
|
||||
WidgetForQuadrant(QWidget *tl = 0, QWidget *tr = 0, QWidget *bl = 0, QWidget *br = 0) :
|
||||
topLeft(tl), topRight(tr), bottomLeft(bl), bottomRight(br) {}
|
||||
QWidget *topLeft;
|
||||
QWidget *topRight;
|
||||
QWidget *bottomLeft;
|
||||
QWidget *bottomRight;
|
||||
enum {
|
||||
FLAG_NONE = 0,
|
||||
FLAG_DISABLED = 1
|
||||
};
|
||||
|
||||
struct PropertiesForQuadrant {
|
||||
PropertiesForQuadrant(){}
|
||||
PropertiesForQuadrant(const PropertyList& tl, const PropertyList& tr,const PropertyList& bl,const PropertyList& br) :
|
||||
topLeft(tl), topRight(tr), bottomLeft(bl), bottomRight(br) {}
|
||||
PropertyList topLeft;
|
||||
PropertyList topRight;
|
||||
PropertyList bottomLeft;
|
||||
PropertyList bottomRight;
|
||||
struct Quadrant {
|
||||
QWidget *widget;
|
||||
int flags;
|
||||
};
|
||||
|
||||
WidgetForQuadrant applicationState[(size_t)ApplicationState::Count];
|
||||
PropertiesForQuadrant stateProperties[(size_t)ApplicationState::Count];
|
||||
struct Quadrants {
|
||||
Quadrant topLeft;
|
||||
Quadrant topRight;
|
||||
Quadrant bottomLeft;
|
||||
Quadrant bottomRight;
|
||||
};
|
||||
|
||||
Quadrants applicationState[(size_t)ApplicationState::Count];
|
||||
static void setQuadrant(const Quadrant &, QStackedWidget *);
|
||||
static void addWidgets(const Quadrant &, QStackedWidget *);
|
||||
void registerApplicationState(ApplicationState state, Quadrants q);
|
||||
|
||||
GpsLocation *locationProvider;
|
||||
QMenu *connections;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue