mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive list view: replace signal-magic by flag
In DiveListView, we have a very fundamental problem: When On the one hand, we get informed of user-selection in the DiveListView::selectionChanged() slot. This has to set the correct flags in the C-backend. On the other hand, sometimes we have to set the selection programatically, e.g. when selecting a trip. This is done by calling QItemSelectionModel::select(). But: this will *also* call into the above slot, in which we can't tell whether it was a user interaction or an internal call. This can lead to either infinite loops or very inefficient behavior, because the current dive is set numerous times. The current code is aware of that and disconnects the corresponding signal. This is scary, as these signals are set internally by the model and view. Replace this by a global "command executing" flag in DiveListNotifier. The flag is set using a "marker" class, which resets the flag once it goes out of scope (cf. RAII pattern). In DiveListView, only process a selection if the flag is not set. Otherwise simply call the QTreeView base class, to reflect the new selection in the UI. To have a common point for notifications of selection changes, add such a signal to DiveListNotifier. This signal will be used by the DiveListView as well as the Command-objects. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0d98da5261
commit
23db0ba68d
6 changed files with 99 additions and 27 deletions
|
@ -58,10 +58,6 @@ slots:
|
|||
void shiftTimes();
|
||||
void loadImages();
|
||||
void loadWebImages();
|
||||
|
||||
signals:
|
||||
void currentDiveChanged();
|
||||
|
||||
private:
|
||||
bool mouseClickSelection;
|
||||
QList<int> expandedRows;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue