summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-05-24 21:03:18 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-24 21:09:11 -0700
commit81c84d02edfa2d91153c8d52e16aa2db442c5264 (patch)
tree98913d59262034704af189d23263e3dcf4477ec5 /qt-ui/divelistview.cpp
parenta3d300ca919d338345edfb6d76eb17a88875293a (diff)
downloadsubsurface-81c84d02edfa2d91153c8d52e16aa2db442c5264.tar.gz
Speed up the multi dive selection
Dirk's code in commit a3d300ca919d ("Correctly implement multi dive selection") had a major flaw - it kept redrawing the selected dives one after another. Not what we need. So this fixes this up so that it doesn't take more than a sec to select all the dives that are on the same part of the click on the globe. I've achieved this by creating a boolean ' dontEmitDiveChanged and sending the signal only if this flag is false. The reason that we can't simply remove the emit from the selectionChanged is because the selectionChanged is what we have when we click on the diveList, if we removed this from there, nothing will happen upon selection. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r--qt-ui/divelistview.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index e505cfd0d..92e8dd506 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -28,7 +28,8 @@
#include <iostream>
#include "../qthelper.h"
-DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), sortColumn(0), currentOrder(Qt::DescendingOrder), searchBox(this)
+DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), sortColumn(0)
+ , currentOrder(Qt::DescendingOrder), searchBox(this), dontEmitDiveChangedSignal(false)
{
setItemDelegate(new DiveListDelegate(this));
setUniformRowHeights(true);
@@ -241,6 +242,7 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
if (!newDiveSelection.count())
return;
+ dontEmitDiveChangedSignal = true;
// select the dives, highest index first - this way the oldest of the dives
// becomes the selected_dive that we scroll to
QList<int> sortedSelection = newDiveSelection;
@@ -254,6 +256,9 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
scrollTo(idx.parent());
scrollTo(idx);
+ // now that everything is up to date, update the widgets
+ Q_EMIT currentDiveChanged(selected_dive);
+ dontEmitDiveChangedSignal = false;
return;
}
@@ -454,8 +459,8 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
QTreeView::selectionChanged(selectionModel()->selection(), newDeselected);
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection)));
connect(selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex)));
- // now that everything is up to date, update the widgets
- Q_EMIT currentDiveChanged(selected_dive);
+ if(!dontEmitDiveChangedSignal)
+ Q_EMIT currentDiveChanged(selected_dive);
}
static bool can_merge(const struct dive *a, const struct dive *b)