Files
xtree.old.ng/src/application/xqmainmodel.cpp
Christoph Holzheuer 429c939cdf some fixes
2025-08-18 16:09:47 +02:00

90 lines
2.4 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}
{
}
//! 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() )
{
const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" );
// __fixme! das ist mist!
const XQNodePtr sheetNode = section.sheetRootNode()->first_child();
XQItem* newItem = _itemFactory.makeItem(sheetNode, contentPtr );
// den neuen eintrag in die passende section der übersicht eintragen ...
section.headerItem().appendRow( newItem );
// ... ausklappen...
const QModelIndex index = section.headerItem().index();
_treeTable->expand( index );
// ... und markieren
_treeTable->setCurrentIndex( index );
// den gesamten projekt knoten speichern, warum?
//newItem->setContentNode(contentNode);
// erzeuger sheet node speichern
newItem->setSheetNode( sheetNode );
emit itemCreated( newItem );
return newItem;
}
}
throw XQException( "addProjectItem: main model should not be empty!" );
}
/*
XQItem* XQMainModel::addSectionItem( XQItem* projectItem )
{
const XQNodePtr& parentSheet = projectItem->sheetNode();
const XQNodePtr sheetNode = parentSheet->first_child();
return _itemFactor.makeItem( sheetNode, new QString("fitz!"));
}
*/