Still works...

This commit is contained in:
2025-08-13 22:25:01 +02:00
parent 7ade8ef1c8
commit d3f2cbeaec
9 changed files with 106 additions and 76 deletions

View File

@@ -71,7 +71,7 @@ namespace XQAppData
insert( "icn29Dummy", QApplication::style()->standardIcon(QStyle::SP_BrowserReload));
insert( "icn30Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveFDIcon));
insert( "icn31Dummy", QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation));
insert( "icn32Dummy", QApplication::style()->standardIcon(QStyle::SP_BrowserStop));
insert( "BrowserStop", QApplication::style()->standardIcon(QStyle::SP_BrowserStop));
insert( "icn33Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveHDIcon));
insert( "icn34Dummy", QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion));
insert( "icn35Dummy", QApplication::style()->standardIcon(QStyle::SP_CommandLink));
@@ -249,3 +249,5 @@ namespace XQAppData
}
*/
}; // namespace XQAppData

View File

@@ -32,7 +32,7 @@ XQChildModel::XQChildModel( QObject *parent )
//! erzeugt die basisstruktur des models.
/*
void XQChildModel::initModel(const QString& modelName)
{
@@ -84,16 +84,17 @@ void XQChildModel::initModel(const QString& modelName)
}
/*
// empty row:
XQNodePtr contentNode = XQNode::make_node( sheetNode->tag_name() );
XQItemList emptyRow = _itemFactory.makeEmptyRow( contentNode, sheetNode );
appendRow( emptyRow );
*/
// XQNodePtr contentNode = XQNode::make_node( sheetNode->tag_name() );
// XQItemList emptyRow = _itemFactory.makeEmptyRow( contentNode, sheetNode );
// appendRow( emptyRow );
} // for
}
*/
//! erzegut den sichtbaren inhalt des models aus einem root-datenknoten.

View File

@@ -29,13 +29,10 @@ public:
explicit XQChildModel(QObject *parent = nullptr);
virtual ~XQChildModel() = default;
void initModel(const QString& modelName) override;
void setContent(const XQNodePtr& contentRoot );
protected:
//void setupViewProperties() override;
void initContextMenu() override;

View File

@@ -34,29 +34,6 @@ XQMainModel::XQMainModel(QObject *parent )
}
//! initialisiert dieses model über den namen.
void XQMainModel::initModel(const QString& modelName)
{
// model rootnode finden -> <DocumentTreeModel>
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
// #1: über alle sections
for( auto& section : modelSheet->children() )
{
// #2: (optionalen) header erzeugen
const XQNodePtr header = section->find_child_by_tag_name( "Header");
if( header )
{
XQItemList list = _itemFactory.makeHeader( header );
Q_ASSERT(!list.isEmpty());
addSection(list, section );
}
}
}
//! erzeugt einen eintrag in der baum-übersicht.
@@ -79,7 +56,7 @@ XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode )
return newTreeentry;
}
}
throw XQException( "createTreeEntry: main model should not be emtpy!" );
throw XQException( "createTreeEntry: main model should not be empty!" );
}
//! leere default implementation

View File

@@ -32,7 +32,6 @@ public:
explicit XQMainModel(QObject *parent = nullptr);
virtual ~XQMainModel() = default;
void initModel(const QString& modelName) override;
XQItem* createTreeEntry( XQNodePtr contentNode );
public slots:

View File

