From a9dacca684442d0155f3deab285582127bb89f7e Mon Sep 17 00:00:00 2001 From: "PANIK\\chris" Date: Sat, 6 Sep 2025 11:08:07 +0200 Subject: [PATCH] Fixed toggleSection --- src/application/xqmainwindow.cpp | 2 +- src/model/xqsectionmanager.cpp | 4 ++-- src/model/xqviewmodel.cpp | 24 ++++++++++++++---------- src/xtree.pro | 1 + xml/modeldata2.xtr | 6 +++--- xml/modeldata3.xtr | 2 +- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/application/xqmainwindow.cpp b/src/application/xqmainwindow.cpp index a6d2748..bd8ba14 100644 --- a/src/application/xqmainwindow.cpp +++ b/src/application/xqmainwindow.cpp @@ -320,7 +320,7 @@ void XQMainWindow::onSectionCreated( const XQModelSection& section ) void XQMainWindow::onSectionToggled( const XQModelSection& section ) { - //qDebug() << " --- XXX section toggled: " << section.contentType() << ":" << section.sheetRootNode()->to_string(); + qDebug() << " --- XXX section toggled: " << section.contentType() << ":" << section.sheetRootNode()->to_string(); } void XQMainWindow::setChildTabByName( const QString& key ) diff --git a/src/model/xqsectionmanager.cpp b/src/model/xqsectionmanager.cpp index b546a87..7c5928b 100644 --- a/src/model/xqsectionmanager.cpp +++ b/src/model/xqsectionmanager.cpp @@ -172,9 +172,9 @@ int XQSectionManager::lastRow(const XQModelSection& section ) const { // last section? return last row of model if (index == _sections.size() - 1) - return section.startIndex().model()->rowCount() - 1; + return section.startIndex().model()->rowCount();// - 1; // return row above the row of the next section -> last row of given section - return _sections.at(index+1).firstRow() - 1; + return _sections.at(index+1).firstRow();// - 1; } return -1; } diff --git a/src/model/xqviewmodel.cpp b/src/model/xqviewmodel.cpp index 14ee63f..1b37dd4 100644 --- a/src/model/xqviewmodel.cpp +++ b/src/model/xqviewmodel.cpp @@ -152,22 +152,22 @@ void XQViewModel::initModel(const QString& modelName) //! Wrzeugt dann eine section aus einer frisch erzeugten itemlist. Der erste modelindex //! der liste und der root knoten der model-beschreibung werden gespeichert. -void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sectionNode ) +void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sheetNode ) { // 1. die liste darf nicht leer sein Q_ASSERT(!list.isEmpty()); - // 2. sectionNode muss da sein - Q_ASSERT(sectionNode); + // 2. sheetNode muss da sein + Q_ASSERT(sheetNode); // 3. 'ContenType' muss vorhanden sein - if( !sectionNode->has_attribute( c_ContentType) ) + if( !sheetNode->has_attribute( c_ContentType) ) throw XQException( "section list: Section node needs attribute 'ContentType'!"); // 5. das erzeugt dann auch valide indices appendRow(list); - const QString §ionKey = sectionNode->attribute(c_ContentType); + const QString §ionKey = sheetNode->attribute(c_ContentType); // 6. jetzt können wir auch die sction erzeugen - const XQModelSection& section = _sections.createSection( sectionKey, list[0]->index(), sectionNode ); + const XQModelSection& section = _sections.createSection( sectionKey, list[0]->index(), sheetNode ); // ... und es der welt mitteilen. emit sectionCreated( section ); @@ -193,10 +193,11 @@ void XQViewModel::toggleSection( const XQModelSection& section ) XQSectionRange pos = _sections.sectionRange(section); //int fstRow = _sections.firstRow(index); //int lstRow = _sections.lastRow(index); - //_treeTable->toggleRowsHidden(fstRow, lstRow); + _treeTable->toggleRowsHidden(pos.firstRow, pos.lastRow ); + qDebug() << " --- toggleSection: " << section.contentType(); // hier nicht!? - //emit sectionToggled(section); + emit sectionToggled(section); } } @@ -441,7 +442,7 @@ void XQViewModel::cmdDelete( const XQCommand& command ) // ... 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(); + qDebug() << " --- delete: " << firstItem.text() << " " << firstItem.row(); // jetzt löschen entry.contentNode->unlink_self(); removeRow(entry.itemPos ); @@ -452,7 +453,10 @@ void XQViewModel::cmdDelete( const XQCommand& command ) void XQViewModel::cmdDeleteUndo( const XQCommand& command ) { - + for (const auto& entry : command) + { + qDebug() << " --- delete UNDo: " << entry.contentNode->to_string(); + } } diff --git a/src/xtree.pro b/src/xtree.pro index abde6c3..fa5a243 100644 --- a/src/xtree.pro +++ b/src/xtree.pro @@ -2,6 +2,7 @@ QT += core gui widgets quick quickwidgets # widgets-private CONFIG += c++20 qmltypes +CONFIG -= qml_debug QML_IMPORT_NAME = org.sourceworx.qmlcomponents QML_IMPORT_MAJOR_VERSION = 1 diff --git a/xml/modeldata2.xtr b/xml/modeldata2.xtr index b2fa088..5dd4c6d 100644 --- a/xml/modeldata2.xtr +++ b/xml/modeldata2.xtr @@ -4,9 +4,9 @@ - - - + + + diff --git a/xml/modeldata3.xtr b/xml/modeldata3.xtr index f7c783b..1816ed8 100644 --- a/xml/modeldata3.xtr +++ b/xml/modeldata3.xtr @@ -1,6 +1,6 @@ - +