From 30133946e0354339078dacb18869ae09747f2caf Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 5 May 2020 11:42:01 +0200 Subject: models: emit dive changed signal when cylinders edited To display changed SAC values it is necessary that the models emit changed signals when cylinders are edited. An alternative might be that the undo commands emit dive-changed signals themselves. Fixes #2814. Signed-off-by: Berthold Stoeger --- qt-models/divetripmodel.cpp | 16 ++++++++++++++++ qt-models/divetripmodel.h | 2 ++ 2 files changed, 18 insertions(+) (limited to 'qt-models') diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 784013bce..0af987191 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -716,6 +716,9 @@ DiveTripModelTree::DiveTripModelTree(QObject *parent) : DiveTripModelBase(parent connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModelTree::divesSelected); connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &DiveTripModelTree::tripChanged); connect(&diveListNotifier, &DiveListNotifier::filterReset, this, &DiveTripModelTree::filterReset); + connect(&diveListNotifier, &DiveListNotifier::cylinderAdded, this, &DiveTripModelTree::cylinderChanged); + connect(&diveListNotifier, &DiveListNotifier::cylinderEdited, this, &DiveTripModelTree::cylinderChanged); + connect(&diveListNotifier, &DiveListNotifier::cylinderRemoved, this, &DiveTripModelTree::cylinderChanged); populate(); } @@ -1253,6 +1256,11 @@ void DiveTripModelTree::divesChanged(const QVector &dives) { divesChangedTrip(trip, divesInTrip); }); } +void DiveTripModelTree::cylinderChanged(dive *d) +{ + divesChanged(QVector { d }); +} + void DiveTripModelTree::divesChangedTrip(dive_trip *trip, const QVector &divesIn) { QVector dives = divesIn; @@ -1469,6 +1477,9 @@ DiveTripModelList::DiveTripModelList(QObject *parent) : DiveTripModelBase(parent connect(&diveListNotifier, &DiveListNotifier::divesTimeChanged, this, &DiveTripModelList::divesTimeChanged); connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModelList::divesSelected); connect(&diveListNotifier, &DiveListNotifier::filterReset, this, &DiveTripModelList::filterReset); + connect(&diveListNotifier, &DiveListNotifier::cylinderAdded, this, &DiveTripModelList::cylinderChanged); + connect(&diveListNotifier, &DiveListNotifier::cylinderEdited, this, &DiveTripModelList::cylinderChanged); + connect(&diveListNotifier, &DiveListNotifier::cylinderRemoved, this, &DiveTripModelList::cylinderChanged); populate(); } @@ -1622,6 +1633,11 @@ void DiveTripModelList::divesChanged(const QVector &divesIn) initSelection(); } +void DiveTripModelList::cylinderChanged(dive *d) +{ + divesChanged(QVector { d }); +} + void DiveTripModelList::divesTimeChanged(timestamp_t delta, const QVector &divesIn) { QVector dives = visibleDives(divesIn); diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h index 52173a48c..332dc59f8 100644 --- a/qt-models/divetripmodel.h +++ b/qt-models/divetripmodel.h @@ -115,6 +115,7 @@ public slots: void divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool deleteFrom, bool createTo, const QVector &dives); void diveSiteChanged(dive_site *ds, int field); void divesChanged(const QVector &dives); + void cylinderChanged(dive *d); void divesTimeChanged(timestamp_t delta, const QVector &dives); void divesSelected(const QVector &dives); void tripChanged(dive_trip *trip, TripField); @@ -190,6 +191,7 @@ public slots: void divesDeleted(dive_trip *trip, bool deleteTrip, const QVector &dives); void diveSiteChanged(dive_site *ds, int field); void divesChanged(const QVector &dives); + void cylinderChanged(dive *d); void divesTimeChanged(timestamp_t delta, const QVector &dives); // Does nothing in list view. //void divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool deleteFrom, bool createTo, const QVector &dives); -- cgit v1.2.3-70-g09d2