From f74c004bf9f125cfdf82797d3d3b267ab5ebdb2e Mon Sep 17 00:00:00 2001 From: "PANIK\\chris" Date: Sun, 28 Sep 2025 14:15:18 +0200 Subject: [PATCH] Moved child row creation to XQItemFactory, some other cleanups. --- src/application/xqchildmodel.cpp | 39 ++++---------------------------- src/application/xqchildmodel.h | 1 - src/application/xqmainwindow.cpp | 6 ++--- src/items/xqitemfactory.cpp | 22 +++++++++++++----- src/items/xqitemfactory.h | 3 ++- src/model/xqviewmodel.cpp | 2 -- xml/modelsheets.xml | 15 ++++++------ 7 files changed, 32 insertions(+), 56 deletions(-) diff --git a/src/application/xqchildmodel.cpp b/src/application/xqchildmodel.cpp index 0e8921e..828a744 100644 --- a/src/application/xqchildmodel.cpp +++ b/src/application/xqchildmodel.cpp @@ -88,48 +88,17 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot ) // Die Beschreibungen für die optionalen Kinder // steck im ersten Knoten des Model-Sheets if( !sheetNode->first_child()->has_children() ) - { - qDebug() << " --- no sheet node for children"; continue; - } - addSectionChildren( list.front(), sheetNode->first_child(), contentEntry ); + + XQItemList childList = _itemFactory.makeRow( sheetNode, contentEntry ); + // als kinder einfügen + list.front()->appendRow( childList ); } } // for } -void XQChildModel::addSectionChildren( QStandardItem* parent, const XQNodePtr& sheetNode, const XQNodePtr& contentEntry ) -{ - qDebug() << " --- AddModelData: CHILD Found for: :" << contentEntry->to_string() << " sheet parent: " << sheetNode->tag_name(); - for (const auto& contentChild : contentEntry->children()) - { - const QString& contentKey = contentChild->tag_name(); - qDebug() << " --- Na Hopp1: " << contentChild->to_string() << " -> " <to_string(); - // wir brauchen ein beschreibenden sheetnode für diesen content-child knoten - if( sheetNode->has_child( contentKey )) - { - const XQNodePtr& sheetChild = sheetNode->child(contentKey); - qDebug() << " --- Na Also: " << sheetChild->to_string(); - - - for( const auto& sheetX : sheetChild->children() ) - { - qDebug() << " --- --- sheetX: " << sheetX->to_string(); - } - - - XQItemList list = _itemFactory.makeRow( sheetChild, contentChild ); - //insertRow( parent->row()+1, list ); - parent->appendRow( list ); - - } - - } - -} - //! erzeugt ein adhoc-contextmenu, je nachdem welche aktionen gerade möglich sind. diff --git a/src/application/xqchildmodel.h b/src/application/xqchildmodel.h index 1ce3f0a..dff21ce 100644 --- a/src/application/xqchildmodel.h +++ b/src/application/xqchildmodel.h @@ -31,7 +31,6 @@ public: void addModelData(const XQNodePtr& contentRoot ); void addSectionEntry( const QString& key, const XQNodePtr& contentEntry ); - void addSectionChildren(QStandardItem* parent, const XQNodePtr& sheetNode, const XQNodePtr& contentEntry ); protected: diff --git a/src/application/xqmainwindow.cpp b/src/application/xqmainwindow.cpp index 391b3d1..697f123 100644 --- a/src/application/xqmainwindow.cpp +++ b/src/application/xqmainwindow.cpp @@ -118,7 +118,7 @@ void XQMainWindow::initMainWindow() // #2. load demo data loadDocument( c_DocumentFileName1 ); //loadDocument( c_DocumentFileName2, true ); - //loadDocument( c_DocumentFileName2 ); + loadDocument( c_DocumentFileName2 ); //loadDocument( c_DocumentFileName3 ); @@ -260,7 +260,6 @@ void XQMainWindow::onTreeViewItemClicked( const XQItem& item ) void XQMainWindow::onTreeViewItemChanged(const XQItem& item ) { - qDebug() << " --- TREE VIEW itemChanged: text" << item.text() << " parent: " << item.parent()->text() << " type: " << item.itemType().text() << " : " << (void*)&_mainModel << " : " << (void*) sender(); // hier müssen wir erst das projekt aktivieren XQItem* xqItem = static_cast(item.parent()); onTreeViewItemClicked( *xqItem ); @@ -268,8 +267,7 @@ void XQMainWindow::onTreeViewItemChanged(const XQItem& item ) { int idx = _tabWidget->currentIndex(); if(_documentStore.contains(idx) ) - { - qDebug() << " --- Has Document and might toggle: " << item.text(); + { XQViewModel& childModel = *_documentStore[idx].viewModel; childModel.onToggleSection(item.text()); } diff --git a/src/items/xqitemfactory.cpp b/src/items/xqitemfactory.cpp index 137575a..75cd5cc 100644 --- a/src/items/xqitemfactory.cpp +++ b/src/items/xqitemfactory.cpp @@ -167,13 +167,23 @@ XQItemList XQItemFactory::makeRow(const XQNodePtr& sheetNode, const XQNodePtr& c return list; } -XQItemList XQItemFactory::makeChildRow( XQItem* parent, const XQNodePtr& sheetNode, const XQNodePtr& contentNode ) -{ - Q_UNUSED(parent); - Q_UNUSED(sheetNode); - Q_UNUSED(contentNode); - return XQItemList(); +//! Erzeugt kind-items zu einem section-eintrag. + +XQItemList XQItemFactory::makeChildRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ) +{ + XQItemList list; + for (const auto& contentChild : contentNode->children()) + { + const QString& contentKey = contentChild->tag_name(); + // wir brauchen ein beschreibenden sheetnode für diesen content-child knoten + if( sheetNode->has_child( contentKey )) + { + const XQNodePtr& sheetChild = sheetNode->child(contentKey); + list = makeRow( sheetChild, contentChild ); + } + } + return list; } //! Erzeugt ein XQItem aus einer typ-beschreibung ('sheetNode') und einem daten-knoten ('contentNode'). diff --git a/src/items/xqitemfactory.h b/src/items/xqitemfactory.h index 59636f8..a93cc1c 100644 --- a/src/items/xqitemfactory.h +++ b/src/items/xqitemfactory.h @@ -32,8 +32,9 @@ public: XQNodePtr findModelSheet( const QString& modelName ) const; + // __fix auf nicht vorhandenen content felder prüfen! vereinheitlichen! XQItemList makeRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); - XQItemList makeChildRow( XQItem* parent, const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); + XQItemList makeChildRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); XQItem* makeSingleItem( const XQNodePtr& sheetNode, const QString& caption ); void setItemTypeDataFromString( XQItem& item, const QString& roleKey, const QString& source ) const; diff --git a/src/model/xqviewmodel.cpp b/src/model/xqviewmodel.cpp index 99262aa..cd471af 100644 --- a/src/model/xqviewmodel.cpp +++ b/src/model/xqviewmodel.cpp @@ -182,8 +182,6 @@ void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sheetNode void XQViewModel::onToggleSection(const QString& sectionKey ) { - qDebug() << " --- Model: " << this->objectName() << " should toggle: " << sectionKey << ": " << _sections.hasValidSection( sectionKey ); - _sections.dump(); if(_sections.hasValidSection( sectionKey ) ) toggleSection( _sections.sectionByKey(sectionKey) ); } diff --git a/xml/modelsheets.xml b/xml/modelsheets.xml index 6e95e94..73f87d0 100644 --- a/xml/modelsheets.xml +++ b/xml/modelsheets.xml @@ -15,6 +15,7 @@ + @@ -121,17 +122,17 @@ - - - + + + - - + + - - + +