aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/mobilelistmodel.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/mobilelistmodel.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/mobilelistmodel.h')
-rw-r--r--qt-models/mobilelistmodel.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/qt-models/mobilelistmodel.h b/qt-models/mobilelistmodel.h
index c898ed118..e315e9ebd 100644
--- a/qt-models/mobilelistmodel.h
+++ b/qt-models/mobilelistmodel.h
@@ -77,6 +77,7 @@ public:
MobileListModel(DiveTripModelBase *source);
void expand(int row);
void unexpand();
+ void invalidate();
Q_INVOKABLE void toggle(int row);
Q_PROPERTY(int shown READ shown NOTIFY shownChanged);
signals:
@@ -121,6 +122,7 @@ public:
MobileSwipeModel(DiveTripModelBase *source);
static MobileSwipeModel *instance();
void resetModel(DiveTripModelBase::Layout layout); // Switch between tree and list view
+ void invalidate();
private:
struct IndexRange {
int first, last;
@@ -175,8 +177,7 @@ public:
static MobileModels *instance();
MobileListModel *listModel();
MobileSwipeModel *swipeModel();
- void clear(); // Clear all dive data
- void reset(); // Reset model after having reloaded the core data
+ void invalidate(); // Invalidate all entries to force a re-render.
private:
MobileModels();
DiveTripModelTree source;