mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:33:24 +00:00
Saves the selection to select it later.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
4019fdaa24
commit
5a994b08f6
2 changed files with 26 additions and 3 deletions
|
@ -24,20 +24,43 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
|
||||||
setModel(model);
|
setModel(model);
|
||||||
setSortingEnabled(false);
|
setSortingEnabled(false);
|
||||||
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
connect(header(), SIGNAL(sectionClicked(int)), this, SLOT(headerClicked(int)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveListView::headerClicked(int i )
|
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){
|
if (i == (int) TreeItemDT::NR){
|
||||||
reload(DiveTripModel::TREE);
|
reload(DiveTripModel::TREE);
|
||||||
}else{
|
}else{
|
||||||
reload(DiveTripModel::LIST);
|
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)
|
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());
|
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
||||||
QAbstractItemModel *oldModel = m->sourceModel();
|
QAbstractItemModel *oldModel = m->sourceModel();
|
||||||
if (oldModel)
|
if (oldModel)
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="animated">
|
<property name="animated">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>763</width>
|
<width>763</width>
|
||||||
<height>25</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
|
Loading…
Add table
Reference in a new issue