Files
xtree.ng.zwo/items/xqitemtype.h
2025-08-13 18:30:47 +02:00

87 lines
2.4 KiB
C++

/***************************************************************************
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 XQITEMTYPE_H
#define XQITEMTYPE_H
#include <QDebug>
#include <QMap>
#include <xqitem.h>
///
/// Ist das Unsinn!? Einfach ein QStandardItem mit data() nehmen?
/// Ok, das erspart die die attribs, aber wo ist der fette gewinn?
/// statt _editorType = x hast Du dann halt setData( QVariant::fromValue<>(x) );
/// Aber: Du kannst T abbilden auf QString ... und dann
///
using XQItemTypeMap = QMap<QString, XQItemType*>;
//class XQItemType : public QObject
class XQItemType : public XQItem// public QObject
{
//
//Q_OBJECT
// wäre auch eine möglichkeit !?
//Q_PROPERTY(XQItem::RenderStyle renderStyle renderStyle getDate WRITE setrenderStyle )
public:
XQItemType();
XQItemType( const XQItemType& other);
virtual ~XQItemType();
QVariant data( int role ) const override;
void setData(const QVariant& value, int role ) override;
// FIX! Das gehört hier nicht her!
QString formatToSI(const QString& rawText ) const;
QString unFormatFromSI(const QString& valueText ) const;
void replaceAttribute( XQItem* item, const QVariant& newValue, int role );
QString makeItemTypeKey();
//static XQItemType* storeItemType( XQItemType* protoType );
static XQItemType* staticItemType();
protected:
static XQItemTypeMap s_ItemTypeMap;
static size_t s_ItemTypeCount;
/*
static void setItemType( XQItem* item, RenderStyle renderStyle, Qt::ItemFlags flags, UnitType unitType, const QString& format );
static void setStaticType( XQItem* item );
*/
// fix __ch
// static void setItemType( XQItem* item, const QString& renderStyle, const QString& unitType, const QString& itemTypeID );
//static XQItemType* addItemType( const QString& key, RenderStyle renderStyle, UnitType unitType);
//static XQItemType* makeItemType( RenderStyle renderStyle, UnitType unitType);
};
Q_DECLARE_METATYPE(XQItemType*);
#endif // XQITEMTYPE_H