From fb6210a99a1eda0f7f7197ed57f3c61a82132dff Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 5 May 2020 00:12:36 +0200 Subject: 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 --- qt-models/gpslistmodel.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qt-models/gpslistmodel.cpp') diff --git a/qt-models/gpslistmodel.cpp b/qt-models/gpslistmodel.cpp index 33eb8a5ea..c463c3ed2 100644 --- a/qt-models/gpslistmodel.cpp +++ b/qt-models/gpslistmodel.cpp @@ -1,10 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 #include "qt-models/gpslistmodel.h" +#include "core/subsurface-qt/divelistnotifier.h" #include "core/qthelper.h" #include GpsListModel::GpsListModel() { + connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &GpsListModel::update); } void GpsListModel::update() -- cgit v1.2.3-70-g09d2