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

@@ -255,52 +255,47 @@ void XQModel::onCommandUndo( XQCommand& command )
// undo-/redo-able stuff
/**
* @brief XQModel::cmdCutRows Cut the rows whose positions have been store in the command.
* @param command
*/
//! markierte knoten entfernen, 'command' enthält die liste
void XQModel::cmdCut( XQCommand& command )
{
// wir gehen rückwärts über alle gemerkten knoten ...
for (auto it = command.rbegin(); it != command.rend(); ++it)
{
// ... holen das erste item, das auch den content node enthält
const XQNodeBackup& entry = *it;
XQItem& firstItem = xqFirstItem( (*it).itemPos );
qDebug() << " --- Cut: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id;
//const XQNodeBackup& entry = *it;
//XQItem& firstItem = xqFirstItem( (*it).itemPos );
//qDebug() << " --- Cut: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id;
// jetzt löschen, dabei wird die parent-verbindung entfernt
const XQNodeBackup& entry = *it;
entry.contentNode->unlink_self();
removeRow(entry.itemPos );
}
}
// clone to clipboard, remove items
//! entfernte knoten aus wieder einfügen , 'command' enthält die liste
void XQModel::cmdCutUndo( XQCommand& command )
{
command.dumpList("UNDO Cut");
_sections.dump();
int xx = command.first().itemPos;
const XQModelSection& section = _sections.sectionFromRow( xx );
// die anfangsposition
int itmPos = command.first().itemPos;
// die 'zuständige' section rausfinden
const XQModelSection& section = _sections.sectionFromRow( itmPos );
// über alle einträge ...
for (auto& entry : command )
{
XQNodePtr savedNode = entry.contentNode;
// __fix! should not bee _contentRoot!
savedNode->add_me_at( entry.nodePos, _contentRoot );
const XQNodePtr& savedNode = entry.contentNode;
// __fix! should not be _contentRoot!
savedNode->add_me_at( entry.nodePos, _contentRoot );
XQItemList list = _itemFactory.makeContentRow( savedNode, section.sheetRootNode );
XQItem& firstItem = *((XQItem*)list[0]);
qDebug() << " --- Cut Undo: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id;
qDebug() << " --- Cut Undo: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id << " count: " << entry.contentNode.use_count();
insertRow( entry.itemPos, list );
}
}
//! clipboard inhalte einfügen
void XQModel::cmdPaste( XQCommand& command )
{
// selection holen ...
@@ -320,11 +315,19 @@ void XQModel::cmdPaste( XQCommand& command )
// wir pasten das clipboard
for (auto& entry : _clipBoard )
{
//
// siehe! und es war schrott!
//
// das ist ein clon
XQNodePtr savedNode = entry.contentNode;
// der wir hier rein gelinkt
XQItemList list = _itemFactory.makeContentRow( savedNode, section.sheetRootNode );
// wir klonen den knoten aus dem clipbord
savedNode->clone(section.contentRootNode )->add_me_at( nodePos );
insertRow( insRow, list );
const QModelIndex& selIdx = list[0]->index();
_treeView->selectionModel()->select(selIdx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
// zur nächsten zeile