@@ -319,7 +319,7 @@ XQItemList XQItemFactory::makeHeader( const XQNodePtr& headerNode )
{
XQItemList list;
// über alle kinder der <Header> sektion
for( const auto& headerEntry : headerNode->children() )
{
qDebug() << " --- headerEntry: " << headerEntry->tag_name() << ": " << headerEntry->attribute( "ItemType") << headerEntry->attribute( "Caption");

View File

@@ -83,57 +83,37 @@ XQItem& XQViewModel::xqFirstItem(int row) const
return *static_cast<XQItem*>( QStandardItemModel::item(row) );
}
//! create the own model structure
void XQViewModel::initModel( const QString& modelName)
//! initialisiert dieses model über den namen. Es wird hier
//! nur die strukur erzeugt, keine inhalte.
void XQViewModel::initModel(const QString& modelName)
{
/*
model
section
header
data
section
...
*/
// model rootnode finden -> <DocumentTreeModel>
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
/*
// #0: Wir suchen die Model-Beschreibung
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
// #1: Wir erzeugen die Model-Struktur: Jedes Kind beschreibt einen
// XML-Datentyp, z.B. <Panel atr1="..." />, <Battery .../>
// Jeder XML-Knoten entspricht einer Zeile im späteren Model, jedes
// Attribut wird einem eigenen Feld (XQItem) abgebildet.
for( const auto& sheetNode : modelSheet->children() )
// #1: über alle sections
for( auto& section : modelSheet->children() )
{
XQItemList list = _itemFactory.makeHeaderRow( sheetNode );
// für jeden XML-Knotentyp in der Modelbeschreibung erzeugen wir eine section
addSection(list, sheetNode );
// jedes kind kann enthält einen itemType und einen headerItemType. Für
// diese sind eventuell weitere attribute vorhanden, die die im type
// enthaltenen defualt-werte überschreiben.
for( const auto& sheetChild : sheetNode->children() )
// #2: (optionalen) header erzeugen
const XQNodePtr header = section->find_child_by_tag_name( "Header");
if( header )
{
//qDebug() << "---- kloppo: " << sheetChild->tag_name() << ": " << sheetChild->to_string();
extendItemType( sheetChild );
XQItemList list = _itemFactory.makeHeader( header );
Q_ASSERT(!list.isEmpty());
addSection(list, section );
}
// empty row:
//XQNodePtr contentNode = XQNode::make_node( sheetNode->tag_name() );
//XQItemList emptyRow = _itemFactory.makeEmptyRow( contentNode, sheetNode );
//appendRow( emptyRow );
} // for
*/
}
}

View File

@@ -48,7 +48,6 @@ public:
QUndoStack* undoStack();
void setUndoStack( QUndoStack* undoStack );
//! create the own model structure
virtual void initModel( const QString& modelName);
//little helpers
@@ -73,7 +72,7 @@ public:
/*!
Derzeit wir die default-implementierung von data/setData genutzt. hier wäre dann die
Derzeit wird die default-implementierung von data/setData genutzt. hier wäre dann die
Stelle um setData & data an externe 'handler' umzubiegen, siehe giovannies 'model-injection'
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override

View File

@@ -71,8 +71,83 @@
<DocumentDetailsModel>
<Section>
<Header>
<PanelID Caption="Panel" ItemType="HeaderType" />
<PanelName Caption="Name" ItemType="HeaderType" Icon="BrowserStop" />
<Manufacturer Caption="Manufacturer" ItemType="HeaderType" />
<WattPeak Caption="Watt Peak" ItemType="HeaderType" />
<Width Caption="Width" ItemType="HeaderType" />
<Height Caption="Height" ItemType="HeaderType" />
<Wight Caption="Weight" ItemType="HeaderType" />
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
<MaxAmpere Caption="max. Ampere" ItemType="HeaderType" />
</Header>
<Data>
<!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
<PanelID ItemType="PlainType" Icon="FileIcon"/>
<PanelName ItemType="PlainType"/>
<Manufacturer ItemType="ValueType"/>
<!-- 'UnitType' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
<WattPeak ItemType="ValueType" UnitType="Wp"/>
<Width ItemType="ValueType" UnitType="m"/>
<Height ItemType="ValueType" UnitType="m"/>
<Weight ItemType="ValueType" UnitType="kg"/>
<MaxVolt ItemType="ValueType" UnitType="V"/>
<MaxAmpere ItemType="ValueType" UnitType="A"/>
</Data>
</Section>
<Section>
<Header>
<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>
<Header>
<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>
<DocumentDetailsModelX>
<Panel FriendlyName="@PanelName">
<PanelID HeaderCaption="Panel" HeaderItemType="HeaderType" ItemType="PlainType" Icon="icn74Dummy"/>
<PanelName HeaderCaption="Name" HeaderItemType="HeaderType" ItemType="PlainType"/>
@@ -105,4 +180,4 @@
<MaxVolt HeaderCaption="max. Volt" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="V"/>
</Battery>
</DocumentDetailsModel>
</DocumentDetailsModelX>