This commit is contained in:
2025-08-15 20:31:40 +02:00
parent 6865e6aaaa
commit c87da2802a
14 changed files with 235 additions and 293 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

@@ -32,7 +32,7 @@ namespace XQAppData
class XQAppIconMap : public QMap<QString,QIcon> class XQAppIconMap : public QMap<QString,XQIcon>
{ {
public: public:
@@ -40,85 +40,85 @@ namespace XQAppData
void init() void init()
{ {
insert( "DirIcon" , QApplication::style()->standardIcon(QStyle::SP_DirIcon)); namedInsert( "DirIcon" , QStyle::SP_DirIcon );
insert( "FileDialogBack", QApplication::style()->standardIcon(QStyle::SP_FileDialogBack)); namedInsert( "FileDialogBack", QStyle::SP_FileDialogBack );
insert( "FileDialogContentsView", QApplication::style()->standardIcon(QStyle::SP_FileDialogContentsView)); namedInsert( "FileDialogContentsView", QStyle::SP_FileDialogContentsView );
insert( "FileDialogDetailedView", QApplication::style()->standardIcon(QStyle::SP_FileDialogDetailedView)); namedInsert( "FileDialogDetailedView", QStyle::SP_FileDialogDetailedView );
insert( "icn05Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogEnd)); namedInsert( "icn05Dummy", QStyle::SP_FileDialogEnd );
insert( "icn06Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogInfoView)); namedInsert( "icn06Dummy", QStyle::SP_FileDialogInfoView );
insert( "icn07Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogListView)); namedInsert( "icn07Dummy", QStyle::SP_FileDialogListView );
insert( "icn08Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogNewFolder)); namedInsert( "icn08Dummy", QStyle::SP_FileDialogNewFolder );
insert( "icn09Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogStart)); namedInsert( "icn09Dummy", QStyle::SP_FileDialogStart );
insert( "icn10Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogToParent)); namedInsert( "icn10Dummy", QStyle::SP_FileDialogToParent );
insert( "icn11Dummy", QApplication::style()->standardIcon(QStyle::SP_ArrowBack)); namedInsert( "icn11Dummy", QStyle::SP_ArrowBack );
insert( "icn12Dummy", QApplication::style()->standardIcon(QStyle::SP_DirIcon)); namedInsert( "icn12Dummy", QStyle::SP_DirIcon );
insert( "icn13Dummy", QApplication::style()->standardIcon(QStyle::SP_MediaSkipBackward)); namedInsert( "icn13Dummy", QStyle::SP_MediaSkipBackward );
insert( "icn14Dummy", QApplication::style()->standardIcon(QStyle::SP_ArrowDown)); namedInsert( "icn14Dummy", QStyle::SP_ArrowDown );
insert( "icn15Dummy", QApplication::style()->standardIcon(QStyle::SP_DirLinkIcon)); namedInsert( "icn15Dummy", QStyle::SP_DirLinkIcon );
insert( "icn16Dummy", QApplication::style()->standardIcon(QStyle::SP_MediaSkipForward)); namedInsert( "icn16Dummy", QStyle::SP_MediaSkipForward );
insert( "icn17Dummy", QApplication::style()->standardIcon(QStyle::SP_ArrowForward)); namedInsert( "icn17Dummy", QStyle::SP_ArrowForward );
insert( "icn18Dummy", QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon)); namedInsert( "icn18Dummy", QStyle::SP_DirOpenIcon );
insert( "icn19Dummy", QApplication::style()->standardIcon(QStyle::SP_MediaStop)); namedInsert( "icn19Dummy", QStyle::SP_MediaStop );
insert( "icn20Dummy", QApplication::style()->standardIcon(QStyle::SP_ArrowLeft)); namedInsert( "icn20Dummy", QStyle::SP_ArrowLeft );
insert( "icn21Dummy", QApplication::style()->standardIcon(QStyle::SP_DockWidgetCloseButton)); namedInsert( "icn21Dummy", QStyle::SP_DockWidgetCloseButton );
insert( "icn22Dummy", QApplication::style()->standardIcon(QStyle::SP_MediaVolume)); namedInsert( "icn22Dummy", QStyle::SP_MediaVolume );
insert( "icn23Dummy", QApplication::style()->standardIcon(QStyle::SP_ArrowRight)); namedInsert( "icn23Dummy", QStyle::SP_ArrowRight );
insert( "icn24Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveCDIcon)); namedInsert( "icn24Dummy", QStyle::SP_DriveCDIcon );
insert( "icn25Dummy", QApplication::style()->standardIcon(QStyle::SP_MediaVolumeMuted)); namedInsert( "icn25Dummy", QStyle::SP_MediaVolumeMuted );
insert( "icn26Dummy", QApplication::style()->standardIcon(QStyle::SP_ArrowUp)); namedInsert( "icn26Dummy", QStyle::SP_ArrowUp );
insert( "icn27Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveDVDIcon)); namedInsert( "icn27Dummy", QStyle::SP_DriveDVDIcon );
insert( "icn28Dummy", QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical)); namedInsert( "icn28Dummy", QStyle::SP_MessageBoxCritical );
insert( "icn29Dummy", QApplication::style()->standardIcon(QStyle::SP_BrowserReload)); namedInsert( "icn29Dummy", QStyle::SP_BrowserReload );
insert( "icn30Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveFDIcon)); namedInsert( "icn30Dummy", QStyle::SP_DriveFDIcon );
insert( "icn31Dummy", QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation)); namedInsert( "icn31Dummy", QStyle::SP_MessageBoxInformation );
insert( "BrowserStop", QApplication::style()->standardIcon(QStyle::SP_BrowserStop)); namedInsert( "BrowserStop", QStyle::SP_BrowserStop );
insert( "icn33Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveHDIcon)); namedInsert( "icn33Dummy", QStyle::SP_DriveHDIcon );
insert( "icn34Dummy", QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion)); namedInsert( "icn34Dummy", QStyle::SP_MessageBoxQuestion );
insert( "icn35Dummy", QApplication::style()->standardIcon(QStyle::SP_CommandLink)); namedInsert( "icn35Dummy", QStyle::SP_CommandLink );
insert( "icn36Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveNetIcon)); namedInsert( "icn36Dummy", QStyle::SP_DriveNetIcon );
insert( "icn37Dummy", QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning)); namedInsert( "icn37Dummy", QStyle::SP_MessageBoxWarning );
insert( "icn38Dummy", QApplication::style()->standardIcon(QStyle::SP_ComputerIcon)); namedInsert( "icn38Dummy", QStyle::SP_ComputerIcon );
insert( "icn39Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogBack)); namedInsert( "icn39Dummy", QStyle::SP_FileDialogBack );
insert( "icn40Dummy", QApplication::style()->standardIcon(QStyle::SP_TitleBarCloseButton)); namedInsert( "icn40Dummy", QStyle::SP_TitleBarCloseButton );
insert( "icn41Dummy", QApplication::style()->standardIcon(QStyle::SP_CustomBase)); namedInsert( "icn41Dummy", QStyle::SP_CustomBase );
insert( "icn42Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogContentsView)); namedInsert( "icn42Dummy", QStyle::SP_FileDialogContentsView );
insert( "icn43Dummy", QApplication::style()->standardIcon(QStyle::SP_TitleBarContextHelpButton)); namedInsert( "icn43Dummy", QStyle::SP_TitleBarContextHelpButton );
insert( "icn44Dummy", QApplication::style()->standardIcon(QStyle::SP_DesktopIcon)); namedInsert( "DesktopIcon", QStyle::SP_DesktopIcon );
insert( "icn45Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogDetailedView)); namedInsert( "icn45Dummy", QStyle::SP_FileDialogDetailedView );
insert( "icn46Dummy", QApplication::style()->standardIcon(QStyle::SP_TitleBarMaxButton)); namedInsert( "icn46Dummy", QStyle::SP_TitleBarMaxButton );
insert( "icn47Dummy", QApplication::style()->standardIcon(QStyle::SP_DialogApplyButton)); namedInsert( "icn47Dummy", QStyle::SP_DialogApplyButton );
insert( "icn48Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogEnd)); namedInsert( "icn48Dummy", QStyle::SP_FileDialogEnd );
insert( "icn49Dummy", QApplication::style()->standardIcon(QStyle::SP_TitleBarMenuButton)); namedInsert( "icn49Dummy", QStyle::SP_TitleBarMenuButton );
insert( "icn50Dummy", QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton)); namedInsert( "icn50Dummy", QStyle::SP_DialogCancelButton );
insert( "icn51Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogInfoView)); namedInsert( "icn51Dummy", QStyle::SP_FileDialogInfoView );
insert( "icn52Dummy", QApplication::style()->standardIcon(QStyle::SP_TitleBarMinButton)); namedInsert( "icn52Dummy", QStyle::SP_TitleBarMinButton );
insert( "icn53Dummy", QApplication::style()->standardIcon(QStyle::SP_DialogCloseButton)); namedInsert( "icn53Dummy", QStyle::SP_DialogCloseButton );
insert( "icn54Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogListView)); namedInsert( "icn54Dummy", QStyle::SP_FileDialogListView );
insert( "icn55Dummy", QApplication::style()->standardIcon(QStyle::SP_TitleBarNormalButton)); namedInsert( "icn55Dummy", QStyle::SP_TitleBarNormalButton );
insert( "icn56Dummy", QApplication::style()->standardIcon(QStyle::SP_DialogDiscardButton)); namedInsert( "icn56Dummy", QStyle::SP_DialogDiscardButton );
insert( "icn57Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogNewFolder)); namedInsert( "icn57Dummy", QStyle::SP_FileDialogNewFolder );
insert( "icn58Dummy", QApplication::style()->standardIcon(QStyle::SP_TitleBarShadeButton)); namedInsert( "icn58Dummy", QStyle::SP_TitleBarShadeButton );
insert( "icn59Dummy", QApplication::style()->standardIcon(QStyle::SP_DialogHelpButton)); namedInsert( "icn59Dummy", QStyle::SP_DialogHelpButton );
insert( "icn60Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogStart)); namedInsert( "icn60Dummy", QStyle::SP_FileDialogStart );
insert( "icn61Dummy", QApplication::style()->standardIcon(QStyle::SP_TitleBarUnshadeButton)); namedInsert( "icn61Dummy", QStyle::SP_TitleBarUnshadeButton );
insert( "icn62Dummy", QApplication::style()->standardIcon(QStyle::SP_DialogNoButton)); namedInsert( "icn62Dummy", QStyle::SP_DialogNoButton );
insert( "icn63Dummy", QApplication::style()->standardIcon(QStyle::SP_FileDialogToParent)); namedInsert( "icn63Dummy", QStyle::SP_FileDialogToParent );
insert( "icn64Dummy", QApplication::style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton)); namedInsert( "icn64Dummy", QStyle::SP_ToolBarHorizontalExtensionButton );
insert( "icn65Dummy", QApplication::style()->standardIcon(QStyle::SP_DialogOkButton)); namedInsert( "icn65Dummy", QStyle::SP_DialogOkButton );
insert( "FileIcon", QApplication::style()->standardIcon(QStyle::SP_FileIcon)); namedInsert( "FileIcon", QStyle::SP_FileIcon );
insert( "icn67Dummy", QApplication::style()->standardIcon(QStyle::SP_ToolBarVerticalExtensionButton)); namedInsert( "icn67Dummy", QStyle::SP_ToolBarVerticalExtensionButton );
insert( "icn68Dummy", QApplication::style()->standardIcon(QStyle::SP_DialogResetButton)); namedInsert( "icn68Dummy", QStyle::SP_DialogResetButton );
insert( "icn70Dummy", QApplication::style()->standardIcon(QStyle::SP_FileLinkIcon)); namedInsert( "icn70Dummy", QStyle::SP_FileLinkIcon );
insert( "TrashIcon", QApplication::style()->standardIcon(QStyle::SP_TrashIcon)); namedInsert( "TrashIcon", QStyle::SP_TrashIcon );
insert( "icn72Dummy", QApplication::style()->standardIcon(QStyle::SP_DialogSaveButton)); namedInsert( "icn72Dummy", QStyle::SP_DialogSaveButton );
insert( "icn73Dummy", QApplication::style()->standardIcon(QStyle::SP_MediaPause)); namedInsert( "icn73Dummy", QStyle::SP_MediaPause );
insert( "icn74Dummy", QApplication::style()->standardIcon(QStyle::SP_VistaShield)); namedInsert( "icn74Dummy", QStyle::SP_VistaShield );
insert( "icn75Dummy", QApplication::style()->standardIcon(QStyle::SP_DialogYesButton)); namedInsert( "icn75Dummy", QStyle::SP_DialogYesButton );
insert( "icn76Dummy", QApplication::style()->standardIcon(QStyle::SP_MediaPlay)); namedInsert( "icn76Dummy", QStyle::SP_MediaPlay );
insert( "icn77Dummy", QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon)); namedInsert( "icn77Dummy", QStyle::SP_DirClosedIcon );
insert( "icn79Dummy", QApplication::style()->standardIcon(QStyle::SP_MediaSeekBackward)); namedInsert( "icn79Dummy", QStyle::SP_MediaSeekBackward );
insert( "DirHomeIcon", QApplication::style()->standardIcon(QStyle::SP_DirHomeIcon)); namedInsert( "DirHomeIcon", QStyle::SP_DirHomeIcon );
insert( "icn81Dummy", QApplication::style()->standardIcon(QStyle::SP_MediaSeekForward)); namedInsert( "icn81Dummy", QStyle::SP_MediaSeekForward );
/* /*
auto from = to_underlying(QIcon::ThemeIcon::AddressBookNew); auto from = to_underlying(QIcon::ThemeIcon::AddressBookNew);
auto to = to_underlying(QIcon::ThemeIcon::NThemeIcons); auto to = to_underlying(QIcon::ThemeIcon::NThemeIcons);
@@ -134,8 +134,17 @@ namespace XQAppData
} }
}; void namedInsert( const QString& key, QStyle::StandardPixmap pixmapID )
{
QIcon icon = QApplication::style()->standardIcon( pixmapID );
insert( key, XQIcon( icon, key ) );
//_keysToNames.insert()
}
protected:
QMap<qint64,QString> _keysToNames;
};
@@ -150,18 +159,15 @@ namespace XQAppData
static XQAppIconMap s_IconMap; static XQAppIconMap s_IconMap;
bool hasTypeIcon(const QString& key )
XQIcon typeIcon(const QString& key )
{ {
if(s_IconMap.isEmpty()) if(s_IconMap.isEmpty())
s_IconMap.init(); s_IconMap.init();
return !key.isEmpty() && s_IconMap.contains(key); if( s_IconMap.contains(key) )
}
QIcon typeIcon(const QString& key )
{
if( hasTypeIcon(key) )
return s_IconMap[key]; return s_IconMap[key];
return QApplication::style()->standardIcon(QStyle::SP_TrashIcon); static XQIcon s_FallBackIcon( QApplication::style()->standardIcon( QStyle::SP_TrashIcon), "NoIcon" );
return s_FallBackIcon;
} }

View File

@@ -19,7 +19,8 @@
#include <QVariant> #include <QVariant>
#include <QMap> #include <QMap>
#include <QStringView> #include <QStringView>
#include <QIcon>
#include <xqicon.h>
#include <pugixml.hpp> #include <pugixml.hpp>
const QString c_Version = "0.1.1 04.09.2024"; const QString c_Version = "0.1.1 04.09.2024";
@@ -48,8 +49,7 @@ namespace XQAppData
{ {
//class XQAppIconMap; //class XQAppIconMap;
bool hasTypeIcon(const QString& key ); XQIcon typeIcon(const QString& key );
QIcon typeIcon(const QString& key );
} }
#endif // XQAPPDATA_H #endif // XQAPPDATA_H

View File

@@ -34,47 +34,6 @@ XQMainModel::XQMainModel(QObject *parent )
} }
//! 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!" );
}
//! leere default implementation //! leere default implementation
void XQMainModel::initContextMenu() void XQMainModel::initContextMenu()

View File

@@ -32,7 +32,7 @@ public:
explicit XQMainModel(QObject *parent = nullptr); explicit XQMainModel(QObject *parent = nullptr);
virtual ~XQMainModel() = default; virtual ~XQMainModel() = default;
XQItem* createTreeEntry( XQNodePtr contentNode );
public slots: public slots:

View File

@@ -68,28 +68,32 @@ bool XQItemFactory::isValid()
} }
//! es reicht nicht, einen itemType aus den itemType-templates zu //! Es reicht nicht, einen itemType aus den itemType-templates zu
//! holen: möglicherweise muss der noch mit zusätzlichen attributen //! holen: möglicherweise muss der noch mit zusätzlichen attributen
//! ergänzt werden, (hier 'UnitType' ). //! ergänzt werden.
//! Vom aufwand ist es auch egal, ob ich daten aus dem XML in das
//! item oder den itemtyp schreiben muss.
XQItemType* XQItemFactory::makeItemType(const XQNodePtr& sheetEntry ) XQItemType* XQItemFactory::makeItemType(const XQNodePtr& sheetEntry )
{ {
QString typeKey = sheetEntry->attribute("ItemType"); QString typeKey = sheetEntry->attribute( c_ItemType );
XQItemType* itemType = findItemTypeTemplate(typeKey); XQItemType* itemType = findItemTypeTemplate(typeKey);
// wir prüfen, ob im sheetEntry noch zusätzliche attribute vorhanden // wir prüfen, ob im sheetEntry noch zusätzliche attribute vorhanden
// sind, die wir in dem itemType müssen // sind, die wir in dem itemType müssen
qDebug() << " --- makeItemType: " << sheetEntry->to_string();
// über alle attribute // über alle attribute
for (const auto& attr : sheetEntry->attributes()) for (const auto& attrEntry : sheetEntry->attributes())
{ {
// prüfen, ob der itemType des attribute schon hat // prüfen, ob der itemType des attribute schon hat
int role = itemType->hasAttribute( attr.first); int role = itemType->roleForAttributeKey( attrEntry.first );
// wenn ja, überschreiben // wenn ja, überschreiben
if( role != XQItem::NoRole ) if( role != XQItem::NoRole )
{ {
QVariant newValue = makeVariant(role,attr.second); QVariant newValue = makeVariant(role, attrEntry.second );
itemType = itemType->replaceAttribute( newValue, role ); itemType = itemType->replaceAttribute( newValue, role );
} }
@@ -97,7 +101,7 @@ XQItemType* XQItemFactory::makeItemType(const XQNodePtr& sheetEntry )
return itemType; return itemType;
} }
//! firz! //! sucht einen item typ aus der map mit 'vorgefertigen' itemtypen.
XQItemType* XQItemFactory::findItemTypeTemplate(const QString& key ) const XQItemType* XQItemFactory::findItemTypeTemplate(const QString& key ) const
{ {
@@ -107,7 +111,7 @@ XQItemType* XQItemFactory::findItemTypeTemplate(const QString& key ) const
} }
//! firz! //! sucht eine model-beschreibung
XQNodePtr XQItemFactory::findModelSheet( const QString& modelName ) const XQNodePtr XQItemFactory::findModelSheet( const QString& modelName ) const
{ {
@@ -153,6 +157,7 @@ QVariant XQItemFactory::makeVariant( int dataRole, const QString& source ) const
case XQItem::ItemTypeRole: case XQItem::ItemTypeRole:
{ {
// itemType() -> XQItemType* // itemType() -> XQItemType*
qDebug() << " --- makeVariant: make ItemType: " << source;
XQItemType* itemType = findItemTypeTemplate( source ); XQItemType* itemType = findItemTypeTemplate( source );
value = QVariant::fromValue(itemType); value = QVariant::fromValue(itemType);
break; break;
@@ -203,9 +208,7 @@ QVariant XQItemFactory::makeVariant( int dataRole, const QString& source ) const
case XQItem::IconRole: case XQItem::IconRole:
{ {
QIcon typeIcon; QIcon typeIcon = XQAppData::typeIcon(source);
if(XQAppData::hasTypeIcon(source))
typeIcon = XQAppData::typeIcon(source);
value = QVariant::fromValue(typeIcon); value = QVariant::fromValue(typeIcon);
break; break;
} }
@@ -264,9 +267,8 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& co
{ {
// den itemtype des neuen items rausfinden // den itemtype des neuen items rausfinden
QString typeKey = sheetNode->attribute(c_ItemType); QString typeKey = sheetNode->attribute(c_ItemType);
qDebug() << " --- makeItem: typeKey: " << typeKey << ": " << sheetNode->to_string();
//XQItemType* itemType = makeItemType(sheetEntry); // throws XQItemType* itemType = makeItemType(sheetNode); // throws
XQItemType* itemType = findItemTypeTemplate(typeKey);
// fallunterscheidung beim inhalt: // fallunterscheidung beim inhalt:
const QString* contentPtr{}; const QString* contentPtr{};
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung // das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
@@ -280,24 +282,8 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& co
} }
XQItemList XQItemFactory::makeHeaderRow( const XQNodePtr& headerNode )
{
XQItemList list; //! erzeugt eine item-row.
// über alle kinder der <Header> sektion
for( const auto& headerEntry : headerNode->children() )
{
//qDebug() << " --- headerEntry: " << headerEntry->tag_name() << ": " << headerEntry->attribute( "ItemType") << headerEntry->attribute( "Caption");
XQItem* headerItem = makeItem( headerEntry );
list.append( headerItem );
}
return list;
}
//! erzeugt eine header item row.
XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ) XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
{ {

View File

@@ -34,7 +34,7 @@ public:
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode=nullptr); XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode=nullptr);
XQItemList makeHeaderRow( const XQNodePtr& sheetNode );
XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ); //XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );

View File

@@ -70,18 +70,17 @@ void XQItemType::setData(const QVariant& value, int role )
} }
//! tested, ob ein attribute (z.B. unitType) hier vorhanden ist //! tested, ob ein attribute (z.B. unitType) hier vorhanden ist
int XQItemType::hasAttribute( const QString& attrKey ) int XQItemType::roleForAttributeKey( const QString& attrKey )
{ {
int role = XQItem::fetchItemDataRole(attrKey); int role = XQItem::fetchItemDataRole(attrKey);
// gibbed überhaupt eine rolle für unser attribut? // gibbed überhaupt eine rolle für unser attribut?
if( role == XQItem::NoRole) if( role != XQItem::NoRole)
return XQItem::NoRole; {
// wenn ja, ist die role hier besetzt?
// wenn ja, ist die role hier besetzt? QVariant value = data(role);
QVariant value = data(role); if( !value.isValid() || value.isNull() )
if( !value.isValid() || value.isNull() ) return XQItem::NoRole;
return XQItem::NoRole; }
return role; return role;
} }
@@ -91,6 +90,7 @@ int XQItemType::hasAttribute( const QString& attrKey )
XQItemType* XQItemType::replaceAttribute( const QVariant& newValue, int role ) XQItemType* XQItemType::replaceAttribute( const QVariant& newValue, int role )
{ {
qDebug() << " --- Before: " << makeItemTypeKey() << " role:" << XQItem::fetchItemDataRoleName(role) << " value:" << newValue.toString();
// hat sich überhaupt was geändert? // hat sich überhaupt was geändert?
QVariant oldValue = data(role); QVariant oldValue = data(role);
@@ -115,8 +115,10 @@ XQItemType* XQItemType::replaceAttribute( const QVariant& newValue, int role )
// speichern // speichern
s_ItemTypeMap.insert( newKey, myClone ); s_ItemTypeMap.insert( newKey, myClone );
// und ins item übernehmen
//item.setItemType( myClone );
qDebug() << " --- After: " << myClone->makeItemTypeKey();
/// Obacht! Der alte, geänderte itemType bleibt erhalten /// Obacht! Der alte, geänderte itemType bleibt erhalten
/// und verrottet ggf. ohne Daseinszweck /// und verrottet ggf. ohne Daseinszweck
@@ -131,6 +133,7 @@ XQItemType* XQItemType::replaceAttribute( const QVariant& newValue, int role )
QVariant XQItemType::formatText( const XQItem& item ) const QVariant XQItemType::formatText( const XQItem& item ) const
{ {
XQItem::UnitType uType = unitType(); XQItem::UnitType uType = unitType();
//qDebug() << " --- formatText: " << XQItem::fetchUnitTypeToString( uType);
const QString& cont = item.content(); const QString& cont = item.content();
if( uType != XQItem::NoUnitType ) if( uType != XQItem::NoUnitType )
return formatToSI( cont, uType ); return formatToSI( cont, uType );
@@ -245,9 +248,10 @@ QString XQItemType::makeItemTypeKey()
key = key.arg( editorTypeToString() ); key = key.arg( editorTypeToString() );
key = key.arg( unitTypeToString() ); key = key.arg( unitTypeToString() );
key = key.arg( contentFormat() ); key = key.arg( contentFormat() );
key = key.arg( data(XQItem::FlagsRole).toString() ); key = key.arg( data(XQItem::FlagsRole).toString() );
key = key.arg( icon().name() ); // icons haben leider keine namen, es sei denn, sie kommen aus einen theme
//key = key.arg( icon().name() );
key = key.arg( icon().cacheKey() );
key = key.arg( fixedChoicesToString() ); key = key.arg( fixedChoicesToString() );
return key; return key;

View File

@@ -40,12 +40,12 @@ public:
QVariant data( int role ) const override; QVariant data( int role ) const override;
void setData(const QVariant& value, int role ) override; void setData(const QVariant& value, int role ) override;
virtual QVariant formatText( const XQItem& item ) const; QVariant formatText( const XQItem& item ) const;
QString formatToSI(const QString& rawText, XQItem::UnitType unitType ) const; QString formatToSI(const QString& rawText, XQItem::UnitType unitType ) const;
QString unFormatFromSI(const QString& valueText ) const; QString unFormatFromSI(const QString& valueText ) const;
int hasAttribute( const QString& attrKey ); int roleForAttributeKey( const QString& attrKey );
XQItemType* replaceAttribute(const QVariant& newValue, int role ); XQItemType* replaceAttribute(const QVariant& newValue, int role );
QString makeItemTypeKey(); QString makeItemTypeKey();

View File

@@ -14,6 +14,7 @@
#include <QDebug> #include <QDebug>
#include <QApplication> #include <QApplication>
#include <QMetaType>
#include <xqmainwindow.h> #include <xqmainwindow.h>
@@ -48,12 +49,13 @@ who is who:
*/ */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
QIcon icon;
//app.setStyle("fusion"); //app.setStyle("fusion");
XQMainWindow window; XQMainWindow window;
window.show(); window.show();

View File

@@ -38,7 +38,6 @@ bool XQModelSection::operator==(const XQModelSection& other) const
bool XQModelSection::isValid() const bool XQModelSection::isValid() const
{ {
qDebug() << " mi: " << modelIndex.isValid() << " sheetNode: " << (bool)(sheetRootNode);
return modelIndex.isValid() && sheetRootNode; return modelIndex.isValid() && sheetRootNode;
} }
@@ -62,7 +61,6 @@ XQItem& XQModelSection::XQModelSection::headerItem() const
bool XQModelSectionList::hasValidSection(const QString& sectionKey) const bool XQModelSectionList::hasValidSection(const QString& sectionKey) const
{ {
qDebug() << " ---- FIND section: " << sectionKey << ":" << contains(sectionKey) << ":" << at(sectionKey).isValid();
if (!contains(sectionKey) ) if (!contains(sectionKey) )
return false; return false;
return at(sectionKey).isValid(); return at(sectionKey).isValid();

View File

@@ -108,7 +108,6 @@ void XQViewModel::initModel(const QString& modelName)
const XQNodePtr header = section->find_child_by_tag_name( "Header"); const XQNodePtr header = section->find_child_by_tag_name( "Header");
if( header ) if( header )
{ {
//XQItemList list = _itemFactory.makeHeaderRow( header );
XQItemList list = _itemFactory.makeContentRow( header, nullptr ); XQItemList list = _itemFactory.makeContentRow( header, nullptr );
addSection(list, section ); addSection(list, section );
} }
@@ -318,7 +317,7 @@ void XQViewModel::cmdCutUndo( XQCommand& command )
const XQNodePtr& savedNode = entry.contentNode; const XQNodePtr& savedNode = entry.contentNode;
// __fix! should not be _contentRoot! // __fix! should not be _contentRoot!
savedNode->add_me_at( entry.nodePos, _contentRoot ); savedNode->add_me_at( entry.nodePos, _contentRoot );
XQItemList list = _itemFactory.makeContentRow( savedNode, section.sheetRootNode ); XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode, savedNode );
XQItem& firstItem = *((XQItem*)list[0]); XQItem& firstItem = *((XQItem*)list[0]);
qDebug() << " --- Cut Undo: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id << " count: " << entry.contentNode.use_count(); qDebug() << " --- Cut Undo: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id << " count: " << entry.contentNode.use_count();
@@ -353,7 +352,7 @@ void XQViewModel::cmdPaste( XQCommand& command )
XQNodePtr newNode = entry.contentNode->clone(section.contentRootNode ); XQNodePtr newNode = entry.contentNode->clone(section.contentRootNode );
newNode->clone(section.contentRootNode )->add_me_at( nodePos ); newNode->clone(section.contentRootNode )->add_me_at( nodePos );
// ... und damit eine frische item-row erzeugen // ... und damit eine frische item-row erzeugen
XQItemList list = _itemFactory.makeContentRow( newNode, section.sheetRootNode ); XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode, newNode );
insertRow( insRow, list ); insertRow( insRow, list );
// die neue item-row selektieren // die neue item-row selektieren
const QModelIndex& selIdx = list[0]->index(); const QModelIndex& selIdx = list[0]->index();

View File

@@ -43,6 +43,7 @@ HEADERS += \
util/xsingleton.h \ util/xsingleton.h \
util/xtreewalker.h \ util/xtreewalker.h \
widgets/xqcontextmenu.h \ widgets/xqcontextmenu.h \
widgets/xqicon.h \
widgets/xqtreetable.h widgets/xqtreetable.h
SOURCES += \ SOURCES += \
@@ -67,6 +68,7 @@ SOURCES += \
pugixml/pugixml.cpp \ pugixml/pugixml.cpp \
util/xqexception.cpp \ util/xqexception.cpp \
widgets/xqcontextmenu.cpp \ widgets/xqcontextmenu.cpp \
widgets/xqicon.cpp \
widgets/xqtreetable.cpp widgets/xqtreetable.cpp

View File

@@ -9,38 +9,17 @@
<ItemTypes> <ItemTypes>
<TreeParentType RenderStyle="PlainStyle" ItemFlags="IsEnabled|IsDropEnabled" Icon="DirIcon" /> <TreeParentType RenderStyle="PlainStyle" ItemFlags="IsEnabled|IsDropEnabled" Icon="DirIcon" />
<TreeChildType RenderStyle="PlainStyle" ItemFlags="IsCheckable|IsEnabled|IsDragEnabled|IsSelectable|IsDropEnabled"/> <TreeChildType RenderStyle="PlainStyle" ItemFlags="IsCheckable|IsEnabled|IsDragEnabled|IsSelectable|IsDropEnabled"/>
<HeaderType RenderStyle="HeaderStyle" ItemFlags="IsEnabled" Icon="battery"/> <HeaderType RenderStyle="HeaderStyle" ItemFlags="IsCheckable|IsEnabled" Icon="DirIcon"/>
<HiddenType RenderStyle="HiddenStyle"/> <HiddenType RenderStyle="HiddenStyle"/>
<StaticType RenderStyle="PlainStyle"/> <StaticType RenderStyle="PlainStyle"/>
<PlainType RenderStyle="PlainStyle" ItemFlags="IsEnabled|IsEditable|IsSelectable"/> <PlainType RenderStyle="PlainStyle" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
<ValueType RenderStyle="FormattedStyle" ItemFlags="IsEnabled|IsEditable|IsSelectable" UnitType="Coulomb"/> <ValueType RenderStyle="FormattedStyle" ItemFlags="IsEnabled|IsEditable|IsSelectable" Icon="DirIcon" UnitType="Coulomb"/>
<PercentageType RenderStyle="ProgressBarStyle" ItemFlags="IsEnabled|IsSelectable"/> <PercentageType RenderStyle="ProgressBarStyle" ItemFlags="IsEnabled|IsSelectable"/>
<ChoiceType RenderStyle="ComboBoxStyle" ItemFlags="IsEnabled|IsSelectable|IsEditable" FixedChoices="la|le|lo|lu"/> <ChoiceType RenderStyle="ComboBoxStyle" ItemFlags="IsEnabled|IsSelectable|IsEditable" FixedChoices="la|le|lo|lu"/>
<IntValueType RenderStyle="SpinBoxStyle" ItemFlags="IsEnabled|IsSelectable"/> <IntValueType RenderStyle="SpinBoxStyle" ItemFlags="IsEnabled|IsSelectable"/>
</ItemTypes> </ItemTypes>
<!--
DocumentTreeModel
-->
<!--
<DocumentTreeModel>
<ActiveProjects ItemType="PlainType" HeaderItemType="TreeParentType" HeaderCaption="Active Projects" State="runnning">
<Project ItemType="TreeChildType" Icon="list-add"/>
</ActiveProjects>
<PlannedProjects HeaderItemType="TreeParentType" HeaderCaption="Planned Projects" State="planned">
<Project ItemType="TreeChildType" Icon="list-add"/>
</PlannedProjects>
<FinishedProjects HeaderItemType="TreeParentType" HeaderCaption="Finished Projects" State="finished">
<Project ItemType="TreeChildType" Icon="list-remove"/>
</FinishedProjects>
</DocumentTreeModel>
-->
<!--
DocumentDetailsModel:
-->
<DocumentTreeModel> <DocumentTreeModel>
<Section ContentType="runnning"> <Section ContentType="runnning">
<Header> <Header>
@@ -66,7 +45,6 @@
<Project Caption="@ProjectName" ItemType="TreeParentType"/> <Project Caption="@ProjectName" ItemType="TreeParentType"/>
</Data> </Data>
</Section> </Section>
</DocumentTreeModel> </DocumentTreeModel>
@@ -88,11 +66,11 @@
</Header> </Header>
<Data> <Data>
<!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType--> <!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
<PanelID ItemType="PlainType" Icon="FileIcon"/> <PanelID ItemType="PlainType" Icon="DesktopIcon"/>
<PanelName ItemType="PlainType"/> <PanelName ItemType="PlainType" Icon="BrowserStop"/>
<Manufacturer ItemType="ValueType"/> <Manufacturer ItemType="ValueType"/>
<!-- 'UnitType' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType--> <!-- 'UnitType' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
<WattPeak ItemType="ValueType" UnitType="Wp"/> <WattPeak ItemType="ValueType" UnitType="Wp" Icon="DesktopIcon"/>
<Width ItemType="ValueType" UnitType="m"/> <Width ItemType="ValueType" UnitType="m"/>
<Height ItemType="ValueType" UnitType="m"/> <Height ItemType="ValueType" UnitType="m"/>
<Weight ItemType="ValueType" UnitType="kg"/> <Weight ItemType="ValueType" UnitType="kg"/>
@@ -101,83 +79,7 @@
</Data> </Data>
</Section> </Section>
<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>
</DocumentDetailsModel> </DocumentDetailsModel>
<DocumentDetailsModelX>
<Panel FriendlyName="@PanelName">
<PanelID HeaderCaption="Panel" HeaderItemType="HeaderType" ItemType="PlainType" Icon="icn74Dummy"/>
<PanelName HeaderCaption="Name" HeaderItemType="HeaderType" ItemType="PlainType"/>
<Manufacturer HeaderCaption="Manufacturer" HeaderItemType="HeaderType" ItemType="ValueType"/>
<WattPeak HeaderCaption="Watt Peak" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="Wp"/>
<Width HeaderCaption="Width" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="m"/>
<Height HeaderCaption="Height" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="m"/>
<Weight HeaderCaption="Weight" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="kg"/>
<MaxVolt HeaderCaption="max. Volt" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="V"/>
<MaxAmpere HeaderCaption="max. Ampere" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="A"/>
</Panel>
<Inverter FriendlyName="@InverterName">
<InverterID HeaderCaption="Inverter" HeaderItemType="HeaderType" ItemType="ValueType"/>
<InverterName HeaderCaption="Name" HeaderItemType="HeaderType" ItemType="ValueType"/>
<Manufacturer HeaderCaption="Manufacturer" HeaderItemType="HeaderType" ItemType="ValueType"/>
<MaxPowerInput HeaderCaption="max. Input" HeaderItemType="HeaderType" ItemType="ChoiceType" ChoiceDataSource="MaxPowerInputChoice" UnitType="W"/>
<MaxPowerOutput HeaderCaption="max Output" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="W"/>
<NumStrings HeaderCaption="Strings" HeaderItemType="HeaderType" ItemType="ValueType"/>
<Weight HeaderCaption="Weight" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="kg"/>
</Inverter>
<Battery FriendlyName="@BatteryName">
<BatteryID HeaderCaption="Battery" HeaderItemType="HeaderType" ItemType="ValueType"/>
<BatteryName HeaderCaption="Name" HeaderItemType="HeaderType" ItemType="ValueType"/>
<Manufacturer HeaderCaption="Manufacturer" HeaderItemType="HeaderType" ItemType="ValueType"/>
<Capacity HeaderCaption="Capacity" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="Wh"/>
<Yield HeaderCaption="Yield" HeaderItemType="HeaderType" ItemType="PercentageType" UnitType="%"/>
<MaxCurrent HeaderCaption="max. Current" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="A"/>
<MaxVolt HeaderCaption="max. Volt" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="V"/>
</Battery>
</DocumentDetailsModelX>