Files
xtree.old.ng/src/application/xqmainmodel.cpp

79 lines
2.0 KiB
C++
Raw Normal View History

2025-08-05 22:39:41 +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>
2025-08-07 03:11:56 +02:00
#include <xqtreetable.h>
2025-08-05 22:39:41 +02:00
#include <xqitemdelegate.h>
#include <xqitem.h>
#include <xqappdata.h>
#include <xqselectionmodel.h>
#include <xqitemfactory.h>
2025-08-08 21:39:33 +02:00
//! default konstruktor.
2025-08-05 22:39:41 +02:00
XQMainModel::XQMainModel(QObject *parent )
2025-08-07 03:11:56 +02:00
: XQViewModel{parent}
2025-08-05 22:39:41 +02:00
{
}
2025-08-11 22:27:55 +02:00
//! leere default implementation
2025-08-05 22:39:41 +02:00
void XQMainModel::initContextMenu()
{
}
2025-08-16 22:03:41 +02:00
//! erzeugt einen eintrag in der baum-übersicht.
XQItem* XQMainModel::makeTreeItem( XQNodePtr contentNode )
2025-08-16 22:03:41 +02:00
{
// wir durchsuchen alle unsere section nach dem passenden content-type,
// hier: content-type beschreibt die
2025-08-16 22:03:41 +02:00
for(const auto& section : _sections )
{
if( contentNode->attribute( c_ContentType) == section.contentType() )
2025-08-16 22:03:41 +02:00
{
qDebug() << " --- wtf1: " << contentNode->to_string();
qDebug() << " --- wtf2: " << section.sectionRootNode()->to_string();
qDebug() << " --- wtf3: " << section.sheetRootNode()->to_string();
2025-08-16 22:03:41 +02:00
const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" );
// __fixme! das ist mist!
XQItem* newItem = _itemFactory.makeItem(section.sheetRootNode()->child(0), contentPtr );
2025-08-16 22:03:41 +02:00
section.headerItem().appendRow( newItem );
_treeTable->expand( section.modelIndex() );
// ??
_treeTable->setCurrentIndex( section.modelIndex() );
newItem->setContentNode(contentNode);
emit itemCreated( newItem );
2025-08-16 22:03:41 +02:00
return newItem;
}
2025-08-16 22:03:41 +02:00
}
throw XQException( "makeTreeItem: main model should not be empty!" );
2025-08-16 22:03:41 +02:00
}