diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-05-05 00:12:36 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-07 08:43:27 -0700 |
commit | fb6210a99a1eda0f7f7197ed57f3c61a82132dff (patch) | |
tree | 7562feb3291d06173b971437d1bd3395b2722eff /qt-models/weightsysteminfomodel.cpp | |
parent | aeee2a08027b177495635262114374f085351ce7 (diff) | |
download | subsurface-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/weightsysteminfomodel.cpp')
-rw-r--r-- | qt-models/weightsysteminfomodel.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/qt-models/weightsysteminfomodel.cpp b/qt-models/weightsysteminfomodel.cpp index 21d6f538f..9c28d5f64 100644 --- a/qt-models/weightsysteminfomodel.cpp +++ b/qt-models/weightsysteminfomodel.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "qt-models/weightsysteminfomodel.h" +#include "core/subsurface-qt/divelistnotifier.h" #include "core/dive.h" #include "core/metrics.h" #include "core/gettextfromc.h" @@ -74,6 +75,7 @@ int WSInfoModel::rowCount(const QModelIndex&) const WSInfoModel::WSInfoModel() { setHeaderDataStrings(QStringList() << tr("Description") << tr("kg")); + connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &WSInfoModel::update); update(); } |