#ifndef FIELDEDITCOMMAND_H #define FIELDEDITCOMMAND_H #include #include #include #include /** * @brief QUndoCommand for field value edits in ScriptTypeEditorWidget * * Stores old and new values for a field, allowing undo/redo of edits. * Uses callbacks to apply values since the actual application logic * is in the editor widget. */ class FieldEditCommand : public QUndoCommand { public: using ApplyCallback = std::function; FieldEditCommand(int journalId, const QString& fieldName, const QVariant& oldValue, const QVariant& newValue, ApplyCallback applyCallback, QUndoCommand* parent = nullptr); void undo() override; void redo() override; int id() const override; bool mergeWith(const QUndoCommand* other) override; QString fieldName() const { return m_fieldName; } int journalId() const { return m_journalId; } private: int m_journalId; QString m_fieldName; QVariant m_oldValue; QVariant m_newValue; ApplyCallback m_applyCallback; bool m_firstRedo = true; // Skip first redo since value is already applied }; #endif // FIELDEDITCOMMAND_H