25class ChangeQObjectPropertyCommand :
public QUndoCommand
28 ChangeQObjectPropertyCommand (
30 QString property_name,
32 : object_ (
object), property_name_ (property_name),
33 original_value_ (
object.property (property_name.toLatin1 ().data ())),
34 value_ (std::move (value))
36 setText (QObject::tr (
"Change %1").arg (property_name_));
39 int id ()
const override {
return 1762957285; }
40 bool mergeWith (
const QUndoCommand * other)
override
42 if (other->id () != id ())
47 const auto * other_cmd =
48 dynamic_cast<const ChangeQObjectPropertyCommand *
> (other);
49 const auto cur_time = std::chrono::steady_clock::now ();
50 const auto duration = cur_time - last_redo_timestamp_;
52 std::chrono::duration_cast<std::chrono::milliseconds> (duration).count ()
60 &object_ != &other_cmd->object_
61 || property_name_ != other_cmd->property_name_)
64 last_redo_timestamp_ = cur_time;
65 value_ = other_cmd->value_;
71 object_.setProperty (property_name_.toLatin1 ().data (), original_value_);
76 object_.setProperty (property_name_.toLatin1 ().data (), value_);
77 last_redo_timestamp_ = std::chrono::steady_clock::now ();
82 QString property_name_;
83 QVariant original_value_;
85 std::chrono::time_point<std::chrono::steady_clock> last_redo_timestamp_;