diff --git a/src/application/xqmainwindow.cpp b/src/application/xqmainwindow.cpp index 04cb49e..7951779 100644 --- a/src/application/xqmainwindow.cpp +++ b/src/application/xqmainwindow.cpp @@ -123,8 +123,8 @@ void XQMainWindow::initMainWindow() _mainModelView.initModel( c_MainModelName ); // #2. load demo data - loadDocument( c_DocumentFileName1 ); - loadDocument( c_DocumentFileName2 ); + //loadDocument( c_DocumentFileName1 ); + //loadDocument( c_DocumentFileName2 ); qDebug() << " --- all here: " << XQNode::s_Count; @@ -261,6 +261,10 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index ) _mainTreeView->selectionModel()->select(index, QItemSelectionModel::Select); //entry.setBackground( QBrush( Qt::green ) ); + QVariant variant = entry.QStandardItem::data( XQItem::ContentNodeRole ); + + XQNodePtr ptr = variant.value(); + QString key = entry.attribute(c_ProjectID); qDebug() << " --- FIRZ: key: " << key; diff --git a/src/items/xqitemfactory.cpp b/src/items/xqitemfactory.cpp index 79a900c..409861f 100644 --- a/src/items/xqitemfactory.cpp +++ b/src/items/xqitemfactory.cpp @@ -303,6 +303,25 @@ XQItemList XQItemFactory::createGenericRow( const XQNodePtr& contentNode, const */ + +//! erzeugt eine header-item row. + +XQItemList XQItemFactory::makeHeaderRow( const XQNodePtr& sheetNode ) +{ + + XQItemList list; + + for( const auto& sheetEntry : sheetNode->children() ) + { + list.append( makeHeaderItem( sheetEntry ) ); + } + + Q_ASSERT(!list.empty()); + + return list; +} + + //! erzeugt eine item-row. XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ) @@ -321,20 +340,37 @@ XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNo // for( const auto& sheetEntry : sheetNode->children() ) - { - list.append( makeItem( sheetEntry, contentNode ) ); + { + list.append( makeContentItem( sheetEntry, contentNode ) ); } - if( !list.empty() ) - { - // wir merken uns den original content node auch, aber - // im ersten Item. - dynamic_cast(list[0])->setContentNode(contentNode); - } + Q_ASSERT(!list.empty()); + + // wir merken uns den original content node auch, aber + // im ersten Item. + dynamic_cast(list[0])->setContentNode(contentNode); return list; } + +XQItem* XQItemFactory::makeHeaderItem( const XQNodePtr& sheetNode ) +{ + // den itemtype des neuen items rausfinden + XQItemType* itemType = makeItemType(sheetNode); // throws + + // das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung + // der content wird indirect über den tag-name des sheetnode geholt + + XQItem* newItem = new XQItem( itemType, sheetNode->attribute_ptr(c_Caption) ); + + // __fixme! + if( newItem->isCheckable() ) + newItem->setCheckState( Qt::Checked ); + + return newItem; +} + //! 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 diff --git a/src/items/xqitemfactory.h b/src/items/xqitemfactory.h index fadad24..dd8d5db 100644 --- a/src/items/xqitemfactory.h +++ b/src/items/xqitemfactory.h @@ -34,12 +34,12 @@ public: //XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ); - // wozu ist das gut? - //XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ); + XQItemList makeHeaderRow( const XQNodePtr& sheetNode ); XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); - XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); - XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr ); + // wozu ist das gut? + //XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ); + XQStaticItem* makeStaticItem( const XQNodePtr& sheetNode, const QString& contentPtr ); @@ -53,6 +53,12 @@ protected: bool isValid(); + XQItem* makeHeaderItem( const XQNodePtr& sheetNode ); + XQItem* makeContentItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); + + XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); + XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr ); + // shortcuts using ItemConfigFunc = std::function; using ItemConfigMap = QMap; diff --git a/src/model/xqviewmodel.cpp b/src/model/xqviewmodel.cpp index 4b6dfdf..e188895 100644 --- a/src/model/xqviewmodel.cpp +++ b/src/model/xqviewmodel.cpp @@ -107,8 +107,8 @@ void XQViewModel::initModel(const QString& modelName) // #2: (optionalen?) header erzeugen const XQNodePtr header = sectionNode->find_child_by_tag_name( c_Header ); if( header ) - { - XQItemList list = _itemFactory.makeContentRow( header, nullptr ); + { + XQItemList list = _itemFactory.makeHeaderRow( header ); addSection(list, sectionNode ); }