first commit, again.

This commit is contained in:
2025-08-22 22:57:06 +02:00
commit c8e59b10db
79 changed files with 24448 additions and 0 deletions

84
deprecated/reste.cpp Normal file
View File

@@ -0,0 +1,84 @@
XQItem* createTreeEntry( XQNodePtr contentNode );
//! erzeugt einen eintrag in der baum-übersicht.
XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode )
{
/*
for(const auto& section : _sections )
{
qDebug() << " --- wtf1: " << contentNode->to_string();
qDebug() << " --- wtf2: " << section.sheetRootNode->to_string();
if( contentNode->attribute("State") == section.sheetRootNode->attribute("State") )
{
//XQItem* newTreeentry = _itemFactory.makeTreeChildItem( contentNode, section.sheetRootNode );
makeTreeChildItem:
// den itemtype des neuen items rausfinden
QString typeKey = sheetEntry->attribute("ItemType");
XQItemType* itemType = findItemTypeTemplate(typeKey); // throws
//XQItemType* itemType = makeItemType(sheetEntry); // throws
const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" );
XQItem* newItem = new XQItem( itemType, contentPtr );
return newItem;
section.headerItem().appendRow( newTreeentry );
_treeTable->expand( section.modelIndex );
// ??
_treeTable->setCurrentIndex( section.modelIndex );
newTreeentry->setContentNode(contentNode);
emit xqItemCreated( newTreeentry );
return newTreeentry;
}
}
*/
throw XQException( "createTreeEntry: main model should not be empty!" );
}
<Section ContentType="Inverter">
<Header Marker="Inverter">
<InverterID Caption="Inverter" ItemType="HeaderType" />
<InverterName Caption="Name" ItemType="HeaderType" />
<Manufacturer Caption="Manufacturer" ItemType="HeaderType" />
<MaxPowerInput Caption="max. Input" ItemType="HeaderType" />
<MaxPowerOutput Caption="max Output" ItemType="HeaderType" />
<NumStrings Caption="Strings" ItemType="HeaderType" />
<Weight Caption="Weight" ItemType="HeaderType" />
</Header>
<Data>
<InverterID Caption="Inverter" ItemType="ValueType" />
<InverterName Caption="Name" ItemType="ValueType" />
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
<MaxPowerInput Caption="max. Input" ItemType="ValueType" ItemType="ChoiceType" ChoiceDataSource="MaxPowerInputChoice" UnitType="W"/>
<MaxPowerOutput Caption="max Output" ItemType="ValueType" UnitType="W"/>
<NumStrings Caption="Strings" ItemType="ValueType" />
<Weight Caption="Weight" ItemType="ValueType" UnitType="kg"/>
</Data>
</Section>
<Section ContentType="Battery">
<Header Marker="Battery">
<BatteryID Caption="Name" ItemType="HeaderType" />
<BatteryName Caption="Battery" ItemType="HeaderType" />
<Manufacturer Caption="Manufacturer" ItemType="HeaderType" />
<Capacity Caption="Capacity" ItemType="HeaderType"/>
<Yield Caption="Yield" ItemType="HeaderType" />
<MaxCurrent Caption="max. Current" ItemType="HeaderType" />
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
</Header>
<Data>
<BatteryID Caption="Battery" ItemType="ValueType" />
<BatteryName Caption="Name" ItemType="ValueType" />
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
<Capacity Caption="Capacity" ItemType="ValueType" UnitType="Wh"/>
<Yield Caption="Yield" ItemType="ValueType" ItemType="PercentageType" UnitType="%"/>
<MaxCurrent Caption="max. Current" ItemType="ValueType" UnitType="A"/>
<MaxVolt Caption="max. Volt" ItemType="ValueType" UnitType="V"/>
</Data>
</Section>

View File

@@ -0,0 +1,15 @@
/***************************************************************************
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.
***************************************************************************/
#include <xqgenericitem.h>

View File

