aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-20 12:08:22 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-10-21 19:57:49 +0300
commit6ed5db4d51e3852916db64f2220004dbd04847fc (patch)
treecab2ff5b7298b4097668832fd69e4e6c6cdd5c59 /desktop-widgets
parent9829e49815de1b81b5c9848b71eaa810faab2bcf (diff)
downloadsubsurface-6ed5db4d51e3852916db64f2220004dbd04847fc.tar.gz
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>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/divelistview.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index 5a1741a7f..627e72c24 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -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();