From 372873717edcc86934516fce969b5a42679d3412 Mon Sep 17 00:00:00 2001 From: "PANIK\\chris" Date: Sun, 17 Aug 2025 11:50:26 +0200 Subject: [PATCH] adding projects to project tree works again. --- src/application/xqappdata.h | 2 +- src/application/xqmainmodel.cpp | 42 +++++++++++++++----------------- src/application/xqmainmodel.h | 2 +- src/application/xqmainwindow.cpp | 15 +++++++++--- src/items/xqitemfactory.cpp | 21 ++++++++++++---- src/items/xqitemfactory.h | 6 ++--- src/model/xqmodelsectionlist.cpp | 2 +- src/xtree.pro | 5 +++- xml/modelsheets.xml | 26 ++++++++++---------- 9 files changed, 69 insertions(+), 52 deletions(-) diff --git a/src/application/xqappdata.h b/src/application/xqappdata.h index b84be83..8c3c88d 100644 --- a/src/application/xqappdata.h +++ b/src/application/xqappdata.h @@ -29,7 +29,7 @@ const QString c_ItemType = "ItemType"; const QString c_Caption = "Caption"; const QString c_Header = "Header"; const QString c_ContentType = "ContentType"; -const QString c_Data = "Data"; +const QString c_ModelSheet = "ModelSheet"; const QString c_MainModelName = "DocumentTreeModel"; const QString c_ChildModelName = "DocumentDetailsModel"; diff --git a/src/application/xqmainmodel.cpp b/src/application/xqmainmodel.cpp index 25dcf65..1e62c17 100644 --- a/src/application/xqmainmodel.cpp +++ b/src/application/xqmainmodel.cpp @@ -43,40 +43,36 @@ void XQMainModel::initContextMenu() //! erzeugt einen eintrag in der baum-übersicht. -XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode ) +XQItem* XQMainModel::makeTreeItem( XQNodePtr contentNode ) { - + // wir durchsuchen alle unsere section nach dem passenden content-type, + // hier: content-type beschreibt die for(const auto& section : _sections ) { - qDebug() << " --- wtf1: " << contentNode->to_string(); - qDebug() << " --- wtf2: " << section.sheetRootNode()->to_string(); - /* - if( contentNode->attribute("State") == section.sheetRootNode->attribute("State") ) - { - //XQItem* newTreeentry = _itemFactory.makeTreeChildItem( contentNode, section.sheetRootNode ); - makeTreeChildItem: - // den itemtype des neuen items rausfinden - QString typeKey = sheetEntry->attribute("ItemType"); - XQItemType* itemType = findItemTypeTemplate(typeKey); // throws - //XQItemType* itemType = makeItemType(sheetEntry); // throws + if( contentNode->attribute( c_ContentType) == section.contentType() ) + { + + qDebug() << " --- wtf1: " << contentNode->to_string(); + qDebug() << " --- wtf2: " << section.sectionRootNode()->to_string(); + qDebug() << " --- wtf3: " << section.sheetRootNode()->to_string(); const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" ); + // __fixme! das ist mist! + XQItem* newItem = _itemFactory.makeItem(section.sheetRootNode()->child(0), contentPtr ); - XQItem* newItem = new XQItem( itemType, contentPtr ); + section.headerItem().appendRow( newItem ); + _treeTable->expand( section.modelIndex() ); + // ?? + _treeTable->setCurrentIndex( section.modelIndex() ); + newItem->setContentNode(contentNode); + emit itemCreated( newItem ); return newItem; - section.headerItem().appendRow( newTreeentry ); - _treeTable->expand( section.modelIndex ); - // ?? - _treeTable->setCurrentIndex( section.modelIndex ); - newTreeentry->setContentNode(contentNode); - emit xqItemCreated( newTreeentry ); - return newTreeentry; } - */ + } - throw XQException( "createTreeEntry: main model should not be empty!" ); + throw XQException( "makeTreeItem: main model should not be empty!" ); } diff --git a/src/application/xqmainmodel.h b/src/application/xqmainmodel.h index 443b7dd..355207d 100644 --- a/src/application/xqmainmodel.h +++ b/src/application/xqmainmodel.h @@ -32,7 +32,7 @@ public: explicit XQMainModel(QObject *parent = nullptr); virtual ~XQMainModel() = default; - XQItem* createTreeEntry( XQNodePtr contentNode ); + XQItem* makeTreeItem( XQNodePtr contentNode ); public slots: diff --git a/src/application/xqmainwindow.cpp b/src/application/xqmainwindow.cpp index 2a6c85b..5a9a088 100644 --- a/src/application/xqmainwindow.cpp +++ b/src/application/xqmainwindow.cpp @@ -15,12 +15,14 @@ #include #include #include +#include #include #include #include #include #include +#include //! konstruktor. @@ -91,7 +93,13 @@ void XQMainWindow::initMainWindow() connect( _tabWidget, SIGNAL(tabBarClicked(int)), this, SLOT(onTabClicked(int)) ); - +/* + XQQuickWidget* butt = new XQQuickWidget; + butt->resize(800,600); + butt->setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint); + butt->move( 1200,300); + butt->show(); +*/ /* connect( &_mainModelView, &XQViewModel::itemCreated, this, [=, this](XQItem* item) @@ -324,15 +332,14 @@ void XQMainWindow::loadDocument( const QString& fileName ) connect( childModel, SIGNAL(sectionCreated(XQModelSection)), this, SLOT(onSectionCreated(XQModelSection)) ); connect( childModel, SIGNAL(sectionToggled(XQModelSection)), this, SLOT(onSectionToggled(XQModelSection)) ); - // Den globalen undo-stack ... childModel->setUndoStack(&_undoStack); // und die TreeView übergeben childModel->setTreeTable(childTreeView); - // create new entry in the left side main tree view - //XQItem* newEntry = _mainModelView.createTreeEntry( contentRoot ); + // neuen eintrag im übsichts-baum erzeugen + XQItem* newEntry = _mainModelView.makeTreeItem( contentRoot ); //_mainTreeView->setCurrentIndex( newEntry->index() ); //_documentStore.addDocument( fileName, pTitle, newEntry, childModel ); diff --git a/src/items/xqitemfactory.cpp b/src/items/xqitemfactory.cpp index 76b95fa..1c4d254 100644 --- a/src/items/xqitemfactory.cpp +++ b/src/items/xqitemfactory.cpp @@ -259,17 +259,16 @@ QVariant XQItemFactory::makeVariant( int dataRole, const QString& source ) const /// +//! fixme! unsinn! //! erzeugt ein XQItem aus einer typ-beschreibung ('sheetNode') und einem daten-knoten ('contentNode'). //! wenn der content node nicht gesetzt ist, wird stattdess das attribut 'Caption' aus der typ-beschreibung //! verwendet: es handelt sich dann um ein header item, das erzeugt wurde. XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ) { - // den itemtype des neuen items rausfinden - QString typeKey = sheetNode->attribute(c_ItemType); + // das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung + // der content wird indirect über den tag-name des sheetnode geholt - XQItemType* itemType = makeItemType(sheetNode); // throws - // fallunterscheidung beim inhalt: const QString* contentPtr{}; // das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung if(!contentNode) @@ -278,7 +277,20 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& co // der content wird indirect über den tag-name des sheetnode geholt contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() ); + return makeItem( sheetNode, contentPtr ); +} + + +XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const QString* contentPtr ) +{ + // den itemtype des neuen items rausfinden + QString typeKey = sheetNode->attribute(c_ItemType); + + XQItemType* itemType = makeItemType(sheetNode); // throws + XQItem* newItem = new XQItem( itemType, contentPtr ); + + // __fixme! if( newItem->isCheckable() ) { //qDebug() << " --- yooo: " << newItem->toolTip(); @@ -286,7 +298,6 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& co } return newItem; - } diff --git a/src/items/xqitemfactory.h b/src/items/xqitemfactory.h index 3376be5..5fb2ba3 100644 --- a/src/items/xqitemfactory.h +++ b/src/items/xqitemfactory.h @@ -30,10 +30,10 @@ public: void initItemFactory(const QString& modelSheetFileName ); - XQNodePtr findModelSheet( const QString& modelName ) const; - - XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode=nullptr); + XQNodePtr findModelSheet( const QString& modelName ) const; + XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); + XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr ); XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); //XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ); diff --git a/src/model/xqmodelsectionlist.cpp b/src/model/xqmodelsectionlist.cpp index c645e41..3f6d83b 100644 --- a/src/model/xqmodelsectionlist.cpp +++ b/src/model/xqmodelsectionlist.cpp @@ -60,7 +60,7 @@ XQNodePtr XQModelSection::sectionRootNode() const XQNodePtr XQModelSection::sheetRootNode() const { - return _sectionRootNode->find_child_by_tag_name( c_Data ); + return _sectionRootNode->find_child_by_tag_name( c_ModelSheet ); } diff --git a/src/xtree.pro b/src/xtree.pro index 00a8b87..252e2a4 100644 --- a/src/xtree.pro +++ b/src/xtree.pro @@ -1,4 +1,4 @@ -QT += core gui widgets +QT += core gui widgets quick quickwidgets # widgets-private CONFIG += c++20 @@ -43,6 +43,7 @@ HEADERS += \ util/xsingleton.h \ util/xtreewalker.h \ widgets/xqcontextmenu.h \ + widgets/xqquickwidget.h \ widgets/xqtreetable.h SOURCES += \ @@ -67,6 +68,7 @@ SOURCES += \ pugixml/pugixml.cpp \ util/xqexception.cpp \ widgets/xqcontextmenu.cpp \ + widgets/xqquickwidget.cpp \ widgets/xqtreetable.cpp @@ -82,6 +84,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target DISTFILES += \ + ../quick/xqmodelview.qml \ README.md \ xml/modelsheets.xml \ xml/modeldata1.xtr \ diff --git a/xml/modelsheets.xml b/xml/modelsheets.xml index d8aea64..d152b27 100644 --- a/xml/modelsheets.xml +++ b/xml/modelsheets.xml @@ -26,25 +26,25 @@
- + - +
- + - +
- + - +
@@ -65,7 +65,7 @@ - + @@ -77,7 +77,7 @@ - +
@@ -90,15 +90,15 @@ - + - + - +
@@ -111,7 +111,7 @@ - + @@ -119,7 +119,7 @@ - +