@@ -0,0 +1,33 @@
/***************************************************************************
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 XQGENERICITEM_H
#define XQGENERICITEM_H
#include <xqitem.h>
//
// Was sollte das mal werden?
//
template<class T, class U>
class XQGenericItem : public XQItem, public T, public U
{
public:
XQGenericItem() = default;
};
#endif // XQGENERICITEM_H

29
deprecated/xqicon.cpp Normal file
View File

@@ -0,0 +1,29 @@
/***************************************************************************
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.
***************************************************************************/
#include <xqicon.h>
XQIcon::XQIcon()
{}
XQIcon::XQIcon( const QIcon& icon, const QString& iconKey )
: QIcon{icon}, _iconKey{iconKey}
{
}
const QString& XQIcon::iconKey()
{
return _iconKey;
}

35
deprecated/xqicon.h Normal file
View File

@@ -0,0 +1,35 @@
/***************************************************************************
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 XQICON_H
#define XQICON_H
#include <QIcon>
class XQIcon : public QIcon
{
public:
XQIcon();
XQIcon( const QIcon& icon, const QString& iconKey );
const QString& iconKey();
protected:
QString _iconKey;
};
#endif // XQICON_H

290
deprecated/xqitemtype.cpp Normal file
View File

@@ -0,0 +1,290 @@
/***************************************************************************
source::worx xtree
Copyright © 2024 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.
***************************************************************************/
//#include <cmath>
#include <xqitemtype.h>
#include <QDateTime>
#include <QDebug>
XQItemTypeMap XQItemType::s_ItemTypeMap;
///
/// XQItemType
///
XQItemType::XQItemType()
{
}
XQItemType::XQItemType( const XQItemType& other)
{
_renderStyle = other._renderStyle;
_editorType = other._editorType;
_itemFlags = other._itemFlags;
_unitType = other._unitType;
_contentFormat = other._contentFormat;
// wem gehören die dann? leck?
_fixedChoices = other._fixedChoices;
_typeIcon = other._typeIcon;
}
XQItemType::~XQItemType()
{
}
/*
XQItemType::XQItemType( RenderStyle aRenderStyle, EditorType aEditorType, Qt::ItemFlags aItemFlags, UnitType aUnitType, const QString& aContentFormat )
: renderStyle{aRenderStyle},
editorType{aEditorType},
itemFlags{aItemFlags},
unitType{aUnitType},
contentFormat{aContentFormat}
{
itemtypeKey = makeItemTypeKey(renderStyle,editorType,itemFlags,unitType,contentFormat);
};
*/
///
/// create attributes for from factory
///
void XQItemType::setAttribute(XQItem::RenderStyle renderStyle )
{
_renderStyle = renderStyle;
}
void XQItemType::setAttribute(XQItem::EditorType editorType )
{
_editorType = editorType;
}
void XQItemType::setAttribute(Qt::ItemFlags itemFlags )
{
_itemFlags = itemFlags;
}
void XQItemType::setAttribute(XQItem::UnitType unitType)
{
_unitType = unitType;
}
void XQItemType::setAttribute(const QString& contentFormat)
{
_contentFormat = contentFormat;
}
void XQItemType::setAttribute(QStandardItemModel *fixedChoices)
{
_fixedChoices = fixedChoices;
}
void XQItemType::setAttribute(const QIcon& typeIcon )
{
_typeIcon = typeIcon;
}
///
/// data() access for property sytem
///
XQItem::RenderStyle XQItemType::renderStyle() const
{
return _renderStyle;
}
XQItem::EditorType XQItemType::editorType() const
{
return _editorType;
}
XQItem::UnitType XQItemType::unitType() const
{
return _unitType;
}
const QString& XQItemType::contentFormat() const
{
return _contentFormat;
}
QStandardItemModel* XQItemType::fixedChoices() const
{
return _fixedChoices;
}
QString XQItemType::unitTypeStr() const
{
return XQItem::fetchUnitTypeStr( _unitType );
}
QString XQItemType::formatToSI( const QString& valueTxt ) const
{
/*
if( valueTxt.isEmpty() )
return valueTxt;
if( XQItem::ISODate == _unitType )
{
// format iso date
QDateTime dateTime = QDateTime::fromString(valueTxt, Qt::ISODate);
// fixme! make this configurable!
QString format = "dd.MM.yyyy HH:mm:ss"; // You can customize this format
// Format the QDateTime object into a human-readable string
return dateTime.toString(format);
}
QLocale sysLocale = QLocale::system();
sysLocale.setNumberOptions(sysLocale.numberOptions() | QLocale::OmitGroupSeparator);
double dVal = sysLocale.toDouble(valueTxt);
QString strVal, strPrefix;
int exp = (int)::log10f(dVal);
exp = (exp/3)*3;
double nVal = dVal;
if( !s_PrefixExponentMap.key(exp).isEmpty() )
nVal /= ::pow( 10,exp);
strVal = sysLocale.toString(nVal, 'f', 2);
strPrefix = s_PrefixExponentMap.key(exp);
//qDebug() << " convert: " << dVal << " : " << valueTxt << ": " << strVal << ":" << exp << " : " << strPrefix << ": " << nVal;
return QString("%1 %2%3").arg( strVal, strPrefix, unitTypeStr() );
*/
return "fitze!";
}
QString XQItemType::unFormatFromSI(const QString& formText ) const
{
/*
QString input = formText.simplified();
// #1: strip numeric part
if( input.isEmpty() )
return input;
int idx = 0;
for( auto c : input )
{
if( c.isNumber() || c.toLower() == 'e' || c == '.' || c == ',' ||c == '-' || c == '+' )
idx++;
else
break;
}
if(!idx)
return QString("0");
QString numPart = formText.left(idx);
QString unitPart;
//if(idx + 1 < formText.size() )
unitPart = formText.right(idx - 1).simplified();
QLocale sysLocale = QLocale::system();
double dVal = sysLocale.toDouble(numPart);
if( unitPart.size() > 0 )
{
QString prefix = QString(unitPart[0]);
if( s_PrefixExponentMap.contains(prefix) )
dVal *= std::pow( 10.0, s_PrefixExponentMap[prefix] );
}
sysLocale.setNumberOptions(sysLocale.numberOptions() | QLocale::OmitGroupSeparator);
QString result = sysLocale.toString(dVal, 'f', 2);
//qDebug() << " convert: " << numPart << " : " << unitPart << " : " << dVal << " : " << result;
return result;
*/
return "fitze!";
}
///
/// --- statics --------------------------------------------------------------------------
///
QString XQItemType::makeItemTypeKey()
{
return makeItemTypeKey(
_renderStyle,
_editorType,
_itemFlags,
_unitType,
_contentFormat,
_fixedChoices,
_typeIcon
);
}
QString XQItemType::makeItemTypeKey(
XQItem::RenderStyle aRenderStyle,
XQItem::EditorType aEditorType,
Qt::ItemFlags aItemFlags,
XQItem::UnitType aUnitType,
const QString& aContentFormat,
QStandardItemModel* aFixedChoices,
const QIcon aIcon
)
{
auto combinedHash = [](const QStandardItemModel* model)
{
const quint32 prime = 0x9e3779b1; // große Zufallszahl
quint32 seed = 0;
for (int row = 0; row < model->rowCount(); ++row) {
const QString text = model->item(row)->text();
quint32 h = qHash(text);
// Verschmelzung nach Boost-Hash-Combine:
seed ^= h + prime + (seed << 6) + (seed >> 2);
}
return QString::number(seed);
};
return QString("%1:%2:%3:%4:%5:%7:%8").arg(
XQItem::fetchRenderStyleStr(aRenderStyle),
XQItem::fetchEditorTypeStr(aEditorType),
QString::number( aItemFlags.toInt() ),
XQItem::fetchUnitTypeStr(aUnitType),
aContentFormat,
combinedHash(aFixedChoices),
aIcon.name()
);
}
/*
void XQItemType::setItemType( XQItem* item, RenderStyle renderStyle, UnitType unitType )
{
XQItemType* itemType = XQItemType::makeItemType( renderStyle, unitType );
item->setItemType( itemType );
}
*/

