added some comments.

This commit is contained in:
2025-08-06 16:44:08 +02:00
parent 87de9c1f33
commit f41b00d8ff
5 changed files with 90 additions and 44 deletions

View File

@@ -27,12 +27,11 @@ void XQNodeStore::dumpList( const QString& title ) const
XQCommand::XQCommand(CmdType cmdType, XQModel* modelView )
: _cmdType{ cmdType }, _modelView(modelView)
: _cmdType{ cmdType }, _model(modelView)
{
}
XQCommand::~XQCommand()
{
qDebug() << " --- command destructor: " << toString();
@@ -49,22 +48,34 @@ void XQCommand::setCommandType( XQCommand::CmdType cmdType )
_cmdType = cmdType;
}
//! ruft 'onCommandRedo' 'meines' models auf.
void XQCommand::redo()
{
_modelView->onCommandRedo( *this );
_model->onCommandRedo( *this );
}
//! ruft 'onCommandUndo' 'meines' models auf.
void XQCommand::undo()
{
_modelView->onCommandUndo( *this );
_model->onCommandUndo( *this );
}
//! gibt den urpsrungs-index dieses commands zurück.
const QModelIndex& XQCommand::originIndex() const
{
return _originIndex;
}
//! merkt sich den ersten QModelIndex der von diesem command
//! betroffenen items. zusätzlich wird der command-text erzeugt.
void XQCommand::setOriginIndex( const QModelIndex& origin )
{
QString cmdText("%1: %2 (%3)");
@@ -78,17 +89,24 @@ void XQCommand::setOriginIndex( const QModelIndex& origin )
}
//! erzeugt aus den 'selected indices' eine liste mit der jewiligen knotenposition,
//! der item-zeile und dem content-knoten.
void XQCommand::saveNodes( const QModelIndexList& list )
{
clear();
// über jede zeil
for( auto entry : list )
{
XQNodePtr contentNode = XQItem::xqItemFromIndex( entry ).contentNode();
// im command speichern wir den original knoten, nicht eine kopie, wie im clipboard.
// knoten holen
const XQNodePtr& contentNode = XQItem::xqItemFromIndex( entry ).contentNode();
// hier speichern wir den original knoten, nicht einen clone, wie im clipboard.
push_back( {entry.row(), contentNode->own_pos(), contentNode } );
}
}
//! erzeugt einen string aus dem command-type, fürs debuggen.
QString XQCommand::toString()
{