Added new-undo == delete

This commit is contained in:
2025-09-04 17:01:01 +02:00
parent 89c5fd21f1
commit 5d2fb1b378
8 changed files with 116 additions and 84 deletions

View File

@@ -180,6 +180,28 @@ void XQViewModel::onToggleSection(const QString& sectionKey )
qDebug() << " --- onToggleSection: " << sectionKey;
}
void XQViewModel::toggleSection( const XQModelSection& section )
{
if(_treeTable)
{
const QModelIndex& index = section.persistentModelIndex();
qDebug() << " ---- toggle section: FIRZ: " << index.isValid() << " : " << index.data().toString() << " : " << section.contentType();//_sections.keyOf( sec );
int fstRow = _sections.firstRow( index );
int lstRow = _sections.lastRow( index );
_treeTable->toggleRowsHidden(fstRow, lstRow );
emit sectionToggled( section );
}
emit sectionToggled( section );
}
void XQViewModel::toggleSection( const QString& sectionKey )
{
}
/*
//! SLOT als weiterleitung vom SIGNAL itemchanged
@@ -447,50 +469,33 @@ void XQViewModel::cmdNew( const XQCommand& command )
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() );
XQNodePtr newNode = XQNode::make_node( node->tag_name(), node->tag_value() );
// store node in node->parent()
newNode->add_me_at( node->own_pos(), node->parent() );
// store node also in 'command' to enable undo
//...
const XQModelSection& section = _sections.sectionFromIndex( origin );
// create new item row
// neue, leere zeile erzeugen ...
XQItemList list =_itemFactory.makeRow( section.sheetRootNode(), newNode );
// add it to the treeview ...
// ... zur treeview hinzufügen ...
insertRow( origin.row(), list );
// ... and make it ...
treeTable()->setCurrentIndex( list[0]->index() );
// ... editable
treeTable()->edit( list[0]->index() );
// ... editierbar machen ...
QModelIndex newIndex = list[0]->index();
treeTable()->setCurrentIndex( newIndex );
treeTable()->edit( newIndex );
// ,,, und fürs undo speichern
const_cast<XQCommand&>(command).saveNodes( {newIndex} );
}
void XQViewModel::toggleSection( const XQModelSection& section )
{
if(_treeTable)
{
const QModelIndex& index = section.persistentModelIndex();
qDebug() << " ---- toggle section: FIRZ: " << index.isValid() << " : " << index.data().toString() << " : " << section.contentType();//_sections.keyOf( sec );
int fstRow = _sections.firstRow( index );
int lstRow = _sections.lastRow( index );
_treeTable->toggleRowsHidden(fstRow, lstRow );
emit sectionToggled( section );
}
emit sectionToggled( section );
}
void XQViewModel::toggleSection( const QString& sectionKey )
{
}
//! entfernt die neu angelegte zeile.
void XQViewModel::cmdNewUndo( const XQCommand& command )
{
cmdDelete( command );
}

View File

@@ -84,7 +84,7 @@ public:
Derzeit wird die default-implementierung von data/setData genutzt. hier wäre dann die
Stelle um setData & data an externe 'handler' umzubiegen, siehe giovannies 'model-injection'
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override
{
return QStandardItemModel::data( index, role );
}