summaryrefslogtreecommitdiffstats
path: root/qt-models/divetripmodel.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-05-05 00:12:36 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-07 08:43:27 -0700
commitfb6210a99a1eda0f7f7197ed57f3c61a82132dff (patch)
tree7562feb3291d06173b971437d1bd3395b2722eff /qt-models/divetripmodel.h
parentaeee2a08027b177495635262114374f085351ce7 (diff)
downloadsubsurface-fb6210a99a1eda0f7f7197ed57f3c61a82132dff.tar.gz
cleanup: invert control-flow when resetting the core structures
To reset the core data structures, the mobile and desktop UIs were calling into the dive-list models, which then reset the core data structures, themselves and the unrelated locationinformation model. The UI code then reset various other things, such as the TankInformation model or the map. . This was unsatisfying from a control-flow perspective, as the models should display the core data, not act on it. Moreover, this meant lots of intricate intermodule-dependencies. Thus, straighten up the control flow: give the C core the possibility to send a "all data reset" event. And do that in those functions that reset the core data structures. Let each module react to this event by itself. This removes inter-module dependencies. For example, the MainWindow now doesn't have to reset the TankInfoModel or the MapWidget. Then, to reset the core data structures, let the UI code simply directly call the respective core functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divetripmodel.h')
-rw-r--r--qt-models/divetripmodel.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h
index 3e7955b5b..4b2376bd9 100644
--- a/qt-models/divetripmodel.h
+++ b/qt-models/divetripmodel.h
@@ -64,12 +64,6 @@ public:
// Call after having set the model to be informed of the current selection.
void initSelection();
- // Clear all dives
- void clear();
-
- // Reload data
- void reset();
-
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
DiveTripModelBase(QObject *parent = 0);
@@ -78,6 +72,8 @@ public:
// Used for sorting. This is a bit of a layering violation, as sorting should be performed
// by the higher-up QSortFilterProxyModel, but it makes things so much easier!
virtual bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const = 0;
+protected slots:
+ void reset();
signals:
// The propagation of selection changes is complex.
// The control flow of dive-selection goes: