/*************************************************************************** source::worx xtree Copyright © 2024-2025 c.holzheuer christoph.holzheuer@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ***************************************************************************/ #ifndef XQCOMMAND_H #define XQCOMMAND_H #include #include class XQModel; struct XQNodeBackup { int itemPos{-1}; int nodePos{-1}; XQNodePtr contentNode; }; //! //! \brief The XQNodeStore class //! class XQNodeStore : public QVector { public: void dumpList( const QString& title="" ) const; virtual void saveNodes( const QModelIndexList& list ) = 0; }; //! Das command enthält immer auch die betroffenen items //! ist also auch ein node store class XQCommand : public QUndoCommand, public XQNodeStore { public: enum CmdType { cmdInvalid, cmdUndo, cmdRedo, cmdTextEdit, cmdCut, cmdPaste, cmdPasteSelf, cmdCopy, cmdMove, cmdNew, cmdDelete, cmdToggleSection, cmdExtern //?? }; XQCommand(CmdType cmdType, XQModel* modelView ); virtual ~XQCommand(); CmdType commandType() const; void setCommandType( CmdType cmdType ); const QModelIndex& originIndex() const; void setOriginIndex( const QModelIndex& origin ); void saveNodes( const QModelIndexList& list ) override; void redo() override; void undo() override; QString toString(); protected: CmdType _cmdType{cmdInvalid}; XQModel* _model{}; // needed for redo() / undo() QModelIndex _originIndex; /* Du hast den item editor vergessen, Du Honk! NTCompositeModel* m_pModel; QModelIndex m_index; QVariant m_value; QVariant m_oldValue; bool m_updateIndex; */ }; Q_DECLARE_METATYPE(XQCommand::CmdType); #endif // XQCOMMAND_H