adding projects to project tree works again.
This commit is contained in:
@@ -29,7 +29,7 @@ const QString c_ItemType = "ItemType";
|
||||
const QString c_Caption = "Caption";
|
||||
const QString c_Header = "Header";
|
||||
const QString c_ContentType = "ContentType";
|
||||
const QString c_Data = "Data";
|
||||
const QString c_ModelSheet = "ModelSheet";
|
||||
|
||||
const QString c_MainModelName = "DocumentTreeModel";
|
||||
const QString c_ChildModelName = "DocumentDetailsModel";
|
||||
|
@@ -43,40 +43,36 @@ void XQMainModel::initContextMenu()
|
||||
|
||||
//! 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 )
|
||||
{
|
||||
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:
|
||||
// den itemtype des neuen items rausfinden
|
||||
QString typeKey = sheetEntry->attribute("ItemType");
|
||||
XQItemType* itemType = findItemTypeTemplate(typeKey); // throws
|
||||
//XQItemType* itemType = makeItemType(sheetEntry); // throws
|
||||
if( contentNode->attribute( c_ContentType) == section.contentType() )
|
||||
{
|
||||
|
||||
qDebug() << " --- wtf1: " << contentNode->to_string();
|
||||
qDebug() << " --- wtf2: " << section.sectionRootNode()->to_string();
|
||||
qDebug() << " --- wtf3: " << section.sheetRootNode()->to_string();
|
||||
|
||||
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;
|
||||
|
||||
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!" );
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ public:
|
||||
explicit XQMainModel(QObject *parent = nullptr);
|
||||
virtual ~XQMainModel() = default;
|
||||
|
||||
XQItem* createTreeEntry( XQNodePtr contentNode );
|
||||
XQItem* makeTreeItem( XQNodePtr contentNode );
|
||||
|
||||
public slots:
|
||||
|
||||
|
@@ -15,12 +15,14 @@
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <xqmainwindow.h>
|
||||
#include <xqcommand.h>
|
||||
#include <xqexception.h>
|
||||
#include <xqitemfactory.h>
|
||||
#include <xqnodewriter.h>
|
||||
#include <xqquickwidget.h>
|
||||
|
||||
|
||||
//! konstruktor.
|
||||
@@ -91,7 +93,13 @@ void XQMainWindow::initMainWindow()
|
||||
|
||||
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)
|
||||
@@ -324,15 +332,14 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
||||
connect( childModel, SIGNAL(sectionCreated(XQModelSection)), this, SLOT(onSectionCreated(XQModelSection)) );
|
||||
connect( childModel, SIGNAL(sectionToggled(XQModelSection)), this, SLOT(onSectionToggled(XQModelSection)) );
|
||||
|
||||
|
||||
// Den globalen undo-stack ...
|
||||
childModel->setUndoStack(&_undoStack);
|
||||
|
||||
// und die TreeView übergeben
|
||||
childModel->setTreeTable(childTreeView);
|
||||
|
||||
// create new entry in the left side main tree view
|
||||
//XQItem* newEntry = _mainModelView.createTreeEntry( contentRoot );
|
||||
// neuen eintrag im übsichts-baum erzeugen
|
||||
XQItem* newEntry = _mainModelView.makeTreeItem( contentRoot );
|
||||
//_mainTreeView->setCurrentIndex( newEntry->index() );
|
||||
//_documentStore.addDocument( fileName, pTitle, newEntry, childModel );
|
||||
|
||||
|
@@ -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').
|
||||
//! 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.
|
||||
|
||||
XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
||||
{
|
||||
// den itemtype des neuen items rausfinden
|
||||
QString typeKey = sheetNode->attribute(c_ItemType);
|
||||
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
||||
// der content wird indirect über den tag-name des sheetnode geholt
|
||||
|
||||
XQItemType* itemType = makeItemType(sheetNode); // throws
|
||||
// fallunterscheidung beim inhalt:
|
||||
const QString* contentPtr{};
|
||||
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
||||
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
|
||||
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 );
|
||||
|
||||
// __fixme!
|
||||
if( newItem->isCheckable() )
|
||||
{
|
||||
//qDebug() << " --- yooo: " << newItem->toolTip();
|
||||
@@ -286,7 +298,6 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& co
|
||||
}
|
||||
|
||||
return newItem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -30,10 +30,10 @@ public:
|
||||
|
||||
void initItemFactory(const QString& modelSheetFileName );
|
||||
|
||||
XQNodePtr findModelSheet( const QString& modelName ) const;
|
||||
|
||||
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode=nullptr);
|
||||
XQNodePtr findModelSheet( const QString& modelName ) const;
|
||||
|
||||
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 makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
||||
|
@@ -60,7 +60,7 @@ XQNodePtr XQModelSection::sectionRootNode() const
|
||||
|
||||
XQNodePtr XQModelSection::sheetRootNode() const
|
||||
{
|
||||
return _sectionRootNode->find_child_by_tag_name( c_Data );
|
||||
return _sectionRootNode->find_child_by_tag_name( c_ModelSheet );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
QT += core gui widgets
|
||||
QT += core gui widgets quick quickwidgets
|
||||
# widgets-private
|
||||
|
||||
CONFIG += c++20
|
||||
@@ -43,6 +43,7 @@ HEADERS += \
|
||||
util/xsingleton.h \
|
||||
util/xtreewalker.h \
|
||||
widgets/xqcontextmenu.h \
|
||||
widgets/xqquickwidget.h \
|
||||
widgets/xqtreetable.h
|
||||
|
||||
SOURCES += \
|
||||
@@ -67,6 +68,7 @@ SOURCES += \
|
||||
pugixml/pugixml.cpp \
|
||||
util/xqexception.cpp \
|
||||
widgets/xqcontextmenu.cpp \
|
||||
widgets/xqquickwidget.cpp \
|
||||
widgets/xqtreetable.cpp
|
||||
|
||||
|
||||
@@ -82,6 +84,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
DISTFILES += \
|
||||
../quick/xqmodelview.qml \
|
||||
README.md \
|
||||
xml/modelsheets.xml \
|
||||
xml/modeldata1.xtr \
|
||||
|
@@ -26,25 +26,25 @@
|
||||
<Header>
|
||||
<Entry Caption="Active Projects" ItemType="TreeParentType"/>
|
||||
</Header>
|
||||
<Data>
|
||||
<ModelSheet firz="running">
|
||||
<Project Caption="@ProjectName" ItemType="TreeParentType"/>
|
||||
</Data>
|
||||
</ModelSheet>
|
||||
</Section>
|
||||
<Section ContentType="planned">
|
||||
<Header>
|
||||
<Entry Caption="Planned Projects" ItemType="TreeParentType"/>
|
||||
</Header>
|
||||
<Data>
|
||||
<ModelSheet firz="planned">
|
||||
<Project Caption="@ProjectName" ItemType="TreeParentType"/>
|
||||
</Data>
|
||||
</ModelSheet>
|
||||
</Section>
|
||||
<Section ContentType="finished">
|
||||
<Header>
|
||||
<Entry Caption="Finished Projects" ItemType="TreeParentType"/>
|
||||
</Header>
|
||||
<Data>
|
||||
<ModelSheet firz="finished">
|
||||
<Project Caption="@ProjectName" ItemType="TreeParentType"/>
|
||||
</Data>
|
||||
</ModelSheet>
|
||||
</Section>
|
||||
</DocumentTreeModel>
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
||||
<MaxAmpere Caption="max. Ampere" ItemType="HeaderType" />
|
||||
</Header>
|
||||
<Data Marker="Panel">
|
||||
<ModelSheet Marker="Panel">
|
||||
<!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
||||
<PanelID ItemType="PlainType" Icon="DesktopIcon"/>
|
||||
<PanelName ItemType="PlainType" Icon="BrowserStop"/>
|
||||
@@ -77,7 +77,7 @@
|
||||
<Weight ItemType="ValueType" UnitType="kg"/>
|
||||
<MaxVolt ItemType="ValueType" UnitType="V"/>
|
||||
<MaxAmpere ItemType="ValueType" UnitType="A"/>
|
||||
</Data>
|
||||
</ModelSheet>
|
||||
</Section>
|
||||
|
||||
<Section ContentType="Inverter" firz="farz">
|
||||
@@ -90,15 +90,15 @@
|
||||
<NumStrings Caption="Strings" ItemType="HeaderType" />
|
||||
<Weight Caption="Weight" ItemType="HeaderType" />
|
||||
</Header>
|
||||
<Data Marker="Inverter">
|
||||
<ModelSheet Marker="Inverter">
|
||||
<InverterID Caption="Inverter" ItemType="ValueType" />
|
||||
<InverterName Caption="Name" 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"/>
|
||||
<NumStrings Caption="Strings" ItemType="ValueType" />
|
||||
<Weight Caption="Weight" ItemType="ValueType" UnitType="kg"/>
|
||||
</Data>
|
||||
</ModelSheet>
|
||||
</Section>
|
||||
|
||||
<Section ContentType="Battery" firz="farz">
|
||||
@@ -111,7 +111,7 @@
|
||||
<MaxCurrent Caption="max. Current" ItemType="HeaderType" />
|
||||
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
||||
</Header>
|
||||
<Data Marker="Bettery">
|
||||
<ModelSheet Marker="Bettery">
|
||||
<BatteryID Caption="Battery" ItemType="ValueType" />
|
||||
<BatteryName Caption="Name" ItemType="ValueType" />
|
||||
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
||||
@@ -119,7 +119,7 @@
|
||||
<Yield Caption="Yield" ItemType="ValueType" ItemType="PercentageType" UnitType="%"/>
|
||||
<MaxCurrent Caption="max. Current" ItemType="ValueType" UnitType="A"/>
|
||||
<MaxVolt Caption="max. Volt" ItemType="ValueType" UnitType="V"/>
|
||||
</Data>
|
||||
</ModelSheet>
|
||||
</Section>
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user