Dive list: remove three unnecessary instances of qobject_cast<>.
In DiveListView, the result of model() was dynamically cast to QSortFilterProxyModel. But then, only the virtual match() function was used. The whole point of virtual functions is that you can cast them on the base-class and it will execute the function of the derived class. Thus, remove these casts and operate directly on the QAbstractItemModel base class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9829e49815
commit
6ed5db4d51
@ -289,7 +289,7 @@ void DiveListView::selectTrip(dive_trip_t *trip)
|
||||
if (!trip)
|
||||
return;
|
||||
|
||||
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel *>(model());
|
||||
QAbstractItemModel *m = model();
|
||||
QModelIndexList match = m->match(m->index(0, 0), DiveTripModel::TRIP_ROLE, QVariant::fromValue<void *>(trip), 2, Qt::MatchRecursive);
|
||||
QItemSelectionModel::SelectionFlags flags;
|
||||
if (!match.count())
|
||||
@ -374,7 +374,7 @@ void DiveListView::selectDive(int i, bool scrollto, bool toggle)
|
||||
{
|
||||
if (i == -1)
|
||||
return;
|
||||
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel *>(model());
|
||||
QAbstractItemModel *m = model();
|
||||
QModelIndexList match = m->match(m->index(0, 0), DiveTripModel::DIVE_IDX, i, 2, Qt::MatchRecursive);
|
||||
if (match.isEmpty())
|
||||
return;
|
||||
@ -411,7 +411,7 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
|
||||
if ((d = get_dive(newSelection)) != NULL && !d->hidden_by_filter)
|
||||
selectDive(newSelection);
|
||||
}
|
||||
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel *>(model());
|
||||
QAbstractItemModel *m = model();
|
||||
QModelIndexList idxList = m->match(m->index(0, 0), DiveTripModel::DIVE_IDX, get_divenr(current_dive), 2, Qt::MatchRecursive);
|
||||
if (!idxList.isEmpty()) {
|
||||
QModelIndex idx = idxList.first();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user