84 lines
2.1 KiB
C++
84 lines
2.1 KiB
C++
/***************************************************************************
|
|
|
|
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}
|
|
{
|
|
|
|
}
|
|
|
|
//! initialisiert dieses model über den namen.
|
|
|
|
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 );
|
|
}
|
|
}
|
|
|
|
|
|
//! erzeugt einen eintrag in der baum-übersicht.
|
|
|
|
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 );
|
|
_treeTable->expand( section.modelIndex );
|
|
// ??
|
|
_treeTable->setCurrentIndex( section.modelIndex );
|
|
newTreeentry->setContentNode(contentNode);
|
|
emit xqItemCreated( newTreeentry );
|
|
return newTreeentry;
|
|
}
|
|
}
|
|
throw XQException( "createTreeEntry: main model should not be emtpy!" );
|
|
}
|
|
|
|
//! firz
|
|
|
|
void XQMainModel::initContextMenu()
|
|
{
|
|
}
|
|
|
|
|