diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-05-13 21:42:31 -0500 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-13 21:47:14 -0500 |
commit | 009e6a6fa7055ed0ef14e4b4d9407999d86ef158 (patch) | |
tree | ef6c91a4d28c830517ab00775c5b967ff6c16c3a | |
parent | 6f74618d9c3907765633f6b6e17eb2ba5cd8f931 (diff) | |
download | subsurface-009e6a6fa7055ed0ef14e4b4d9407999d86ef158.tar.gz |
shift-key + shift-click + key corner cases covered.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | Configure.mk | 2 | ||||
-rw-r--r-- | qt-ui/divelistview.cpp | 26 | ||||
-rw-r--r-- | qt-ui/divelistview.h | 2 |
3 files changed, 23 insertions, 7 deletions
diff --git a/Configure.mk b/Configure.mk index 96508c65c..f3281d317 100644 --- a/Configure.mk +++ b/Configure.mk @@ -5,7 +5,7 @@ all: PKGCONFIG=pkg-config XML2CONFIG=xml2-config XSLCONFIG=xslt-config -QMAKE=qmake +QMAKE=qmake-qt4 MOC=moc UIC=uic diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 2b579e1f0..e5d4baddc 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -17,7 +17,6 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec { setUniformRowHeights(true); setItemDelegateForColumn(TreeItemDT::RATING, new StarWidgetsDelegate()); - } void DiveListView::setModel(QAbstractItemModel* model) @@ -43,8 +42,22 @@ void DiveListView::mouseReleaseEvent(QMouseEvent* event) QTreeView::mouseReleaseEvent(event); } +void DiveListView::keyPressEvent(QKeyEvent* event) +{ + if(event->modifiers()) + mouseClickSelection = true; + QTreeView::keyPressEvent(event); +} + +void DiveListView::keyReleaseEvent(QKeyEvent* event) +{ + mouseClickSelection = false; + QWidget::keyReleaseEvent(event); +} + void DiveListView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { + QList<QModelIndex> parents; Q_FOREACH(const QModelIndex& index, deselected.indexes()) { const QAbstractItemModel *model = index.model(); struct dive *dive = (struct dive*) model->data(index, TreeItemDT::DIVE_ROLE).value<void*>(); @@ -53,10 +66,11 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS expand(index); // leave this - even if it looks like it shouldn't be here. looks like I'v found a Qt bug. // the subselection is removed, but the painting is not. this cleans the area. } + } else if (!parents.contains(index.parent())) { + parents.push_back(index.parent()); } } - QList<QModelIndex> parents; Q_FOREACH(const QModelIndex& index, selected.indexes()) { const QAbstractItemModel *model = index.model(); struct dive *dive = (struct dive*) model->data(index, TreeItemDT::DIVE_ROLE).value<void*>(); @@ -66,17 +80,17 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS selection.select(index.child(0,0), index.child(model->rowCount(index) -1 , 0)); selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows); selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select | QItemSelectionModel::NoUpdate); - if (!isExpanded(index)){ + if (!isExpanded(index)) { expand(index); } } - } - else if (!parents.contains(index.parent())){ + } else if (!parents.contains(index.parent())) { parents.push_back(index.parent()); } } - Q_FOREACH(const QModelIndex& index, parents){ + Q_FOREACH(const QModelIndex& index, parents) { + qDebug() << "Expanding"; expand(index); } } diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h index 9cccd39ae..9df8b5fa1 100644 --- a/qt-ui/divelistview.h +++ b/qt-ui/divelistview.h @@ -26,6 +26,8 @@ public: void mousePressEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); + void keyPressEvent(QKeyEvent* event); + void keyReleaseEvent(QKeyEvent*); void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags command); |