summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_edit.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-01-28 22:35:07 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit42cfd3f9638a5f9d37e51285e6d1eaaad3e78501 (patch)
treeda20dbdfd7358638df99a20eab392cf894f9d609 /desktop-widgets/command_edit.cpp
parent512a2e6b684e237c5e6aacd3cba42fb7d2093e0a (diff)
downloadsubsurface-42cfd3f9638a5f9d37e51285e6d1eaaad3e78501.tar.gz
Undo: implement undo of rating and visibility rating
This was rather trivial and modeled after the previous edit UndoCommands. Since this is the first time we're editing integers a new constructor instantiation had to be added. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_edit.cpp')
-rw-r--r--desktop-widgets/command_edit.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/desktop-widgets/command_edit.cpp b/desktop-widgets/command_edit.cpp
index 80113dbdc..0480378b8 100644
--- a/desktop-widgets/command_edit.cpp
+++ b/desktop-widgets/command_edit.cpp
@@ -68,6 +68,8 @@ void EditBase<T>::undo()
// class by virtue of a "using" declaration.
template
EditBase<QString>::EditBase(const QVector<dive *> &dives, QString oldValue, QString newValue);
+template
+EditBase<int>::EditBase(const QVector<dive *> &dives, int oldValue, int newValue);
// Undo and redo do the same as just the stored value is exchanged
template<typename T>
@@ -122,6 +124,48 @@ DiveField EditSuit::fieldId() const
return DiveField::SUIT;
}
+// ***** Rating *****
+void EditRating::set(struct dive *d, int value) const
+{
+ d->rating = value;
+}
+
+int EditRating::data(struct dive *d) const
+{
+ return d->rating;
+}
+
+QString EditRating::fieldName() const
+{
+ return tr("rating");
+}
+
+DiveField EditRating::fieldId() const
+{
+ return DiveField::RATING;
+}
+
+// ***** Visibility ****
+void EditVisibility::set(struct dive *d, int value) const
+{
+ d->visibility = value;
+}
+
+int EditVisibility::data(struct dive *d) const
+{
+ return d->visibility;
+}
+
+QString EditVisibility::fieldName() const
+{
+ return tr("visibility");
+}
+
+DiveField EditVisibility::fieldId() const
+{
+ return DiveField::VISIBILITY;
+}
+
// ***** Mode *****
// Editing the dive mode has very peculiar semantics for historic reasons:
// Since the dive-mode depends on the dive computer, the i-th dive computer