diff --git a/src/data/action/value.cpp b/src/data/action/value.cpp index b60471b0..99fdddbf 100644 --- a/src/data/action/value.cpp +++ b/src/data/action/value.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include // for ValueActionPerformer @@ -25,8 +26,14 @@ String ValueAction::getName(bool to_undo) const { return _ACTION_1_("change", valueP->fieldP->name); } +void ValueAction::perform(bool to_undo) { + if (card) { + swap(const_cast(card)->time_modified, old_time_modified); + } +} + void ValueAction::isOnCard(Card* card) { - const_cast(this)->card = card; + this->card = card; } // ----------------------------------------------------------------------------- : Simple @@ -52,6 +59,7 @@ class SimpleValueAction : public ValueAction { {} virtual void perform(bool to_undo) { + ValueAction::perform(to_undo); swap_value(static_cast(*valueP), new_value); valueP->onAction(*this, to_undo); // notify value } @@ -95,6 +103,7 @@ TextValueAction::TextValueAction(const TextValueP& value, size_t start, size_t e String TextValueAction::getName(bool to_undo) const { return name; } void TextValueAction::perform(bool to_undo) { + ValueAction::perform(to_undo); swap_value(value(), new_value); swap(selection_end, new_selection_end); valueP->onAction(*this, to_undo); // notify value @@ -197,6 +206,7 @@ String TextToggleReminderAction::getName(bool to_undo) const { } void TextToggleReminderAction::perform(bool to_undo) { + ValueAction::perform(to_undo); TextValue& value = static_cast(*valueP); String& val = value.value.mutate(); assert(pos + 4 < val.size()); diff --git a/src/data/action/value.hpp b/src/data/action/value.hpp index f70a3847..0374367b 100644 --- a/src/data/action/value.hpp +++ b/src/data/action/value.hpp @@ -36,15 +36,20 @@ DECLARE_POINTER_TYPE(PackageChoiceValue); /// An Action the changes a Value class ValueAction : public Action { public: - inline ValueAction(const ValueP& value) : valueP(value), card(nullptr) {} + inline ValueAction(const ValueP& value) + : valueP(value), card(nullptr), old_time_modified(wxDateTime::Now()) + {} virtual String getName(bool to_undo) const; + virtual void perform(bool to_undo); /// We know that the value is on the given card, add that information void isOnCard(Card* card); const ValueP valueP; ///< The modified value const Card* card; ///< The card the value is on, or null if it is not a card value + private: + wxDateTime old_time_modified; }; // ----------------------------------------------------------------------------- : Simple