first reCommit
This commit is contained in:
121
model/xqcommand.h
Normal file
121
model/xqcommand.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/***************************************************************************
|
||||
|
||||
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 <QUndoCommand>
|
||||
#include <xqitem.h>
|
||||
#include <xqsimpleclipboard.h>
|
||||
|
||||
class XQModel;
|
||||
|
||||
struct XQSavedNode
|
||||
{
|
||||
int itemPos{-1};
|
||||
int nodePos{-1};
|
||||
XQNodePtr contentNode;
|
||||
};
|
||||
|
||||
class XQSavedNodesList : public QVector<XQSavedNode>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
void dumpSavedNodesList( const QString& title="" );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Holds command type marker and involed data items.
|
||||
*/
|
||||
|
||||
class XQCommand : public QUndoCommand
|
||||
{
|
||||
|
||||
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 );
|
||||
|
||||
/*
|
||||
const QModelIndexList& indexList() const;
|
||||
void setIndexList( const QModelIndexList& list );
|
||||
XQNodeList& nodeList();
|
||||
*/
|
||||
|
||||
XQSavedNodesList& savedNodesList();
|
||||
void saveNodes( const QModelIndexList& list );
|
||||
void clearSavedNodes();
|
||||
|
||||
void redo() override;
|
||||
void undo() override;
|
||||
|
||||
QString toString();
|
||||
|
||||
protected:
|
||||
|
||||
CmdType _cmdType{cmdInvalid};
|
||||
XQModel* _modelView{}; // needed for redo() / undo()
|
||||
QModelIndex _originIndex;
|
||||
XQSavedNodesList _posList;
|
||||
|
||||
/*
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user