From c870ef88014db3541b55b899907a63b95ea620a5 Mon Sep 17 00:00:00 2001 From: "PANIK\\chris" Date: Mon, 18 Aug 2025 21:09:57 +0200 Subject: [PATCH] sections in treeview. --- src/application/xqmainmodel.cpp | 17 ++++++++++++++--- src/application/xqmainmodel.h | 3 +-- src/application/xqmainwindow.cpp | 20 ++++++++++++-------- src/items/xqitemfactory.cpp | 3 +-- xml/modelsheets.xml | 6 +++--- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/application/xqmainmodel.cpp b/src/application/xqmainmodel.cpp index d244624..f467420 100644 --- a/src/application/xqmainmodel.cpp +++ b/src/application/xqmainmodel.cpp @@ -63,11 +63,11 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode ) _treeTable->expand( index ); // ... und markieren _treeTable->setCurrentIndex( index ); - // den gesamten projekt knoten speichern, warum? - //newItem->setContentNode(contentNode); + // quellknoten auch speichern + newItem->setContentNode( contentNode ); // erzeuger sheet node speichern newItem->setSheetNode( sheetNode ); - emit itemCreated( newItem ); + //emit itemCreated( newItem ); return newItem; @@ -78,6 +78,17 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode ) throw XQException( "addProjectItem: main model should not be empty!" ); } +void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem ) +{ + //XQNodePtr sheetNode = projectParent->sheetNode(); + //XQItem* newItem = _itemFactory.makeItem(sheetNode, contentPtr ); + XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection"); + XQItem* newItem = _itemFactory.makeItem(sheetNode, §ion.contentType() ); + projectItem->appendRow( newItem ); + _treeTable->expand( projectItem->index() ); +} + + /* XQItem* XQMainModel::addSectionItem( XQItem* projectItem ) { diff --git a/src/application/xqmainmodel.h b/src/application/xqmainmodel.h index 79ecf28..3b05002 100644 --- a/src/application/xqmainmodel.h +++ b/src/application/xqmainmodel.h @@ -33,8 +33,7 @@ public: virtual ~XQMainModel() = default; XQItem* addProjectItem( XQNodePtr contentNode ); - -public slots: + void addSectionItem( const XQModelSection& section, XQItem* projectItem ); protected: diff --git a/src/application/xqmainwindow.cpp b/src/application/xqmainwindow.cpp index 1193f2e..cfa8f5b 100644 --- a/src/application/xqmainwindow.cpp +++ b/src/application/xqmainwindow.cpp @@ -124,7 +124,7 @@ void XQMainWindow::initMainWindow() // #2. load demo data loadDocument( c_DocumentFileName1 ); - //loadDocument( c_DocumentFileName2 ); + loadDocument( c_DocumentFileName2 ); qDebug() << " --- all here: " << XQNode::s_Count; @@ -259,12 +259,17 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index ) qDebug() << " --- mainWindow onTreeItemClicked:" << entry.text(); - return; - //_mainTreeView->selectionModel()->select(index, QItemSelectionModel::Select); - //entry->setBackground( QBrush( Qt::green ) ); + + _mainTreeView->selectionModel()->select(index, QItemSelectionModel::Select); + entry.setBackground( QBrush( Qt::green ) ); QString key = entry.attribute(c_ProjectID); - if( _documentStore.contains(key) ) + qDebug() << " --- FIRZ: key: " << key; + + + bool isThere = _documentStore.contains(key); + if( isThere) + _tabWidget->setCurrentWidget( _documentStore[key].modelView->treeTable() ); } @@ -283,14 +288,13 @@ void XQMainWindow::onSectionCreated( const XQModelSection& section ) { if( _currentProjectItem ) { - ; + _mainModelView.addSectionItem( section, _currentProjectItem ); } - qDebug() << " --- XXX section created: " << section.contentType() << ":" << section.contentType(); } 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(); } //! liest eine XML datei namens 'fileName' diff --git a/src/items/xqitemfactory.cpp b/src/items/xqitemfactory.cpp index 1c4d254..5729be3 100644 --- a/src/items/xqitemfactory.cpp +++ b/src/items/xqitemfactory.cpp @@ -270,7 +270,7 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& co // der content wird indirect über den tag-name des sheetnode geholt const QString* contentPtr{}; - // das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung + // das ist Unterschied vom HeaderItem zum normalen Item: Der Titel kommt aus der Modelbeschreibung if(!contentNode) contentPtr = sheetNode->attribute_ptr(c_Caption); else @@ -293,7 +293,6 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const QString* cont // __fixme! if( newItem->isCheckable() ) { - //qDebug() << " --- yooo: " << newItem->toolTip(); newItem->setCheckState( Qt::Checked ); } diff --git a/xml/modelsheets.xml b/xml/modelsheets.xml index 99c80bc..3c966aa 100644 --- a/xml/modelsheets.xml +++ b/xml/modelsheets.xml @@ -9,13 +9,13 @@ - - + + - +