Completed cmdNew implementation.
This commit is contained in:
@@ -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 );
|
||||
|
||||
|
@@ -60,6 +60,7 @@ public:
|
||||
|
||||
//little helpers
|
||||
const XQItem& xqRootItem();
|
||||
XQNodePtr contentRootNode();
|
||||
|
||||
XQItem& xqItemFromIndex(const QModelIndex& index) const;
|
||||
XQItem& xqFirstItem(int row) const;
|
||||
|
Reference in New Issue
Block a user