diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-07-03 20:51:24 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-07-04 10:40:47 +0900 |
commit | 57c22d3dcc221caad66f12bb01a278c33dca0ab3 (patch) | |
tree | 642ab351105c90ba505244a087fea91651c183e0 /desktop-widgets | |
parent | 5c1446a87acbdd8c8859a381eb89a131d49ce49f (diff) | |
download | subsurface-57c22d3dcc221caad66f12bb01a278c33dca0ab3.tar.gz |
Cleanup: avoid spurious updateDiveInfo() calls
In 2e230da3610dd1fc61badaf328a084512895fb90 the dive-selection signals
were unified. Sadly, this was done in a suboptimal way resulting in
numerous calls to updateDiveInfo(), which refreshes the main-tab.
Firstly, the MainWindow connected to selection changes from both,
the undo-command and the divelist. Secondly, every selected dive
in the divelist caused a single signal.
Thus, connect only to the divelist (this is necessary for user-initiated
selection changes) and only send a single signal in the divelist
per selection-reset.
This is still less than perfect as updateDiveInfo() is called even
if the current dive doesn't change.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/divelistview.cpp | 7 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 09c69c2a8..c4f778a92 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -194,6 +194,10 @@ void DiveListView::reset() // If items were selected, inform the selection model void DiveListView::diveSelectionChanged(const QVector<QModelIndex> &indexes) { + // Since dives are selected dive-by-dive, send only a single signal at the + // end, not one for every dive. + dontEmitDiveChangedSignal = true; + clearSelection(); MultiFilterSortModel *m = MultiFilterSortModel::instance(); QItemSelectionModel *s = selectionModel(); @@ -217,6 +221,9 @@ void DiveListView::diveSelectionChanged(const QVector<QModelIndex> &indexes) setAnimated(true); } } + + dontEmitDiveChangedSignal = false; + emit divesSelected(); } void DiveListView::currentDiveChanged(QModelIndex index) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 8dc0f94b5..2a1e879a8 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -191,7 +191,6 @@ MainWindow::MainWindow() : QMainWindow(), if (!QIcon::hasThemeIcon("window-close")) { QIcon::setThemeName("subsurface"); } - connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &MainWindow::selectionChanged); connect(diveList, &DiveListView::divesSelected, this, &MainWindow::selectionChanged); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveList, SLOT(update())); |