created src subdir.
This commit is contained in:
83
src/application/xqmainmodel.cpp
Normal file
83
src/application/xqmainmodel.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
|
||||
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 <xqtreeview.h>
|
||||
#include <xqitemdelegate.h>
|
||||
#include <xqitem.h>
|
||||
#include <xqappdata.h>
|
||||
#include <xqselectionmodel.h>
|
||||
#include <xqitemfactory.h>
|
||||
|
||||
|
||||
XQMainModel::XQMainModel(QObject *parent )
|
||||
: XQModel{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()
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user