/*************************************************************************** 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 //! default konstruktor. XQMainModel::XQMainModel(QObject *parent ) : XQViewModel{parent} { } //! leere default implementation void XQMainModel::initContextMenu() { } //! erzeugt einen eintrag in der baum-übersicht. XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode ) { // wir durchsuchen alle unsere section nach dem passenden content-type, // hier: content-type beschreibt die for(const auto& section : _sections ) { if( contentNode->attribute( c_ContentType) == section.contentType() ) { qDebug() << " --- add PROJECT: contentNode: " << contentNode->to_string(); // __fixme! das ist mist! const XQNodePtr sheetNode = section.sheetRootNode()->first_child(); XQItemList list = _itemFactory.makeRow( XQItemFactory::mSingle, sheetNode, contentNode, "ProjectName"); // erzeuger sheet node speichern //newItem->setSheetNode( sheetNode ); // den neuen eintrag in die passende section der übersicht eintragen ... section.headerItem().appendRow( list ); // ... ausklappen... const QModelIndex index = section.headerItem().index(); _treeTable->expand( index ); // ... und markieren _treeTable->setCurrentIndex( index ); // quellknoten auch speichern //newItem->setContentNode( contentNode ); //emit itemCreated( newItem ); return dynamic_cast(list[0]); } } throw XQException( "addProjectItem: main model should not be empty!" ); } void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem ) { return; qDebug() << " --- addSecxtion: " << projectItem->sheetNode()->to_string(); return; XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection"); XQItemList list = _itemFactory.makeRow( XQItemFactory::mSingle, sheetNode, nullptr, c_ContentType ); projectItem->appendRow( list ); _treeTable->expand( projectItem->index() ); }