aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/divelistview.cpp10
-rw-r--r--qt-models/divetripmodel.cpp3
-rw-r--r--qt-models/divetripmodel.h2
-rw-r--r--qt-models/filtermodels.cpp12
-rw-r--r--qt-models/filtermodels.h3
5 files changed, 18 insertions, 12 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index c01a6189a..30364a8eb 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -33,12 +33,7 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
setItemDelegate(new DiveListDelegate(this));
setUniformRowHeights(true);
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate(this));
- MultiFilterSortModel *model = MultiFilterSortModel::instance();
- model->setSortRole(DiveTripModel::SORT_ROLE);
- model->setFilterKeyColumn(-1); // filter all columns
- model->setFilterCaseSensitivity(Qt::CaseInsensitive);
- model->setSourceModel(DiveTripModel::instance());
- setModel(model);
+ setModel(MultiFilterSortModel::instance());
setSortingEnabled(false);
setContextMenuPolicy(Qt::DefaultContextMenu);
@@ -503,8 +498,7 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
header()->setSectionsClickable(true);
connect(header(), SIGNAL(sectionPressed(int)), this, SLOT(headerClicked(int)), Qt::UniqueConnection);
- DiveTripModel *tripModel = DiveTripModel::instance();
- tripModel->setLayout(layout); // Note: setLayout() resets the whole model
+ MultiFilterSortModel::instance()->setLayout(layout);
if (!forceSort)
return;
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp
index 14bc744f6..0194a312f 100644
--- a/qt-models/divetripmodel.cpp
+++ b/qt-models/divetripmodel.cpp
@@ -320,9 +320,6 @@ DiveTripModel::DiveTripModel(QObject *parent) :
connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModel::divesSelected);
connect(&diveListNotifier, &DiveListNotifier::divesDeselected, this, &DiveTripModel::divesDeselected);
connect(&diveListNotifier, &DiveListNotifier::currentDiveChanged, this, &DiveTripModel::currentDiveChanged);
-
- // Update trip headers if filter finished
- connect(MultiFilterSortModel::instance(), &MultiFilterSortModel::filterFinished, this, &DiveTripModel::filterFinished);
}
int DiveTripModel::columnCount(const QModelIndex&) const
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h
index fb826eec1..b372a981f 100644
--- a/qt-models/divetripmodel.h
+++ b/qt-models/divetripmodel.h
@@ -55,6 +55,7 @@ public:
int rowCount(const QModelIndex &parent) const;
QModelIndex index(int row, int column, const QModelIndex &parent) const;
QModelIndex parent(const QModelIndex &index) const;
+ void filterFinished();
signals:
// The propagation of selection changes is complex.
// The control flow of dive-selection goes:
@@ -74,7 +75,6 @@ private slots:
void divesSelected(dive_trip *trip, const QVector<dive *> &dives);
void divesDeselected(dive_trip *trip, const QVector<dive *> &dives);
void currentDiveChanged();
- void filterFinished();
private:
// The model has up to two levels. At the top level, we have either trips or dives
// that do not belong to trips. Such a top-level item is represented by the "Item"
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index ce0c2528c..857c5d698 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -562,6 +562,16 @@ MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyMo
divesDisplayed(0),
curr_dive_site(NULL)
{
+ setSortRole(DiveTripModel::SORT_ROLE);
+ setFilterKeyColumn(-1); // filter all columns
+ setFilterCaseSensitivity(Qt::CaseInsensitive);
+ setSourceModel(DiveTripModel::instance());
+}
+
+void MultiFilterSortModel::setLayout(DiveTripModel::Layout layout)
+{
+ DiveTripModel *tripModel = DiveTripModel::instance();
+ tripModel->setLayout(layout); // Note: setLayout() resets the whole model
}
void MultiFilterSortModel::divesAdded(const QVector<dive *> &dives)
@@ -656,6 +666,8 @@ void MultiFilterSortModel::myInvalidate()
invalidateFilter();
+ // Tell the dive trip model to update the displayed-counts
+ DiveTripModel::instance()->filterFinished();
emit filterFinished();
#if !defined(SUBSURFACE_MOBILE)
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index f962386a1..f579df1a9 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -2,6 +2,8 @@
#ifndef FILTERMODELS_H
#define FILTERMODELS_H
+#include "divetripmodel.h" // For DiveTripModel::Layout. TODO: remove in due course
+
#include <QStringListModel>
#include <QSortFilterProxyModel>
#include <stdint.h>
@@ -132,6 +134,7 @@ slots:
void startFilterDiveSite(struct dive_site *ds);
void stopFilterDiveSite();
void filterChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles);
+ void setLayout(DiveTripModel::Layout layout);
signals:
void filterFinished();