diff --git a/src/application/xqmainmodel.cpp b/src/application/xqmainmodel.cpp index 1fdfac1..d8d0b2c 100644 --- a/src/application/xqmainmodel.cpp +++ b/src/application/xqmainmodel.cpp @@ -52,10 +52,13 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode ) if( contentNode->attribute( c_ContentType) == section.contentType() ) { - const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" ); + const QString& content = contentNode->attribute( "ProjectName" ); // __fixme! das ist mist! const XQNodePtr sheetNode = section.sheetRootNode()->first_child(); - XQItem* newItem = _itemFactory.makeItem(sheetNode, contentPtr ); + XQItem* newItem = _itemFactory.makeItem(sheetNode, content ); + // erzeuger sheet node speichern + newItem->setSheetNode( sheetNode ); + // den neuen eintrag in die passende section der übersicht eintragen ... section.headerItem().appendRow( newItem ); // ... ausklappen... @@ -64,9 +67,7 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode ) // ... und markieren _treeTable->setCurrentIndex( index ); // quellknoten auch speichern - newItem->setContentNode( contentNode ); - // erzeuger sheet node speichern - newItem->setSheetNode( sheetNode ); + //newItem->setContentNode( contentNode ); //emit itemCreated( newItem ); return newItem; @@ -81,18 +82,7 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode ) void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem ) { XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection"); - XQItem* newItem = _itemFactory.makeItem(sheetNode, §ion.contentType() ); + XQItem* newItem = _itemFactory.makeItem(sheetNode, section.contentType() ); projectItem->appendRow( newItem ); _treeTable->expand( projectItem->index() ); } - - -/* -XQItem* XQMainModel::addSectionItem( XQItem* projectItem ) -{ - const XQNodePtr& parentSheet = projectItem->sheetNode(); - const XQNodePtr sheetNode = parentSheet->first_child(); - return _itemFactor.makeItem( sheetNode, new QString("fitz!")); - -} -*/ diff --git a/src/items/xqitem.cpp b/src/items/xqitem.cpp index 3a890fd..ebaae85 100644 --- a/src/items/xqitem.cpp +++ b/src/items/xqitem.cpp @@ -341,7 +341,7 @@ void XQItem::setUnitType(UnitType unitType) QString XQItem::content() const { - // umleitung auf text() + // umleitung auf raw text return data( Qt::EditRole ).toString(); } diff --git a/src/items/xqitemfactory.cpp b/src/items/xqitemfactory.cpp index 5729be3..0e01f54 100644 --- a/src/items/xqitemfactory.cpp +++ b/src/items/xqitemfactory.cpp @@ -77,7 +77,6 @@ bool XQItemFactory::isValid() XQItemType* XQItemFactory::makeItemType(const XQNodePtr& sheetEntry ) { QString typeKey = sheetEntry->attribute( c_ItemType ); - XQItemType* itemType = findItemTypeTemplate(typeKey); // wir prüfen, ob im sheetEntry noch zusätzliche attribute vorhanden @@ -266,17 +265,18 @@ QVariant XQItemFactory::makeVariant( int dataRole, const QString& source ) const XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ) { + // 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 - const QString* contentPtr{}; // das ist Unterschied vom HeaderItem zum normalen Item: Der Titel kommt aus der Modelbeschreibung if(!contentNode) - contentPtr = sheetNode->attribute_ptr(c_Caption); - else - // der content wird indirect über den tag-name des sheetnode geholt - contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() ); + return makeItem( sheetNode, sheetNode->attribute(c_Caption) ); + // der content wird indirect über den tag-name des sheetnode geholt + const QString* contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() ); return makeItem( sheetNode, contentPtr ); } @@ -284,10 +284,7 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& co 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! @@ -299,6 +296,19 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const QString* cont return newItem; } +XQStaticItem* XQItemFactory::makeStaticItem( const XQNodePtr& sheetNode, const QString& content ) +{ + XQItemType* itemType = makeItemType(sheetNode); // throws + XQStaticItem* newItem = new XQStaticItem( itemType, content ); + // __fixme! + if( newItem->isCheckable() ) + { + newItem->setCheckState( Qt::Checked ); + } + return newItem; + +} + //! erzeugt eine item-row. diff --git a/src/items/xqitemfactory.h b/src/items/xqitemfactory.h index 5fb2ba3..68cbfda 100644 --- a/src/items/xqitemfactory.h +++ b/src/items/xqitemfactory.h @@ -32,8 +32,9 @@ public: XQNodePtr findModelSheet( const QString& modelName ) const; - XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); - XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr ); + XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); + XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr ); + XQStaticItem* makeStaticItem( const XQNodePtr& sheetNode, const QString& contentPtr ); XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); //XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );