Completed cmdNew implementation.

This commit is contained in:
2025-09-04 14:56:18 +02:00
parent f8bd0886d3
commit 89c5fd21f1
5 changed files with 45 additions and 42 deletions

View File

@@ -69,7 +69,14 @@ const XQItem& XQViewModel::xqRootItem()
// dynamisch über den ItemData Mechanismus wie in QStandardItem
return *static_cast<XQItem*>(invisibleRootItem());
}
//! Gibt den daten root node des models zurück.
XQNodePtr XQViewModel::contentRootNode()
{
return _contentRoot;
}
@@ -431,20 +438,18 @@ void XQViewModel::cmdDeleteUndo( const XQCommand& command )
void XQViewModel::cmdNew( const XQCommand& command )
{
const QModelIndex& origin = command.originIndex();
XQItem& target = xqItemFromIndex( origin );
// current data node
XQNodePtr node = target.contentNode();
qDebug() << " --- node own pos: " << node->own_pos();
// we create a new data node
XQNodePtr newNode = XQNode::make_node( node->tag_name(), node->tag_value(), node->parent() );
// store node in node->parent()
//node->add_before_me( newNode );
newNode->add_me_at( node->own_pos(), node->parent() );
// store node also in 'command' to enable undo
const XQModelSection& section = _sections.sectionFromIndex( origin );

View File

@@ -60,6 +60,7 @@ public:
//little helpers
const XQItem& xqRootItem();
XQNodePtr contentRootNode();
XQItem& xqItemFromIndex(const QModelIndex& index) const;
XQItem& xqFirstItem(int row) const;