149
deprecated/xqitemtype.h Normal file
View File

@@ -0,0 +1,149 @@
/***************************************************************************
source::worx xtree
Copyright © 2024 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
{
//?? needed?
Q_OBJECT
//das haut so nicht hin
//Q_PROPERTY(XQItem::RenderStyle renderStyle renderStyle getDate WRITE setrenderStyle )
public:
XQItemType();
XQItemType( const XQItemType& other);
virtual ~XQItemType();
//XQItemType( RenderStyle aRenderStyle, EditorType aEditorType, Qt::ItemFlags aItemFlags, UnitType aUnitType, const QString& aContentFormat );
// ContentFormat als enum?? Warum, für predefined types: int, double ?
// key for custom edit?
// key for custom format?
///
/// Setter für die XQItemFactory. Setzen das Attribute
/// _ohne_ den itemTypeCache zu beeinflussen
///
void setAttribute(XQItem::RenderStyle renderStyle );
void setAttribute(XQItem::EditorType editorType );
void setAttribute(Qt::ItemFlags itemFlags );
void setAttribute(XQItem::UnitType unitType);
void setAttribute(const QString& contentFormat);
void setAttribute(QStandardItemModel* fixedChoices);
void setAttribute(const QIcon& typeIcon);
QString unitTypeStr() const;
// FIX! Das gehört hier nicht her!
QString formatToSI(const QString& rawText ) const;
QString unFormatFromSI(const QString& valueText ) const;
/// data() access for property system
XQItem::RenderStyle renderStyle() const;
XQItem::EditorType editorType() const;
Qt::ItemFlags itemFlags() const;
XQItem::UnitType unitType() const;
const QString& contentFormat() const;
QStandardItemModel* fixedChoices() const;
template<typename T>
XQItemType* replaceAttribute(T attribute)
{
// eine kopie meiner selbst erzeugen
XQItemType* myClone = new XQItemType(*this);
return myClone;
}
XQItemType* replaceRenderStyle(XQItem::RenderStyle renderStyle );
XQItemType* replaceEditorType(XQItem::EditorType editorType);
XQItemType* replaceItemFlags(Qt::ItemFlags itemFlags);
XQItemType* replaceUnitType(XQItem::UnitType unitType);
XQItemType* replaceContentFormat(const QString& contentFormat);
XQItemType* replaceFixedChoices( QStandardItemModel* fixedChoices);
QString makeItemTypeKey();
static QString makeItemTypeKey(
XQItem::RenderStyle aRenderStyle,
XQItem::EditorType aEditorType,
Qt::ItemFlags aItemFlags,
XQItem::UnitType aUnitType,
const QString& aContentFormat,
QStandardItemModel* aFixedChoices,
const QIcon aIcon
);
protected:
static XQItemTypeMap s_ItemTypeMap;
XQItem::RenderStyle _renderStyle{XQItem::NoRenderStyle};
XQItem::EditorType _editorType{XQItem::NoEditorType};
Qt::ItemFlags _itemFlags;
XQItem::UnitType _unitType{XQItem::NoUnitType};
QString _contentFormat;
QStandardItemModel* _fixedChoices{};
QIcon _typeIcon;
QString _itemTypeKey;
/*
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*);
/*
//??
done by Q_ENUM
Q_DECLARE_METATYPE(XQItemType::RenderStyle);
Q_DECLARE_METATYPE(XQItemType::UnitType);
Q_DECLARE_METATYPE(XQItemType);
*/
#endif // XQITEMTYPE_H