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:
Linus Torvalds 2013-06-05 15:41:52 +09:00 committed by Dirk Hohndel
parent b533cf299f
commit a737f59553
3 changed files with 61 additions and 1 deletions

View file

@ -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();