summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divetripmodel.cpp18
-rw-r--r--qt-models/divetripmodel.h5
2 files changed, 15 insertions, 8 deletions
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp
index ee0620c5e..ae6dfe651 100644
--- a/qt-models/divetripmodel.cpp
+++ b/qt-models/divetripmodel.cpp
@@ -575,6 +575,7 @@ DiveTripModelTree::DiveTripModelTree(QObject *parent) : DiveTripModelBase(parent
connect(&diveListNotifier, &DiveListNotifier::divesTimeChanged, this, &DiveTripModelTree::divesTimeChanged);
connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModelTree::divesSelected);
connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &DiveTripModelTree::tripChanged);
+ connect(&diveListNotifier, &DiveListNotifier::filterReset, this, &DiveTripModelTree::filterReset);
// Fill model
for (int i = 0; i < dive_table.nr ; ++i) {
@@ -745,7 +746,11 @@ bool DiveTripModelTree::calculateFilterForTrip(const std::vector<dive *> &dives,
return showTrip;
}
-void DiveTripModelTree::recalculateFilter()
+// This recalculates the filters and sends appropriate changed signals.
+// Attention: Since this uses / modifies the hidden_by_filter flag of the
+// core dive structure, only one DiveTripModel[Tree|List] must exist at
+// a given time!
+void DiveTripModelTree::filterReset()
{
// Collect the changes in a vector used later to send signals.
// This could be solved more efficiently in one pass, but
@@ -791,7 +796,6 @@ void DiveTripModelTree::recalculateFilter()
}
emit diveListNotifier.numShownChanged();
- emit diveListNotifier.filterReset();
}
@@ -1291,6 +1295,7 @@ DiveTripModelList::DiveTripModelList(QObject *parent) : DiveTripModelBase(parent
//connect(&diveListNotifier, &DiveListNotifier::divesMovedBetweenTrips, this, &DiveTripModelList::divesMovedBetweenTrips);
connect(&diveListNotifier, &DiveListNotifier::divesTimeChanged, this, &DiveTripModelList::divesTimeChanged);
connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModelList::divesSelected);
+ connect(&diveListNotifier, &DiveListNotifier::filterReset, this, &DiveTripModelList::filterReset);
// Fill model
items.reserve(dive_table.nr);
@@ -1332,7 +1337,11 @@ dive *DiveTripModelList::diveOrNull(const QModelIndex &index) const
return items[row];
}
-void DiveTripModelList::recalculateFilter()
+// This recalculates the filters and sends appropriate changed signals.
+// Attention: Since this uses / modifies the hidden_by_filter flag of the
+// core dive structure, only one DiveTripModel[Tree|List] must exist at
+// a given time!
+void DiveTripModelList::filterReset()
{
// Collect the changes in a vector used later to send signals.
// This could be solved more efficiently in one pass, but
@@ -1342,7 +1351,7 @@ void DiveTripModelList::recalculateFilter()
changed.reserve(items.size());
{
// This marker prevents the UI from getting notifications on selection changes.
- // It is active until the end of the scope. See comment in DiveTripModelTree::recalculateFilter().
+ // It is active until the end of the scope. See comment in DiveTripModelTree::filterReset().
auto marker = diveListNotifier.enterCommand();
DiveFilter *filter = DiveFilter::instance();
@@ -1356,7 +1365,6 @@ void DiveTripModelList::recalculateFilter()
sendShownChangedSignals(changed, noParent);
emit diveListNotifier.numShownChanged();
- emit diveListNotifier.filterReset();
}
QVariant DiveTripModelList::data(const QModelIndex &index, int role) const
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h
index 4f5b55f02..66af0a32a 100644
--- a/qt-models/divetripmodel.h
+++ b/qt-models/divetripmodel.h
@@ -83,7 +83,6 @@ public:
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
DiveTripModelBase(QObject *parent = 0);
int columnCount(const QModelIndex&) const;
- virtual void recalculateFilter() = 0;
// Used for sorting. This is a bit of a layering violation, as sorting should be performed
// by the higher-up QSortFilterProxyModel, but it makes things so much easier!
@@ -121,6 +120,7 @@ public slots:
void divesTimeChanged(timestamp_t delta, const QVector<dive *> &dives);
void divesSelected(const QVector<dive *> &dives, dive *current);
void tripChanged(dive_trip *trip, TripField);
+ void filterReset();
public:
DiveTripModelTree(QObject *parent = nullptr);
@@ -133,7 +133,6 @@ private:
bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const override;
void divesSelectedTrip(dive_trip *trip, const QVector<dive *> &dives, QVector<QModelIndex> &);
dive *diveOrNull(const QModelIndex &index) const override;
- void recalculateFilter();
void divesChangedTrip(dive_trip *trip, const QVector<dive *> &dives);
void divesTimeChangedTrip(dive_trip *trip, timestamp_t delta, const QVector<dive *> &dives);
bool calculateFilterForTrip(const std::vector<dive *> &dives, const DiveFilter *filter, quintptr parentIndex);
@@ -188,6 +187,7 @@ public slots:
// Does nothing in list view.
//void divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool deleteFrom, bool createTo, const QVector<dive *> &dives);
void divesSelected(const QVector<dive *> &dives, dive *current);
+ void filterReset();
public:
DiveTripModelList(QObject *parent = nullptr);
@@ -199,7 +199,6 @@ private:
QVariant data(const QModelIndex &index, int role) const override;
bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const override;
dive *diveOrNull(const QModelIndex &index) const override;
- void recalculateFilter();
std::vector<dive *> items; // TODO: access core data directly
};