mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
First cut at selecting dives from the map
We'll want to enhance this: better logic for which dives are near the selection, and it's probably best to have a "control-click" that adds the dives to the selection rather than deselecting all the old ones. But it's already useful. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
b533cf299f
commit
a737f59553
3 changed files with 61 additions and 1 deletions
|
@ -40,6 +40,25 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
|
|||
connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString)));
|
||||
}
|
||||
|
||||
void DiveListView::unselectDives()
|
||||
{
|
||||
selectionModel()->clearSelection();
|
||||
}
|
||||
|
||||
void DiveListView::selectDive(struct dive *dive, bool scrollto)
|
||||
{
|
||||
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
||||
QModelIndexList match = m->match(m->index(0,0), TreeItemDT::NR, dive->number, 1, Qt::MatchRecursive);
|
||||
QModelIndex idx = match.first();
|
||||
|
||||
QModelIndex parent = idx.parent();
|
||||
if (parent.isValid())
|
||||
expand(parent);
|
||||
selectionModel()->select( idx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
if (scrollto)
|
||||
scrollTo(idx, PositionAtCenter);
|
||||
}
|
||||
|
||||
void DiveListView::showSearchEdit()
|
||||
{
|
||||
searchBox->show();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue