diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-10-12 15:07:40 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-13 21:42:53 -0400 |
commit | 78e2560296bbcc9209dec947417feb8da5a5107c (patch) | |
tree | 58db2cdb02f11db7f98a6942b4d4a16da5dd49f1 /desktop-widgets/mainwindow.h | |
parent | 11a211fb02ad5443342d91b6967f150cb4f6d34f (diff) | |
download | subsurface-78e2560296bbcc9209dec947417feb8da5a5107c.tar.gz |
Cleanup: Turn widget accessor-functions into simple pointers
The keeps track of different sub widgets needed by other parts
of the code, notably:
MainTab
PlannerDetails
PlannerSettingsWidget
ProfileWidget2
DivePlannerWidget
DiveListView
Access to these widgets was provided with accessor functions.
Now these functions were very weird: instead of simply returning
pointers that were stored in the class, they accessed a data
structure which describes the different application states.
But this data structure was "duck-typed", so there was an
implicit agreement at which position the pointers to the
widgets were put inside. The widgets were then down-cast by
the accessor functions. This might make sense if the individual
widgets could for some reason be replaced by other widgets
[dynamic plugins?], but even then it would be strange, as one
would expect to get a pointer to some base class.
Therefore, directly store the properly typed pointers to the
widgets and simply remove the accessor functions. Why bother?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/mainwindow.h')
-rw-r--r-- | desktop-widgets/mainwindow.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h index 6833c5531..1bb674e40 100644 --- a/desktop-widgets/mainwindow.h +++ b/desktop-widgets/mainwindow.h @@ -59,14 +59,10 @@ public: MainWindow(); ~MainWindow(); static MainWindow *instance(); - MainTab *information(); void loadRecentFiles(); void updateRecentFiles(); void updateRecentFilesMenu(); void addRecentFile(const QString &file, bool update); - DiveListView *dive_list(); - DivePlannerWidget *divePlannerWidget(); - PlannerSettingsWidget *divePlannerSettingsWidget(); LocationInformationWidget *locationInformationWidget(); void setTitle(); @@ -74,8 +70,6 @@ public: void importFiles(const QStringList importFiles); void cleanUpEmpty(); void setToolButtonsEnabled(bool enabled); - ProfileWidget2 *graphics() const; - PlannerDetails *plannerDetails() const; void printPlan(); void checkSurvey(); void setApplicationState(const QByteArray& state); @@ -87,6 +81,12 @@ public: void enterEditState(); void exitEditState(); + MainTab *information; + PlannerDetails *plannerDetails; + PlannerSettingsWidget *divePlannerSettingsWidget; + ProfileWidget2 *graphics; + DivePlannerWidget *divePlannerWidget; + DiveListView *dive_list; private slots: /* file menu action */ |