summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-03-03 22:42:51 +0100
committerGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-07 00:13:35 +0200
commit7018783f64f664af97032da4ba4d357c05b52aaf (patch)
tree7b9d8b3e6156be1fe63b9bbbf66c382071fe73ab
parent30c7499a3c656784cc45825b4b1b2fca61081308 (diff)
downloadsubsurface-7018783f64f664af97032da4ba4d357c05b52aaf.tar.gz
undo: replot profile if event changed
Add a DiveListNotifer::eventsChanged signal, which is emitted when the events changed. This is very coarse, at it doesn't differentiate between signal addition / editing / deletion. We might want to be finer in the future. Catch the signal in the profile-widget to replot the dive if this is the currently displayed dive. Reuse the cylindersChanged() slot, but rename it to the now more appropriate profileChanged(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--commands/command_event.cpp2
-rw-r--r--core/subsurface-qt/divelistnotifier.h3
-rw-r--r--profile-widget/profilewidget2.cpp5
-rw-r--r--profile-widget/profilewidget2.h2
4 files changed, 9 insertions, 3 deletions
diff --git a/commands/command_event.cpp b/commands/command_event.cpp
index ea35402e4..d945fbb02 100644
--- a/commands/command_event.cpp
+++ b/commands/command_event.cpp
@@ -23,6 +23,7 @@ void AddEventBase::redo()
eventToRemove = eventToAdd.get();
add_event_to_dc(dc, eventToAdd.release()); // return ownership to backend
invalidate_dive_cache(d);
+ emit diveListNotifier.eventsChanged(d);
}
void AddEventBase::undo()
@@ -32,6 +33,7 @@ void AddEventBase::undo()
eventToAdd.reset(eventToRemove); // take ownership of event
eventToRemove = nullptr;
invalidate_dive_cache(d);
+ emit diveListNotifier.eventsChanged(d);
}
AddEventBookmark::AddEventBookmark(struct dive *d, int dcNr, int seconds) :
diff --git a/core/subsurface-qt/divelistnotifier.h b/core/subsurface-qt/divelistnotifier.h
index 2a72cdf49..63355fbcc 100644
--- a/core/subsurface-qt/divelistnotifier.h
+++ b/core/subsurface-qt/divelistnotifier.h
@@ -113,6 +113,9 @@ signals:
void numShownChanged();
void filterReset();
+ // Event-related signals. Currently, we're very blunt: only one signal for any changes to the events.
+ void eventsChanged(dive *d);
+
// This signal is emited every time a command is executed.
// This is used to hide an old multi-dives-edited warning message.
// This is necessary, so that the user can't click on the "undo" button and undo
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 67962b3bb..54881f71a 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -170,7 +170,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
connect(DivePictureModel::instance(), &DivePictureModel::rowsInserted, this, &ProfileWidget2::plotPictures);
connect(DivePictureModel::instance(), &DivePictureModel::picturesRemoved, this, &ProfileWidget2::removePictures);
connect(DivePictureModel::instance(), &DivePictureModel::modelReset, this, &ProfileWidget2::plotPictures);
- connect(&diveListNotifier, &DiveListNotifier::cylinderEdited, this, &ProfileWidget2::cylinderChanged);
+ connect(&diveListNotifier, &DiveListNotifier::cylinderEdited, this, &ProfileWidget2::profileChanged);
+ connect(&diveListNotifier, &DiveListNotifier::eventsChanged, this, &ProfileWidget2::profileChanged);
#endif // SUBSURFACE_MOBILE
#if !defined(QT_NO_DEBUG) && defined(SHOW_PLOT_INFO_TABLE)
@@ -2189,7 +2190,7 @@ void ProfileWidget2::removePictures(const QVector<QString> &fileUrls)
calculatePictureYPositions();
}
-void ProfileWidget2::cylinderChanged(dive *d)
+void ProfileWidget2::profileChanged(dive *d)
{
if (!d || d->id != displayed_dive.id)
return; // Cylinders of a differnt dive than the shown one changed.
diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h
index 0c1db3f62..4f60bf885 100644
--- a/profile-widget/profilewidget2.h
+++ b/profile-widget/profilewidget2.h
@@ -118,7 +118,7 @@ slots: // Necessary to call from QAction's signals.
void pointInserted(const QModelIndex &parent, int start, int end);
void pointsRemoved(const QModelIndex &, int start, int end);
void updateThumbnail(QString filename, QImage thumbnail, duration_t duration);
- void cylinderChanged(dive *d);
+ void profileChanged(dive *d);
/* this is called for every move on the handlers. maybe we can speed up this a bit? */
void recreatePlannedDive();