adding projects to project tree works again.

This commit is contained in:
2025-08-17 11:50:26 +02:00
parent a13a1de8fe
commit 372873717e
9 changed files with 69 additions and 52 deletions

View File

@@ -29,7 +29,7 @@ const QString c_ItemType = "ItemType";
const QString c_Caption = "Caption"; const QString c_Caption = "Caption";
const QString c_Header = "Header"; const QString c_Header = "Header";
const QString c_ContentType = "ContentType"; const QString c_ContentType = "ContentType";
const QString c_Data = "Data"; const QString c_ModelSheet = "ModelSheet";
const QString c_MainModelName = "DocumentTreeModel"; const QString c_MainModelName = "DocumentTreeModel";
const QString c_ChildModelName = "DocumentDetailsModel"; const QString c_ChildModelName = "DocumentDetailsModel";

View File

@@ -43,40 +43,36 @@ void XQMainModel::initContextMenu()
//! erzeugt einen eintrag in der baum-übersicht. //! erzeugt einen eintrag in der baum-übersicht.
XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode ) XQItem* XQMainModel::makeTreeItem( XQNodePtr contentNode )
{ {
// wir durchsuchen alle unsere section nach dem passenden content-type,
// hier: content-type beschreibt die
for(const auto& section : _sections ) for(const auto& section : _sections )
{ {
qDebug() << " --- wtf1: " << contentNode->to_string();
qDebug() << " --- wtf2: " << section.sheetRootNode()->to_string();
/*
if( contentNode->attribute("State") == section.sheetRootNode->attribute("State") )
{
//XQItem* newTreeentry = _itemFactory.makeTreeChildItem( contentNode, section.sheetRootNode );
makeTreeChildItem: if( contentNode->attribute( c_ContentType) == section.contentType() )
// den itemtype des neuen items rausfinden {
QString typeKey = sheetEntry->attribute("ItemType");
XQItemType* itemType = findItemTypeTemplate(typeKey); // throws qDebug() << " --- wtf1: " << contentNode->to_string();
//XQItemType* itemType = makeItemType(sheetEntry); // throws qDebug() << " --- wtf2: " << section.sectionRootNode()->to_string();
qDebug() << " --- wtf3: " << section.sheetRootNode()->to_string();
const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" ); const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" );
// __fixme! das ist mist!
XQItem* newItem = _itemFactory.makeItem(section.sheetRootNode()->child(0), contentPtr );
XQItem* newItem = new XQItem( itemType, contentPtr ); section.headerItem().appendRow( newItem );
_treeTable->expand( section.modelIndex() );
// ??
_treeTable->setCurrentIndex( section.modelIndex() );
newItem->setContentNode(contentNode);
emit itemCreated( newItem );
return newItem; return newItem;
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 empty!" ); throw XQException( "makeTreeItem: main model should not be empty!" );
} }

View File

@@ -32,7 +32,7 @@ public:
explicit XQMainModel(QObject *parent = nullptr); explicit XQMainModel(QObject *parent = nullptr);
virtual ~XQMainModel() = default; virtual ~XQMainModel() = default;
XQItem* createTreeEntry( XQNodePtr contentNode ); XQItem* makeTreeItem( XQNodePtr contentNode );
public slots: public slots:

View File

@@ -15,12 +15,14 @@
#include <QDebug> #include <QDebug>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton>
#include <xqmainwindow.h> #include <xqmainwindow.h>
#include <xqcommand.h> #include <xqcommand.h>
#include <xqexception.h> #include <xqexception.h>
#include <xqitemfactory.h> #include <xqitemfactory.h>
#include <xqnodewriter.h> #include <xqnodewriter.h>
#include <xqquickwidget.h>
//! konstruktor. //! konstruktor.
@@ -91,7 +93,13 @@ void XQMainWindow::initMainWindow()
connect( _tabWidget, SIGNAL(tabBarClicked(int)), this, SLOT(onTabClicked(int)) ); connect( _tabWidget, SIGNAL(tabBarClicked(int)), this, SLOT(onTabClicked(int)) );
/*
XQQuickWidget* butt = new XQQuickWidget;
butt->resize(800,600);
butt->setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint);
butt->move( 1200,300);
butt->show();
*/
/* /*
connect( &_mainModelView, &XQViewModel::itemCreated, this, [=, this](XQItem* item) connect( &_mainModelView, &XQViewModel::itemCreated, this, [=, this](XQItem* item)
@@ -324,15 +332,14 @@ void XQMainWindow::loadDocument( const QString& fileName )
connect( childModel, SIGNAL(sectionCreated(XQModelSection)), this, SLOT(onSectionCreated(XQModelSection)) ); connect( childModel, SIGNAL(sectionCreated(XQModelSection)), this, SLOT(onSectionCreated(XQModelSection)) );
connect( childModel, SIGNAL(sectionToggled(XQModelSection)), this, SLOT(onSectionToggled(XQModelSection)) ); connect( childModel, SIGNAL(sectionToggled(XQModelSection)), this, SLOT(onSectionToggled(XQModelSection)) );
// Den globalen undo-stack ... // Den globalen undo-stack ...
childModel->setUndoStack(&_undoStack); childModel->setUndoStack(&_undoStack);
// und die TreeView übergeben // und die TreeView übergeben
childModel->setTreeTable(childTreeView); childModel->setTreeTable(childTreeView);
// create new entry in the left side main tree view // neuen eintrag im übsichts-baum erzeugen
//XQItem* newEntry = _mainModelView.createTreeEntry( contentRoot ); XQItem* newEntry = _mainModelView.makeTreeItem( contentRoot );
//_mainTreeView->setCurrentIndex( newEntry->index() ); //_mainTreeView->setCurrentIndex( newEntry->index() );
//_documentStore.addDocument( fileName, pTitle, newEntry, childModel ); //_documentStore.addDocument( fileName, pTitle, newEntry, childModel );

View File

@@ -259,17 +259,16 @@ QVariant XQItemFactory::makeVariant( int dataRole, const QString& source ) const
/// ///
//! fixme! unsinn!
//! erzeugt ein XQItem aus einer typ-beschreibung ('sheetNode') und einem daten-knoten ('contentNode'). //! erzeugt ein XQItem aus einer typ-beschreibung ('sheetNode') und einem daten-knoten ('contentNode').
//! wenn der content node nicht gesetzt ist, wird stattdess das attribut 'Caption' aus der typ-beschreibung //! wenn der content node nicht gesetzt ist, wird stattdess das attribut 'Caption' aus der typ-beschreibung
//! verwendet: es handelt sich dann um ein header item, das erzeugt wurde. //! verwendet: es handelt sich dann um ein header item, das erzeugt wurde.
XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ) XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
{ {
// den itemtype des neuen items rausfinden // das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
QString typeKey = sheetNode->attribute(c_ItemType); // der content wird indirect über den tag-name des sheetnode geholt
XQItemType* itemType = makeItemType(sheetNode); // throws
// fallunterscheidung beim inhalt:
const QString* contentPtr{}; const QString* contentPtr{};
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung // das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
if(!contentNode) if(!contentNode)
@@ -278,7 +277,20 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& co
// der content wird indirect über den tag-name des sheetnode geholt // der content wird indirect über den tag-name des sheetnode geholt
contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() ); contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() );
return makeItem( sheetNode, contentPtr );
}
XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const QString* contentPtr )
{
// den itemtype des neuen items rausfinden
QString typeKey = sheetNode->attribute(c_ItemType);
XQItemType* itemType = makeItemType(sheetNode); // throws
XQItem* newItem = new XQItem( itemType, contentPtr ); XQItem* newItem = new XQItem( itemType, contentPtr );
// __fixme!
if( newItem->isCheckable() ) if( newItem->isCheckable() )
{ {
//qDebug() << " --- yooo: " << newItem->toolTip(); //qDebug() << " --- yooo: " << newItem->toolTip();
@@ -286,7 +298,6 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& co
} }
return newItem; return newItem;
} }

View File

@@ -30,10 +30,10 @@ public:
void initItemFactory(const QString& modelSheetFileName ); void initItemFactory(const QString& modelSheetFileName );
XQNodePtr findModelSheet( const QString& modelName ) const; XQNodePtr findModelSheet( const QString& modelName ) const;
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode=nullptr);
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr );
XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ); //XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );

View File

@@ -60,7 +60,7 @@ XQNodePtr XQModelSection::sectionRootNode() const
XQNodePtr XQModelSection::sheetRootNode() const XQNodePtr XQModelSection::sheetRootNode() const
{ {
return _sectionRootNode->find_child_by_tag_name( c_Data ); return _sectionRootNode->find_child_by_tag_name( c_ModelSheet );
} }

View File

@@ -1,4 +1,4 @@
QT += core gui widgets QT += core gui widgets quick quickwidgets
# widgets-private # widgets-private
CONFIG += c++20 CONFIG += c++20
@@ -43,6 +43,7 @@ HEADERS += \
util/xsingleton.h \ util/xsingleton.h \
util/xtreewalker.h \ util/xtreewalker.h \
widgets/xqcontextmenu.h \ widgets/xqcontextmenu.h \
widgets/xqquickwidget.h \
widgets/xqtreetable.h widgets/xqtreetable.h
SOURCES += \ SOURCES += \
@@ -67,6 +68,7 @@ SOURCES += \
pugixml/pugixml.cpp \ pugixml/pugixml.cpp \
util/xqexception.cpp \ util/xqexception.cpp \
widgets/xqcontextmenu.cpp \ widgets/xqcontextmenu.cpp \
widgets/xqquickwidget.cpp \
widgets/xqtreetable.cpp widgets/xqtreetable.cpp
@@ -82,6 +84,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target !isEmpty(target.path): INSTALLS += target
DISTFILES += \ DISTFILES += \
../quick/xqmodelview.qml \
README.md \ README.md \
xml/modelsheets.xml \ xml/modelsheets.xml \
xml/modeldata1.xtr \ xml/modeldata1.xtr \

View File

@@ -26,25 +26,25 @@
<Header> <Header>
<Entry Caption="Active Projects" ItemType="TreeParentType"/> <Entry Caption="Active Projects" ItemType="TreeParentType"/>
</Header> </Header>
<Data> <ModelSheet firz="running">
<Project Caption="@ProjectName" ItemType="TreeParentType"/> <Project Caption="@ProjectName" ItemType="TreeParentType"/>
</Data> </ModelSheet>
</Section> </Section>
<Section ContentType="planned"> <Section ContentType="planned">
<Header> <Header>
<Entry Caption="Planned Projects" ItemType="TreeParentType"/> <Entry Caption="Planned Projects" ItemType="TreeParentType"/>
</Header> </Header>
<Data> <ModelSheet firz="planned">
<Project Caption="@ProjectName" ItemType="TreeParentType"/> <Project Caption="@ProjectName" ItemType="TreeParentType"/>
</Data> </ModelSheet>
</Section> </Section>
<Section ContentType="finished"> <Section ContentType="finished">
<Header> <Header>
<Entry Caption="Finished Projects" ItemType="TreeParentType"/> <Entry Caption="Finished Projects" ItemType="TreeParentType"/>
</Header> </Header>
<Data> <ModelSheet firz="finished">
<Project Caption="@ProjectName" ItemType="TreeParentType"/> <Project Caption="@ProjectName" ItemType="TreeParentType"/>
</Data> </ModelSheet>
</Section> </Section>
</DocumentTreeModel> </DocumentTreeModel>
@@ -65,7 +65,7 @@
<MaxVolt Caption="max. Volt" ItemType="HeaderType" /> <MaxVolt Caption="max. Volt" ItemType="HeaderType" />
<MaxAmpere Caption="max. Ampere" ItemType="HeaderType" /> <MaxAmpere Caption="max. Ampere" ItemType="HeaderType" />
</Header> </Header>
<Data Marker="Panel"> <ModelSheet Marker="Panel">
<!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType--> <!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
<PanelID ItemType="PlainType" Icon="DesktopIcon"/> <PanelID ItemType="PlainType" Icon="DesktopIcon"/>
<PanelName ItemType="PlainType" Icon="BrowserStop"/> <PanelName ItemType="PlainType" Icon="BrowserStop"/>
@@ -77,7 +77,7 @@
<Weight ItemType="ValueType" UnitType="kg"/> <Weight ItemType="ValueType" UnitType="kg"/>
<MaxVolt ItemType="ValueType" UnitType="V"/> <MaxVolt ItemType="ValueType" UnitType="V"/>
<MaxAmpere ItemType="ValueType" UnitType="A"/> <MaxAmpere ItemType="ValueType" UnitType="A"/>
</Data> </ModelSheet>
</Section> </Section>
<Section ContentType="Inverter" firz="farz"> <Section ContentType="Inverter" firz="farz">
@@ -90,15 +90,15 @@
<NumStrings Caption="Strings" ItemType="HeaderType" /> <NumStrings Caption="Strings" ItemType="HeaderType" />
<Weight Caption="Weight" ItemType="HeaderType" /> <Weight Caption="Weight" ItemType="HeaderType" />
</Header> </Header>
<Data Marker="Inverter"> <ModelSheet Marker="Inverter">
<InverterID Caption="Inverter" ItemType="ValueType" /> <InverterID Caption="Inverter" ItemType="ValueType" />
<InverterName Caption="Name" ItemType="ValueType" /> <InverterName Caption="Name" ItemType="ValueType" />
<Manufacturer Caption="Manufacturer" ItemType="ValueType" /> <Manufacturer Caption="Manufacturer" ItemType="ValueType" />
<MaxPowerInput Caption="max. Input" ItemType="ValueType" ItemType="ChoiceType" ChoiceDataSource="MaxPowerInputChoice" UnitType="W"/> <MaxPowerInput Caption="max. Input" ItemType="ValueType" ItemType="ChoiceType" ChoiceModelSheetSource="MaxPowerInputChoice" UnitType="W"/>
<MaxPowerOutput Caption="max Output" ItemType="ValueType" UnitType="W"/> <MaxPowerOutput Caption="max Output" ItemType="ValueType" UnitType="W"/>
<NumStrings Caption="Strings" ItemType="ValueType" /> <NumStrings Caption="Strings" ItemType="ValueType" />
<Weight Caption="Weight" ItemType="ValueType" UnitType="kg"/> <Weight Caption="Weight" ItemType="ValueType" UnitType="kg"/>
</Data> </ModelSheet>
</Section> </Section>
<Section ContentType="Battery" firz="farz"> <Section ContentType="Battery" firz="farz">
@@ -111,7 +111,7 @@
<MaxCurrent Caption="max. Current" ItemType="HeaderType" /> <MaxCurrent Caption="max. Current" ItemType="HeaderType" />
<MaxVolt Caption="max. Volt" ItemType="HeaderType" /> <MaxVolt Caption="max. Volt" ItemType="HeaderType" />
</Header> </Header>
<Data Marker="Bettery"> <ModelSheet Marker="Bettery">
<BatteryID Caption="Battery" ItemType="ValueType" /> <BatteryID Caption="Battery" ItemType="ValueType" />
<BatteryName Caption="Name" ItemType="ValueType" /> <BatteryName Caption="Name" ItemType="ValueType" />
<Manufacturer Caption="Manufacturer" ItemType="ValueType" /> <Manufacturer Caption="Manufacturer" ItemType="ValueType" />
@@ -119,7 +119,7 @@
<Yield Caption="Yield" ItemType="ValueType" ItemType="PercentageType" UnitType="%"/> <Yield Caption="Yield" ItemType="ValueType" ItemType="PercentageType" UnitType="%"/>
<MaxCurrent Caption="max. Current" ItemType="ValueType" UnitType="A"/> <MaxCurrent Caption="max. Current" ItemType="ValueType" UnitType="A"/>
<MaxVolt Caption="max. Volt" ItemType="ValueType" UnitType="V"/> <MaxVolt Caption="max. Volt" ItemType="ValueType" UnitType="V"/>
</Data> </ModelSheet>
</Section> </Section>