Files
xtree.old.ng/src/items/xqitemfactory.h

68 lines
2.0 KiB
C
Raw Normal View History

2025-08-05 22:39:41 +02:00
/* **************************************************************************
source::worx xtree
Copyright © 2024-2025 c.holzheuer
christoph.holzheuer@gmail.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
***************************************************************************/
#ifndef XQITEMFACTORY_H
#define XQITEMFACTORY_H
#include <xqitem.h>
#include <xqitemtype.h>
#include <functional>
2025-08-07 03:11:56 +02:00
class XQViewModel;
2025-08-05 22:39:41 +02:00
// erzeugt items aus XQNodes
class XQItemFactory : public xsingleton<XQItemFactory>
{
public:
void initItemFactory(const QString& modelSheetFileName );
XQNodePtr findModelSheet( const QString& modelName ) const;
2025-08-12 23:41:36 +02:00
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr );
2025-08-15 20:31:40 +02:00
2025-08-14 19:13:53 +02:00
XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
2025-08-05 22:39:41 +02:00
// wozu ist das gut?
2025-08-14 19:13:53 +02:00
//XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
2025-08-05 22:39:41 +02:00
void setItemDataFromString( XQItem& item, const QString& roleKey, const QString& source ) const;
2025-08-09 11:56:11 +02:00
XQItemType* makeItemType(const XQNodePtr& sheetEntry );
XQItemType* findItemTypeTemplate(const QString& key ) const;
2025-08-05 22:39:41 +02:00
QVariant makeVariant(int dataRole, const QString &value ) const;
protected:
bool isValid();
// shortcuts
using ItemConfigFunc = std::function<void( XQItem* item, const QString& attrValue, XQNodePtr contentNode, XQNodePtr sheetNode )>;
using ItemConfigMap = QMap<QString,ItemConfigFunc>;
2025-08-09 11:56:11 +02:00
XQItemTypeMap s_ItemTypeTemplates;
2025-08-05 22:39:41 +02:00
// Beschreibung des XQModels
XQNodePtr _modelSheet{};
// Beschreibung der ItemTypes
XQNodePtr _typesSheet{};
};
#endif // XQITEMFACTORY_H