diff --git a/src/application/xqmainmodel.cpp b/src/application/xqmainmodel.cpp index 745dc5c..1a423ae 100644 --- a/src/application/xqmainmodel.cpp +++ b/src/application/xqmainmodel.cpp @@ -59,9 +59,12 @@ XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode ) { 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.makeContentItem( contentNode, section.sheetRootNode ); + XQItem* newTreeentry = _itemFactory.makeTreeChildItem( contentNode, section.sheetRootNode ); section.headerItem().appendRow( newTreeentry ); _treeTable->expand( section.modelIndex ); // ?? diff --git a/src/application/xqmainwindow.cpp b/src/application/xqmainwindow.cpp index c71320f..73f56b7 100644 --- a/src/application/xqmainwindow.cpp +++ b/src/application/xqmainwindow.cpp @@ -23,7 +23,7 @@ #include -//! firz +//! konstruktor. XQMainWindow::XQMainWindow( QWidget* parent ) : QMainWindow(parent) @@ -34,7 +34,7 @@ XQMainWindow::XQMainWindow( QWidget* parent ) } -//! firz +//! actions & document struktur einrichten. void XQMainWindow::initMainWindow() { @@ -67,6 +67,7 @@ void XQMainWindow::initMainWindow() connect( _mainTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(onTreeItemClicked(QModelIndex)) ); connect( _tabWidget, SIGNAL(tabBarClicked(int)), this, SLOT(onTabClicked(int)) ); + connect( &_mainModelView, &XQViewModel::xqItemCreated, this, [=, this](XQItem* item) { // when a new main tree item has been created ... @@ -102,7 +103,7 @@ void XQMainWindow::initMainWindow() } -//! firz +//! slot für zentrales undo void XQMainWindow::onUndo() { @@ -113,14 +114,13 @@ void XQMainWindow::onUndo() } -//! +//! slot für zentrales redo void XQMainWindow::onRedo() { qDebug() << " --- redo Pressed"; if(_undoStack.canRedo()) _undoStack.redo(); - } @@ -214,8 +214,9 @@ void XQMainWindow::onAbout() } -//! firz -// when item in the left tree is clicked, switch view on the right side +//! wenn ein item im navigations-baum geklickt wird, soll die document +//! view rechts angepasst werden. + void XQMainWindow::onTreeItemClicked(const QModelIndex& index ) { @@ -234,8 +235,8 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index ) } -//! firz -// when item in the left tree is clicked, switch view on the right side +//! beim click auf ein tab im linken fenster wird der navigationsbaum angepasst. + void XQMainWindow::onTabClicked( int index ) { const QString& key = _documentStore[index].treeItem->attribute( c_ProjectID ); @@ -293,8 +294,10 @@ void XQMainWindow::loadDocument( const QString& fileName ) // read the model data childModel->setContent( contentRoot->first_child() ); + // create new entry in the left side main tree view - XQItem* newEntry = _mainModelView.createTreeEntry( contentRoot ); + + XQItem* newEntry = _mainModelView.createTreeEntry( contentRoot ); _mainTreeView->setCurrentIndex( newEntry->index() ); _documentStore.addDocument( fileName, pTitle, newEntry, childModel ); diff --git a/src/items/xqitemfactory.cpp b/src/items/xqitemfactory.cpp index afdc0ec..bf75e5e 100644 --- a/src/items/xqitemfactory.cpp +++ b/src/items/xqitemfactory.cpp @@ -115,20 +115,6 @@ XQNodePtr XQItemFactory::findModelSheet( const QString& modelName ) const } -XQItem* XQItemFactory::makeContentItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry ) -{ - // den itemtype des neuen items rausfinden - QString typeKey = sheetEntry->attribute("ItemType"); - //XQItemType* itemType = findItemTypeTemplate(typeKey); // throws - XQItemType* itemType = makeItemType(sheetEntry); // throws - - const QString* contentPtr = contentNode->attribute_ptr( sheetEntry->tag_name() ); - - XQItem* newItem = new XQItem( itemType, contentPtr ); - - return newItem; -} - XQItem* XQItemFactory::makeHeaderItem( const XQNodePtr& sheetEntry ) { @@ -140,15 +126,42 @@ XQItem* XQItemFactory::makeHeaderItem( const XQNodePtr& sheetEntry ) // den itemtype des neuen items rausfinden QString typeKey = sheetEntry->attribute("HeaderItemType"); - XQItemType* itemType = findItemTypeTemplate(typeKey); // throws + //XQItemType* itemType = makeItemType(sheetEntry); // throws + XQItemType* itemType = findItemTypeTemplate(typeKey); // das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung const QString* contentPtr = sheetEntry->attribute_ptr("HeaderCaption"); - XQItem* newHeaderItem = new XQItem( itemType, contentPtr ); + return new XQItem( itemType, contentPtr ); - return newHeaderItem; } +XQItem* XQItemFactory::makeContentItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry ) +{ + // den itemtype des neuen items rausfinden + QString typeKey = sheetEntry->attribute("ItemType"); + //XQItemType* itemType = findItemTypeTemplate(typeKey); // throws + XQItemType* itemType = makeItemType(sheetEntry); // throws + + const QString* contentPtr = contentNode->attribute_ptr( sheetEntry->tag_name() ); + + return new XQItem( itemType, contentPtr ); + +} + + +XQItem* XQItemFactory::makeTreeChildItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry ) +{ + // den itemtype des neuen items rausfinden + QString typeKey = sheetEntry->attribute("ItemType"); + XQItemType* itemType = findItemTypeTemplate(typeKey); // throws + //XQItemType* itemType = makeItemType(sheetEntry); // throws + + const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" ); + + XQItem* newItem = new XQItem( itemType, contentPtr ); + + return newItem; +} void XQItemFactory::setItemDataFromString( XQItem& item, const QString& roleKey, const QString& source ) const { diff --git a/src/items/xqitemfactory.h b/src/items/xqitemfactory.h index 8934e70..8829d13 100644 --- a/src/items/xqitemfactory.h +++ b/src/items/xqitemfactory.h @@ -34,6 +34,7 @@ public: XQItem* makeHeaderItem(const XQNodePtr& typeSheetNode ); XQItem* makeContentItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry ); + XQItem* makeTreeChildItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry ); virtual XQItemList makeHeaderRow( const XQNodePtr& sheetNode ); virtual XQItemList makeContentRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ); diff --git a/src/nodes/znode.h b/src/nodes/znode.h index 88f930c..199034f 100644 --- a/src/nodes/znode.h +++ b/src/nodes/znode.h @@ -224,6 +224,7 @@ namespace znode return nullptr; } + //! hängt einen knoten an meine kinderliste an. int add_child( const zshared_node& node ) { _children.push_back( node ); diff --git a/xml/modeldata1.xtr b/xml/modeldata1.xtr index b44a6a9..7b62e47 100644 --- a/xml/modeldata1.xtr +++ b/xml/modeldata1.xtr @@ -1,6 +1,6 @@ - + diff --git a/xml/modelsheets.xml b/xml/modelsheets.xml index 91076e0..2fe8536 100644 --- a/xml/modelsheets.xml +++ b/xml/modelsheets.xml @@ -7,16 +7,16 @@ --> + + + - - - - + - - - + + + + + + + + + + +