invented creation-mode for items

This commit is contained in:
2025-08-23 19:33:29 +02:00
parent 3a5fbad33e
commit e0a50bade4
9 changed files with 44 additions and 32 deletions

View File

@@ -305,7 +305,7 @@ XQItemList XQItemFactory::createGenericRow( const XQNodePtr& contentNode, const
//! erzeugt eine item-row.
XQItemList XQItemFactory::makeRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
XQItemList XQItemFactory::makeRow(CreationMode mode, const XQNodePtr& sheetNode, const XQNodePtr& contentNode, const QString& captionKey )
{
XQItemList list;
@@ -321,7 +321,7 @@ XQItemList XQItemFactory::makeRow( const XQNodePtr& sheetNode, const XQNodePtr&
//
for( const auto& sheetEntry : sheetNode->children() )
list.append( makeItem( sheetEntry, contentNode ) );
list.append( makeItem( mode, sheetEntry, contentNode, captionKey ) );
Q_ASSERT(!list.empty());
@@ -338,19 +338,29 @@ XQItemList XQItemFactory::makeRow( const XQNodePtr& sheetNode, const XQNodePtr&
//! 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 )
XQItem* XQItemFactory::makeItem(CreationMode mode, const XQNodePtr& sheetNode, const XQNodePtr& contentNode, const QString& captionKey )
{
// den itemtype des neuen items rausfinden
XQItemType* itemType = makeItemType(sheetNode); // throws
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() );
// das ist Unterschied vom HeaderItem zum normalen Item: Der Titel kommt aus der Modelbeschreibung,
// sonst wird der content indirekt über den tag-name des sheetnode geholt
switch( mode )
{
case mHeader:
contentPtr = sheetNode->attribute_ptr(captionKey);
break;
case mData:
contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() );
break;
case mSingle:
contentPtr = contentNode->attribute_ptr( captionKey );
}
XQItem* newItem = new XQItem( itemType, contentPtr);

View File

@@ -28,13 +28,20 @@ class XQItemFactory : public xsingleton<XQItemFactory>
public:
enum CreationMode
{
mHeader,
mData,
mSingle
};
void initItemFactory(const QString& modelSheetFileName );
XQNodePtr findModelSheet( const QString& modelName ) const;
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
XQItemList makeRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
XQItemList makeRow( CreationMode mode, const XQNodePtr& sheetNode, const XQNodePtr& contentNode, const QString& captionKey=c_Caption );
// wozu ist das gut?
//XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
@@ -49,7 +56,7 @@ protected:
bool isValid();
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
XQItem* makeItem( CreationMode mode, const XQNodePtr& sheetNode, const XQNodePtr& contentNode, const QString& captionKey );
// shortcuts
using ItemConfigFunc = std::function<void( XQItem* item, const QString& attrValue, XQNodePtr contentNode, XQNodePtr sheetNode )>;