mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
aeee2a0802
commit
fb6210a99a
18 changed files with 70 additions and 49 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue