works again

This commit is contained in:
Christoph Holzheuer
2025-08-14 19:13:53 +02:00
parent d3f2cbeaec
commit a6fb7e82bd
15 changed files with 92 additions and 161 deletions

View File

@@ -31,73 +31,7 @@ XQChildModel::XQChildModel( QObject *parent )
}
//! erzeugt die basisstruktur des models.
/*
void XQChildModel::initModel(const QString& modelName)
{
auto extendItemType = [=,this](const XQNodePtr& entry)
{
const QString& typeName = entry->attribute("ItemType");
XQItemType* itemType = _itemFactory.findItemTypeTemplate( typeName); // throws
// über alle attribute
for (const auto& attr : entry->attributes())
{
// prüfen, ob der itemType des attribute schon hat
int role = itemType->hasAttribute( attr.first);
// wenn ja, überschreiben
if( role != XQItem::NoRole )
{
QVariant newValue = _itemFactory.makeVariant(role,attr.second);
itemType->replaceAttribute( newValue, role );
}
}
};
// #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() )
{
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() )
{
//qDebug() << "---- kloppo: " << sheetChild->tag_name() << ": " << sheetChild->to_string();
extendItemType( sheetChild );
}
// empty row:
// 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.
//! erzegt den sichtbaren inhalt des models aus einem root-datenknoten.
void XQChildModel::setContent( const XQNodePtr& contentRoot )
{
@@ -113,14 +47,20 @@ void XQChildModel::setContent( const XQNodePtr& contentRoot )
// haben, hier: <Panel>. <Battery> ...
for (const auto& contentEntry : _contentRoot->children())
{
qDebug() << " --- GOGOGO: 00: " << contentEntry->to_string();
// Das ist hier der Typ des Eintrags: Panel, Battery ...
QString key = contentEntry->tag_name();
qDebug() << " --- GOGOGO: " << key;
// 'silent failure' hier der Datenbaum kann auch Knoten enthalten
// die nicht für uns gedacht sind.
if (!_sections.hasValidSection(key))
continue;
qDebug() << " --- GOGOGO: FOUND!" << key;
XQModelSection& section = _sections.at( key );
// wir speichern das parent des datenknoten auch in der
// section.
@@ -128,8 +68,10 @@ void XQChildModel::setContent( const XQNodePtr& contentRoot )
section.contentRootNode = contentEntry->parent();
int newRow = _sections.lastRow(section);
//qDebug() << " --- AHJA: " << key << " -- last Row dazu: " << newRow;
XQItemList list = _itemFactory.makeContentRow( contentEntry, section.sheetRootNode );
XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode, contentEntry );
qDebug() << " --- AHJA: " << key << " -- last Row dazu: " << newRow;
// als Baum?
//section.headerItem().appendRow( list );
insertRow( newRow, list);