summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-05-28 17:46:40 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-05-28 17:46:40 -0300
commit5a994b08f6323680fe8362f129f097c9c2aaef2e (patch)
tree749053dc680bcefaa17c542ccc1dda8ddefec89f /qt-ui
parent4019fdaa24eb96a615632b8374e22434ec4069c2 (diff)
downloadsubsurface-5a994b08f6323680fe8362f129f097c9c2aaef2e.tar.gz
Saves the selection to select it later.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelistview.cpp25
-rw-r--r--qt-ui/mainwindow.ui4
2 files changed, 26 insertions, 3 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 8852eda3e..948bfa57a 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -24,20 +24,43 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
setModel(model);
setSortingEnabled(false);
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
- connect(header(), SIGNAL(sectionClicked(int)), this, SLOT(headerClicked(int)));
}
void DiveListView::headerClicked(int i )
{
+ QModelIndexList oldSelection = selectionModel()->selectedRows();
+ QList<struct dive*> currentSelectedDives;
+ Q_FOREACH(const QModelIndex& index , oldSelection){
+ struct dive *d = (struct dive *) index.data(TreeItemDT::DIVE_ROLE).value<void*>();
+ if (d){
+ currentSelectedDives.push_back(d);
+ }
+ }
+
if (i == (int) TreeItemDT::NR){
reload(DiveTripModel::TREE);
}else{
reload(DiveTripModel::LIST);
}
+
+ QModelIndexList newSelection;
+ QItemSelection newSelection2;
+
+ Q_FOREACH(struct dive *d, currentSelectedDives){
+ QModelIndexList match = model()->match(model()->index(0,0), TreeItemDT::DIVE_ROLE, QVariant::fromValue<void*>(d), 1, Qt::MatchRecursive);
+ if (match.count() == 0){
+ qDebug() << "Well, this shouldn't happen.";
+ }else{
+ newSelection << match.first();
+ }
+ }
}
void DiveListView::reload(DiveTripModel::Layout layout)
{
+ header()->setClickable(true);
+ connect(header(), SIGNAL(sectionPressed(int)), this, SLOT(headerClicked(int)), Qt::UniqueConnection);
+
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
QAbstractItemModel *oldModel = m->sourceModel();
if (oldModel)
diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui
index 3f9726785..c72e36eb4 100644
--- a/qt-ui/mainwindow.ui
+++ b/qt-ui/mainwindow.ui
@@ -73,7 +73,7 @@
<bool>true</bool>
</property>
<property name="sortingEnabled">
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property name="animated">
<bool>true</bool>
@@ -103,7 +103,7 @@
<x>0</x>
<y>0</y>
<width>763</width>
- <height>25</height>
+ <height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">