trashed it.

This commit is contained in:
2025-08-20 23:04:09 +02:00
parent 0ec1f7a7c0
commit 306a68f6c9
4 changed files with 62 additions and 16 deletions

View File

@@ -123,8 +123,8 @@ void XQMainWindow::initMainWindow()
_mainModelView.initModel( c_MainModelName ); _mainModelView.initModel( c_MainModelName );
// #2. load demo data // #2. load demo data
loadDocument( c_DocumentFileName1 ); //loadDocument( c_DocumentFileName1 );
loadDocument( c_DocumentFileName2 ); //loadDocument( c_DocumentFileName2 );
qDebug() << " --- all here: " << XQNode::s_Count; qDebug() << " --- all here: " << XQNode::s_Count;
@@ -261,6 +261,10 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
_mainTreeView->selectionModel()->select(index, QItemSelectionModel::Select); _mainTreeView->selectionModel()->select(index, QItemSelectionModel::Select);
//entry.setBackground( QBrush( Qt::green ) ); //entry.setBackground( QBrush( Qt::green ) );
QVariant variant = entry.QStandardItem::data( XQItem::ContentNodeRole );
XQNodePtr ptr = variant.value<XQNodePtr>();
QString key = entry.attribute(c_ProjectID); QString key = entry.attribute(c_ProjectID);
qDebug() << " --- FIRZ: key: " << key; qDebug() << " --- FIRZ: key: " << key;

View File

@@ -303,6 +303,25 @@ XQItemList XQItemFactory::createGenericRow( const XQNodePtr& contentNode, const
*/ */
//! erzeugt eine header-item row.
XQItemList XQItemFactory::makeHeaderRow( const XQNodePtr& sheetNode )
{
XQItemList list;
for( const auto& sheetEntry : sheetNode->children() )
{
list.append( makeHeaderItem( sheetEntry ) );
}
Q_ASSERT(!list.empty());
return list;
}
//! erzeugt eine item-row. //! erzeugt eine item-row.
XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ) XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
@@ -321,20 +340,37 @@ XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNo
// //
for( const auto& sheetEntry : sheetNode->children() ) for( const auto& sheetEntry : sheetNode->children() )
{ {
list.append( makeItem( sheetEntry, contentNode ) ); list.append( makeContentItem( sheetEntry, contentNode ) );
} }
if( !list.empty() ) Q_ASSERT(!list.empty());
{
// wir merken uns den original content node auch, aber // wir merken uns den original content node auch, aber
// im ersten Item. // im ersten Item.
dynamic_cast<XQItem*>(list[0])->setContentNode(contentNode); dynamic_cast<XQItem*>(list[0])->setContentNode(contentNode);
}
return list; return list;
} }
XQItem* XQItemFactory::makeHeaderItem( const XQNodePtr& sheetNode )
{
// den itemtype des neuen items rausfinden
XQItemType* itemType = makeItemType(sheetNode); // throws
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
// der content wird indirect über den tag-name des sheetnode geholt
XQItem* newItem = new XQItem( itemType, sheetNode->attribute_ptr(c_Caption) );
// __fixme!
if( newItem->isCheckable() )
newItem->setCheckState( Qt::Checked );
return newItem;
}
//! fixme! unsinn! //! fixme! unsinn!
//! erzeugt ein XQItem aus einer typ-beschreibung ('sheetNode') und einem daten-knoten ('contentNode'). //! erzeugt ein XQItem aus einer typ-beschreibung ('sheetNode') und einem daten-knoten ('contentNode').
//! wenn der content node nicht gesetzt ist, wird stattdess das attribut 'Caption' aus der typ-beschreibung //! wenn der content node nicht gesetzt ist, wird stattdess das attribut 'Caption' aus der typ-beschreibung

View File

@@ -34,12 +34,12 @@ public:
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ); //XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
// wozu ist das gut? XQItemList makeHeaderRow( const XQNodePtr& sheetNode );
//XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); // wozu ist das gut?
XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr ); //XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
XQStaticItem* makeStaticItem( const XQNodePtr& sheetNode, const QString& contentPtr ); XQStaticItem* makeStaticItem( const XQNodePtr& sheetNode, const QString& contentPtr );
@@ -53,6 +53,12 @@ protected:
bool isValid(); bool isValid();
XQItem* makeHeaderItem( const XQNodePtr& sheetNode );
XQItem* makeContentItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr );
// shortcuts // shortcuts
using ItemConfigFunc = std::function<void( XQItem* item, const QString& attrValue, XQNodePtr contentNode, XQNodePtr sheetNode )>; using ItemConfigFunc = std::function<void( XQItem* item, const QString& attrValue, XQNodePtr contentNode, XQNodePtr sheetNode )>;
using ItemConfigMap = QMap<QString,ItemConfigFunc>; using ItemConfigMap = QMap<QString,ItemConfigFunc>;

View File

@@ -107,8 +107,8 @@ void XQViewModel::initModel(const QString& modelName)
// #2: (optionalen?) header erzeugen // #2: (optionalen?) header erzeugen
const XQNodePtr header = sectionNode->find_child_by_tag_name( c_Header ); const XQNodePtr header = sectionNode->find_child_by_tag_name( c_Header );
if( header ) if( header )
{ {
XQItemList list = _itemFactory.makeContentRow( header, nullptr ); XQItemList list = _itemFactory.makeHeaderRow( header );
addSection(list, sectionNode ); addSection(list, sectionNode );
} }