mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:13:23 +00:00
Undo: update dive list if trip changed
In tree-mode, the trip locations are displayed. Update the corresponding entries if the trip changed, by hooking into the tripChanged() signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
7924c7dafb
commit
e7063b6b08
2 changed files with 16 additions and 1 deletions
|
@ -6,7 +6,6 @@
|
|||
#include "core/divelist.h"
|
||||
#include "core/qthelper.h"
|
||||
#include "core/subsurface-string.h"
|
||||
#include "core/subsurface-qt/DiveListNotifier.h"
|
||||
#include <QIcon>
|
||||
#include <QDebug>
|
||||
#include <memory>
|
||||
|
@ -560,6 +559,7 @@ DiveTripModelTree::DiveTripModelTree(QObject *parent) : DiveTripModelBase(parent
|
|||
connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModelTree::divesSelected);
|
||||
connect(&diveListNotifier, &DiveListNotifier::divesDeselected, this, &DiveTripModelTree::divesDeselected);
|
||||
connect(&diveListNotifier, &DiveListNotifier::currentDiveChanged, this, &DiveTripModelTree::currentDiveChanged);
|
||||
connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &DiveTripModelTree::tripChanged);
|
||||
|
||||
// Fill model
|
||||
for (int i = 0; i < dive_table.nr ; ++i) {
|
||||
|
@ -913,6 +913,19 @@ void DiveTripModelTree::divesChanged(dive_trip *trip, const QVector<dive *> &div
|
|||
}
|
||||
}
|
||||
|
||||
void DiveTripModelTree::tripChanged(dive_trip *trip, TripField)
|
||||
{
|
||||
int idx = findTripIdx(trip);
|
||||
if (idx < 0) {
|
||||
// We don't know the trip - this shouldn't happen. We seem to have
|
||||
// missed some signals!
|
||||
qWarning() << "DiveTripModelTree::divesChanged(): unknown trip";
|
||||
return;
|
||||
}
|
||||
|
||||
dataChanged(createIndex(idx, 0, noParent), createIndex(idx, COLUMNS - 1, noParent));
|
||||
}
|
||||
|
||||
static QVector<dive *> filterSelectedDives(const QVector<dive *> &dives)
|
||||
{
|
||||
QVector<dive *> res;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#define DIVETRIPMODEL_H
|
||||
|
||||
#include "core/dive.h"
|
||||
#include "core/subsurface-qt/DiveListNotifier.h"
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
// There are two different representations of the dive list:
|
||||
|
@ -112,6 +113,7 @@ public slots:
|
|||
void divesTimeChanged(dive_trip *trip, timestamp_t delta, const QVector<dive *> &dives);
|
||||
void divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool deleteFrom, bool createTo, const QVector<dive *> &dives);
|
||||
void currentDiveChanged();
|
||||
void tripChanged(dive_trip *trip, TripField);
|
||||
|
||||
public:
|
||||
DiveTripModelTree(QObject *parent = nullptr);
|
||||
|
|
Loading…
Add table
Reference in a new issue