2025-08-22 22:57:06 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
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 <QPersistentModelIndex>
|
|
|
|
#include <QClipboard>
|
|
|
|
|
|
|
|
#include <xqmainmodel.h>
|
|
|
|
|
|
|
|
#include <xqexception.h>
|
|
|
|
#include <xqtreetable.h>
|
|
|
|
#include <xqitemdelegate.h>
|
|
|
|
#include <xqitem.h>
|
|
|
|
#include <xqappdata.h>
|
|
|
|
#include <xqselectionmodel.h>
|
|
|
|
#include <xqitemfactory.h>
|
|
|
|
|
|
|
|
|
|
|
|
//! 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
|
|
|
|
|
2025-08-23 19:33:29 +02:00
|
|
|
|
2025-08-22 22:57:06 +02:00
|
|
|
for(const auto& section : _sections )
|
|
|
|
{
|
2025-08-27 14:06:31 +02:00
|
|
|
if( contentNode->attribute(c_ContentType) == section.contentType() )
|
2025-08-22 22:57:06 +02:00
|
|
|
{
|
2025-08-23 19:33:29 +02:00
|
|
|
qDebug() << " --- add PROJECT: contentNode: " << contentNode->to_string();
|
|
|
|
|
2025-08-22 22:57:06 +02:00
|
|
|
// __fixme! das ist mist!
|
|
|
|
const XQNodePtr sheetNode = section.sheetRootNode()->first_child();
|
2025-08-27 14:06:31 +02:00
|
|
|
XQItem* newItem = _itemFactory.makeSingleItem( sheetNode, contentNode->attribute( "ProjectName") );
|
2025-08-22 22:57:06 +02:00
|
|
|
|
|
|
|
// den neuen eintrag in die passende section der übersicht eintragen ...
|
2025-08-27 14:06:31 +02:00
|
|
|
section.headerItem().appendRow( newItem );
|
2025-08-22 22:57:06 +02:00
|
|
|
// ... ausklappen...
|
|
|
|
const QModelIndex index = section.headerItem().index();
|
|
|
|
_treeTable->expand( index );
|
|
|
|
// ... und markieren
|
|
|
|
_treeTable->setCurrentIndex( index );
|
|
|
|
// quellknoten auch speichern
|
|
|
|
//newItem->setContentNode( contentNode );
|
|
|
|
//emit itemCreated( newItem );
|
|
|
|
|
2025-08-24 22:30:58 +02:00
|
|
|
// erzeuger sheet node speichern
|
|
|
|
newItem->setSheetNode( sheetNode );
|
|
|
|
return newItem;
|
2025-08-22 22:57:06 +02:00
|
|
|
}
|
|
|
|
}
|
2025-08-23 19:33:29 +02:00
|
|
|
|
2025-08-22 22:57:06 +02:00
|
|
|
throw XQException( "addProjectItem: main model should not be empty!" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
|
|
|
{
|
2025-08-27 14:06:31 +02:00
|
|
|
qDebug() << " --- SUPPA0: " << section.contentType();
|
|
|
|
qDebug() << " --- SUPPA1: -> " << projectItem->contentNode()->to_string();
|
|
|
|
qDebug() << " --- SUPPA2: -> " << projectItem->sheetNode()->to_string();
|
|
|
|
qDebug() << " --- SUPPA3: -> " << projectItem->sheetNode()->find_child_by_tag_name("CurrentSection")->to_string();
|
|
|
|
|
|
|
|
XQNodePtr sectionChild = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");
|
|
|
|
|
|
|
|
//qDebug() << " --- SUPPA4: -> " << section.contentRootNode()->to_string();
|
|
|
|
|
2025-08-24 14:19:39 +02:00
|
|
|
return;
|
2025-08-24 22:30:58 +02:00
|
|
|
|
2025-08-27 14:06:31 +02:00
|
|
|
//
|
|
|
|
if(sectionChild)
|
|
|
|
{
|
|
|
|
//XQItemList list = _itemFactory.makeRow( XQItemFactory::mStatic, sectionChild, nullptr, section.contentType() );
|
|
|
|
//projectItem->appendRow( list );
|
|
|
|
_treeTable->expand( projectItem->index() );
|
2025-08-24 22:30:58 +02:00
|
|
|
|
2025-08-27 14:06:31 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
for(const auto& xsection : _sections )
|
|
|
|
{
|
|
|
|
|
|
|
|
if( projectItem->contentNode()->attribute(c_ContentType) == xsection.contentType() )
|
|
|
|
{
|
|
|
|
|
|
|
|
//qDebug() << " --- FITZ;: contentNode: " << contentNode->to_string();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2025-08-24 22:30:58 +02:00
|
|
|
// ich brauche _meine_ section für den sheetNode!
|
|
|
|
|
2025-08-24 14:19:39 +02:00
|
|
|
|
2025-08-27 14:06:31 +02:00
|
|
|
/*
|
2025-08-22 22:57:06 +02:00
|
|
|
XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");
|
2025-08-24 09:44:51 +02:00
|
|
|
XQItemList list = _itemFactory.makeRow( XQItemFactory::mSingle, sheetNode, nullptr, c_ContentType );
|
|
|
|
projectItem->appendRow( list );
|
2025-08-22 22:57:06 +02:00
|
|
|
_treeTable->expand( projectItem->index() );
|
2025-08-27 14:06:31 +02:00
|
|
|
*/
|
2025-08-24 14:19:39 +02:00
|
|
|
|
2025-08-22 22:57:06 +02:00
|
|
|
}
|