/*************************************************************************** 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 #include #include #include #include #include #include #include #include #include XQMainModel::XQMainModel(QObject *parent ) : XQViewModel{parent} { } XQMainModel::~XQMainModel() { // delete } void XQMainModel::initModel(const QString& modelName) { XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // #1: create structure: create static sections for this model for( auto& sheetNode : modelSheet->children() ) { qDebug() << " create main model: " << sheetNode->tag_name(); XQItemList list = { _itemFactory.makeHeaderItem( sheetNode ) }; Q_ASSERT(!list.isEmpty()); addSection(list, sheetNode ); //appendRow( list ); } } XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode ) { for(const auto& section : _sections ) { if( contentNode->attribute("State") == section.sheetRootNode->attribute("State") ) { XQItem* newTreeentry = _itemFactory.makeContentItem( contentNode, section.sheetRootNode ); section.headerItem().appendRow( newTreeentry ); _treeView->expand( section.modelIndex ); // ?? _treeView->setCurrentIndex( section.modelIndex ); newTreeentry->setContentNode(contentNode); emit xqItemCreated( newTreeentry ); return newTreeentry; } } throw XQException( "createTreeEntry: main model should not be emtpy!" ); } void XQMainModel::initContextMenu() { }