14 Commits

Author SHA1 Message Date
c4d5155ac3 last. 2025-10-16 07:43:46 +02:00
558ef154a6 Removed dead code. 2025-10-05 14:50:45 +02:00
f70e67e6ed Changed XML style, made znode attritbutes a template parameter 2025-10-05 10:45:28 +02:00
b3b37d1ca4 Simplified QML code. 2025-10-04 12:21:30 +02:00
f31da16948 Removed debug-output. 2025-10-02 11:34:55 +02:00
1e82128ea0 Reduced warings. 2025-10-01 11:28:58 +02:00
b5f218084b Fixed child creation. 2025-09-29 23:47:59 +02:00
f74c004bf9 Moved child row creation to XQItemFactory, some other cleanups. 2025-09-28 14:15:18 +02:00
007970f4ee Added subitems for sections. 2025-09-28 10:59:05 +02:00
4996c03b39 some renamings. 2025-09-27 17:21:36 +02:00
6b675cb85e --fy 2025-09-25 22:36:59 +02:00
defa6a1906 Merge branch 'experimental/template-znode' 2025-09-25 21:19:32 +02:00
Christoph Holzheuer
35ebcd2986 tried PCH 2025-09-24 17:29:10 +02:00
93879db3dd very first step... 2025-09-23 22:24:56 +02:00
23 changed files with 177 additions and 329 deletions

View File

@@ -33,38 +33,34 @@ TreeView
//color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff")
//color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff")
//color: index % 2 === 0 ? "#f9f9f9" : "#e0e0e0"
//color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff")
TextField
{
id: currentEntry
id: entry
anchors.centerIn: parent
text: display
font.pixelSize: 12
font.pixelSize: 11
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
/*
background: Rectangle
{
//color: entry.enabled ? "transparent" : "#353637"
//border.color: entry.enabled ? "#21be2b" : "transparent"
border.color: "transparent"
color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff")
// Ändere die Border-Farbe je nachdem, ob das Feld den Fokus hat
property color borderColor: currentEntry.activeFocus ? "dodgerblue" : "gray"
property int borderWidth: currentEntry.activeFocus ? 2 : 1
}
*/
background: Rectangle {
// Die Farbe des Hintergrunds im Normalzustand
color: "#ffffff"
// Hier werden Rahmenfarbe und -breite definiert
border.color: currentEntry.borderColor
border.width: currentEntry.borderWidth
// Abgerundete Ecken für ein modernes Aussehen
radius: 4
// Sanfter Übergang der Rahmenfarbe und -breite
Behavior on border.color {
ColorAnimation { duration: 150 }
}
Behavior on border.width {
NumberAnimation { duration: 150 }
}
// Hintergrund des Textfeldes anpassen
background: Rectangle
{
//color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff")
color: entry.activeFocus ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff")
}
onEditingFinished:

View File

@@ -31,6 +31,22 @@ XQChildModel::XQChildModel( QObject *parent )
}
//! Erzeugt eine model-section und fügt den zugehörigen header ein.
void XQChildModel::addSectionEntry( const QString& key, const XQNodePtr& contentEntry )
{
const XQModelSection& section = _sections.sectionByKey( key );
if(section.isValid() )
{
section.setContentRootNode( contentEntry->parent() );
int newRow =_sections.lastRow(section);
XQNodePtr sheetNode = section.sheetRootNode();
XQItemList list = _itemFactory.makeRow( sheetNode, nullptr );
insertRow( newRow, list);
}
}
//! erzegt den sichtbaren inhalt des models aus einem root-datenknoten.
void XQChildModel::addModelData( const XQNodePtr& contentRoot )
@@ -46,7 +62,6 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot )
// Das ist hier der Typ des Eintrags: Panel, Battery ...
QString key = contentEntry->tag_name();
// 'silent failure' hier der Datenbaum kann auch Knoten enthalten
// die nicht für uns gedacht sind.
if (!_sections.hasValidSection(key))
@@ -65,12 +80,18 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot )
// _hinter_ der letzen zeile einfügen
insertRow( newRow+1, list);
// Es können noch Kind-Knoten mit
// Detail-Infos vorhanden sein.
if( contentEntry->has_children())
{
qDebug() << " --- AddModelData: CHILD Found for: :" << contentEntry->tag_name() << " sheet parent: " << sheetNode->tag_name();
if( !sheetNode->has_children() )
qDebug() << " --- AUA";
//else
// Die Beschreibungen für die optionalen Kinder
// steck im ersten Knoten des Model-Sheets
if( !sheetNode->first_child()->has_children() )
continue;
_itemFactory.makeChildRow( list.front(), sheetNode->first_child(), contentEntry );
}
} // for
@@ -78,22 +99,6 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot )
}
//! Erzeugt eine model-section und fügt den zugehörigen header ein.
void XQChildModel::addSectionEntry( const QString& key, const XQNodePtr& contentEntry )
{
const XQModelSection& section = _sections.sectionByKey( key );
if(section.isValid() )
{
section.setContentRootNode( contentEntry->parent() );
int newRow =_sections.lastRow(section);
XQNodePtr sheetNode = section.sheetRootNode();
XQItemList list = _itemFactory.makeRow( sheetNode, nullptr );
insertRow( newRow, list);
}
}
//! erzeugt ein adhoc-contextmenu, je nachdem welche aktionen gerade möglich sind.
void XQChildModel::initContextMenu()

View File

@@ -30,7 +30,7 @@ public:
virtual ~XQChildModel() = default;
void addModelData(const XQNodePtr& contentRoot );
void addSectionEntry(const QString& key, const XQNodePtr& contentEntry );
void addSectionEntry( const QString& key, const XQNodePtr& contentEntry );
protected:

View File

@@ -71,7 +71,7 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
{
XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");
XQNodePtr sheetNode = projectItem->sheetNode()->child("CurrentSection");
XQItem* newItem = _itemFactory.makeSingleItem( sheetNode, section.contentType() );
projectItem->appendRow( newItem );
expandNewItem(projectItem->index() );

View File

@@ -62,7 +62,6 @@ void XQMainWindow::setupWorkingDir()
void XQMainWindow::initMainWindow()
{
qDebug() << " --- initMainWindow(): here we go!";
// das working dir setzen: 'xml' muss als unterverzeichnis vorhanden sein.
setupWorkingDir();
@@ -119,10 +118,10 @@ void XQMainWindow::initMainWindow()
loadDocument( c_DocumentFileName1 );
loadDocument( c_DocumentFileName2, true );
//loadDocument( c_DocumentFileName2 );
//loadDocument( c_DocumentFileName3 );
loadDocument( c_DocumentFileName3 );
qDebug() << " --- all here: " << XQNode::s_Count;
qDebug() << " --- #nodes created: " << XQNode::s_Count;
}
catch( XQException& exception )
@@ -260,7 +259,6 @@ void XQMainWindow::onTreeViewItemClicked( const XQItem& item )
void XQMainWindow::onTreeViewItemChanged(const XQItem& item )
{
qDebug() << " --- TREE VIEW itemChanged: text" << item.text() << " parent: " << item.parent()->text() << " type: " << item.itemType().text() << " : " << (void*)&_mainModel << " : " << (void*) sender();
// hier müssen wir erst das projekt aktivieren
XQItem* xqItem = static_cast<XQItem*>(item.parent());
onTreeViewItemClicked( *xqItem );
@@ -268,8 +266,7 @@ void XQMainWindow::onTreeViewItemChanged(const XQItem& item )
{
int idx = _tabWidget->currentIndex();
if(_documentStore.contains(idx) )
{
qDebug() << " --- Has Document and might toggle: " << item.text();
{
XQViewModel& childModel = *_documentStore[idx].viewModel;
childModel.onToggleSection(item.text());
}
@@ -428,44 +425,6 @@ void XQMainWindow::loadDocument( const QString& fileName, bool useQML )
}
void XQMainWindow::loadDocumentQML( const QString& fileName )
{
// gibts die Datei?
if( !QFile::exists( fileName) )
throw XQException( "no such file", fileName );
XQNodeFactory treeLoader;
// xml daten laden
XQNodePtr rawTree = treeLoader.load_tree( qPrintable(fileName) );
// versteckten root node ignorieren
XQNodePtr contentRoot = rawTree->first_child();
// 'friendly Name' ist ein Link auf ein anderes Attribute
// das als Namen verwendet wird.
const QString& fName = contentRoot->friendly_name();
// Ein neues Child-Model erzeugen
XQChildModel* childModel = new XQChildModel(this);
// die Modelstruktur anlegen
childModel->initModel( c_ChildModelName );
// model inhalte laden
childModel->addModelData( contentRoot->first_child() );
XQQuickWidget* quickChild = new XQQuickWidget(_tabWidget);
//quickChild->setResizeMode(QQuickWidget::SizeViewToRootObject);
quickChild->rootContext()->setContextProperty("xtrChildModel", childModel);
quickChild->setSource(QUrl("qrc:/xqtreeview.qml"));
_tabWidget->addTab( quickChild, "QML:"+fName );
_tabWidget->setCurrentWidget( quickChild );
quickChild->setResizeMode(QQuickWidget::SizeRootObjectToView);
}
//! speichert ein XML unter dem 'filename'
void XQMainWindow::saveDocument( const QString& fileName )

View File

@@ -64,12 +64,10 @@ public slots:
// fixme implement
//void showDocument( const QString& key ){}
void loadDocument( const QString& fileName, bool useQML=false );
void loadDocumentQML( const QString& fileName );
void saveDocument( const QString& fileName );
static void setupWorkingDir();
protected:
XQNodePtr createDataTree( const QString& fileName );

View File

@@ -242,7 +242,6 @@ void XQItemDelegate::drawSpinBoxStyle(QPainter* painter, const QStyleOptionViewI
spinBoxOption.frame = true;
_commonStyle.drawComplexControl(QStyle::CC_SpinBox, &spinBoxOption, painter, nullptr);
QRect editRect =_commonStyle.subControlRect(QStyle::CC_SpinBox, &spinBoxOption, QStyle::SC_SpinBoxEditField, nullptr);
painter->drawText(spinBoxOption.rect, Qt::AlignCenter, item.text());
}

View File

@@ -42,7 +42,7 @@ void XQItemFactory::initItemFactory( const QString& modelSheetFileName )
throw XQException("modelSheet load failed. ", modelSheetFileName);
// schritt #3: itemtype beschreibungen laden ...
_typesSheet = _modelSheet->find_child_by_tag_name( "ItemTypes" );
_typesSheet = _modelSheet->child( "ItemTypes" );
// ... und testen
if( !_typesSheet )
throw XQException( "initItemFactory <ItemTypes> is null" );
@@ -114,7 +114,7 @@ XQItemType* XQItemFactory::findItemTypeTemplate(const QString& key ) const
XQNodePtr XQItemFactory::findModelSheet( const QString& modelName ) const
{
XQNodePtr modelSheet = _modelSheet->find_child_by_tag_name( modelName );
XQNodePtr modelSheet = _modelSheet->child( modelName );
if( !modelSheet )
throw XQException( "model sheet not found: ", modelName );
@@ -153,8 +153,12 @@ XQItemList XQItemFactory::makeRow(const XQNodePtr& sheetNode, const XQNodePtr& c
// value = contentNode->attributes["Capacity"];
//
// __fix! Obacht! das setzt das vorhandensein des Contents voraus!
for( const auto& sheetEntry : sheetNode->children() )
{
list.append( makeItem( sheetEntry, contentNode ) );
}
Q_ASSERT(!list.empty());
@@ -165,13 +169,27 @@ XQItemList XQItemFactory::makeRow(const XQNodePtr& sheetNode, const XQNodePtr& c
return list;
}
XQItemList XQItemFactory::makeChildRow( XQItem* parent, const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
{
Q_UNUSED(parent);
Q_UNUSED(sheetNode);
Q_UNUSED(contentNode);
return XQItemList();
//! Erzeugt kind-items zu einem section-eintrag.
XQItemList XQItemFactory::makeChildRow( QStandardItem* parent, const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
{
XQItemList list;
for (const auto& contentChild : contentNode->children())
{
const QString& contentKey = contentChild->tag_name();
// wir brauchen ein beschreibenden sheetnode für diesen content-child knoten
if( sheetNode->has_child( contentKey ))
{
const XQNodePtr& sheetChild = sheetNode->child(contentKey);
list = makeRow( sheetChild, contentChild );
// als kinder einfügen
//insertRow( parent->row()+1, list );
parent->appendRow( list );
}
}
return list;
}
//! Erzeugt ein XQItem aus einer typ-beschreibung ('sheetNode') und einem daten-knoten ('contentNode').

View File

@@ -15,6 +15,7 @@
#ifndef XQITEMFACTORY_H
#define XQITEMFACTORY_H
#include <xsingleton.h>
#include <xqitem.h>
#include <xqitemtype.h>
#include <functional>
@@ -32,8 +33,9 @@ public:
XQNodePtr findModelSheet( const QString& modelName ) const;
// __fix auf nicht vorhandenen content felder prüfen! vereinheitlichen!
XQItemList makeRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
XQItemList makeChildRow( XQItem* parent, const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
XQItemList makeChildRow( QStandardItem* parent, const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
XQItem* makeSingleItem( const XQNodePtr& sheetNode, const QString& caption );
void setItemTypeDataFromString( XQItem& item, const QString& roleKey, const QString& source ) const;

View File

@@ -17,6 +17,7 @@
#include <QMetaType>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickStyle>
#include <QUrl>
#include <QQmlContext>
#include <QStyleFactory>
@@ -27,97 +28,20 @@
#include <xqmainwindow.h>
/*
TODO:
- kann ich die Enums auto generieren?
- entries einfach abzählen,
- einen enum als type
- auf diesen type drauf-casten, siehe qtglobal.h
- FIX! in reality, we have nested types, also.
- done: reference style
- done: shared_ptr
- try QML
- try 'model->readMore'
doc:
- vorhandenes xnode konzept soll am qt angebunden werden
- datensparsam: flyweight pattern & pointer auf orig
who is who:
- item
-itemtype
- factory
- model
- section
*/
XQChildModel* createChildModel()
{
XQChildModel* myModel = new XQChildModel();
myModel->initModel( c_ChildModelName );
XQNodeFactory treeLoader;
// xml daten laden
XQNodePtr rawTree = treeLoader.load_tree( qPrintable(c_DocumentFileName1) );
// versteckten root node ignorieren
XQNodePtr contentRoot = rawTree->first_child();
myModel->addModelData( contentRoot->first_child() );
return myModel;
}
using namespace Qt::Literals::StringLiterals;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//qDebug() << QStyleFactory::keys();
//QApplication::setStyle("fusion");
//QApplication::setStyle("windowsvista");
//QApplication::setStyle("windows");
// hat am wenigsten darstellungfehler (alternative: fusion)
QQuickStyle::setStyle("Imagine");
XQMainWindow window;
window.show();
/*
QApplication app(argc, argv);
XQMainWindow::setupWorkingDir();
XQItemFactory::instance().initItemFactory( c_ModelSheetFileName );
XQChildModel* myModel = createChildModel();
qmlRegisterType< XQChildModel>("MyApp.Models", 1, 0, "MyChildModel");
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("myChildModel", myModel);
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
qDebug() << " fitz!";
engine.load( QUrl(QStringLiteral("qrc:/dummyview.qml")) );
//engine.load( QUrl(QStringLiteral("qrc:/xqtableview.qml")) );
qDebug() << " hhakl!";
*/
return app.exec();
}

View File

@@ -16,8 +16,6 @@
#include <xqitem.h>
//! hilfsfunktion: gibt diesen teilbaum rekursiv aus
void inspect( const XQNodePtr& node, int indent )

View File

@@ -16,8 +16,6 @@
#define XQNODE_H
#include <iostream>
#include <memory>
#include <QDebug>
#include <QModelIndex>
@@ -29,12 +27,12 @@
std::ostream& operator<<(std::ostream& os, const QString& obj);
//! raw node
using XQNode = znode::zbasic_node<QString>;
using XQNode = znode::zbasic_node<QString,znode::zpayload<QString>>;
//! default shared node
using XQNodePtr = std::shared_ptr<znode::zbasic_node<QString>>;
using XQNodePtr = std::shared_ptr<znode::zbasic_node<QString,znode::zpayload<QString>>>;
//! die node factory
using XQNodeFactory = znode::znode_factory<QString>;
using XQNodeFactory = znode::znode_factory<QString,znode::zpayload<QString>>;

View File

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

View File

@@ -133,13 +133,13 @@ void XQViewModel::initModel(const QString& modelName)
*/
setObjectName( modelName );
// model rootnode finden -> <DocumentTreeModel>
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
// #1: über alle sections
for( auto& sectionNode : modelSheet->children() )
{
// #2: (optionalen?) header erzeugen
const XQNodePtr header = sectionNode->find_child_by_tag_name( c_Header );
const XQNodePtr header = sectionNode->child( c_Header );
if( header )
{
XQItemList list = _itemFactory.makeRow( header, nullptr );
@@ -166,10 +166,10 @@ void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sheetNode
if( !sheetNode->has_attribute( c_ContentType) )
throw XQException( "section list: Section node needs attribute 'ContentType'!");
// 5. das erzeugt dann auch valide indices
// 4. das erzeugt dann auch valide indices
appendRow(list);
// 6. jetzt können wir auch die section erzeugen
// 5. jetzt können wir auch die section erzeugen
const XQModelSection& section = _sections.createSection( list[0]->index(), sheetNode );
// ... und es der welt mitteilen.
@@ -182,8 +182,6 @@ void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sheetNode
void XQViewModel::onToggleSection(const QString& sectionKey )
{
qDebug() << " --- Model: " << this->objectName() << " should toggle: " << sectionKey << ": " << _sections.hasValidSection( sectionKey );
_sections.dump();
if(_sections.hasValidSection( sectionKey ) )
toggleSection( _sections.sectionByKey(sectionKey) );
}
@@ -329,25 +327,12 @@ void XQViewModel::onCommandUndo( const XQCommand& command )
void XQViewModel::cmdCut( const XQCommand& command )
{
int itmPos = command.first().itemPos;
const XQModelSection& section = _sections.sectionByRow( itmPos );
qDebug() << " --- HEADSHOT I: " << itmPos << "->" << section.contentType();
// wir gehen rückwärts über alle gemerkten knoten ...
for (auto it = command.rbegin(); it != command.rend(); ++it)
{
// ... holen das erste item, das auch den content node enthält
//const XQNodeBackup& entry = *it;
// ... holen das erste item, das auch den content node enthält
// jetzt löschen, dabei wird die parent-verbindung entfernt
const XQNodeBackup& entry = *it;
XQItem& firstItem = xqFirstItem( (*it).itemPos );
//qDebug() << " --- Cut: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id;
qDebug() << " ---- command CUT: itemPos: " << entry.itemPos << " nodePos: "<< entry.nodePos << " is " << entry.contentNode->friendly_name();
entry.contentNode->unlink_self();
removeRow(entry.itemPos );
}
@@ -358,14 +343,11 @@ void XQViewModel::cmdCut( const XQCommand& command )
void XQViewModel::cmdCutUndo( const XQCommand& command )
{
// die anfangsposition
int itmPos = command.first().itemPos;
// die 'zuständige' section rausfinden
const XQModelSection& section = _sections.sectionByRow( itmPos );
qDebug() << " --- HEADSHOT II: " << itmPos << "->" << section.contentType();
// über alle einträge ...
for (auto& entry : command )
{
@@ -374,12 +356,6 @@ void XQViewModel::cmdCutUndo( const XQCommand& command )
savedNode->add_me_at( entry.nodePos, _contentRoot );
XQItemList list = _itemFactory.makeRow( section.sheetRootNode(), savedNode );
insertRow( entry.itemPos, list );
XQItem& firstItem = *((XQItem*)list[0]);
qDebug() << " ---- command cut UNDO2: itemPos: " << entry.itemPos << " nodePos: "<< entry.nodePos << " is " << entry.contentNode->friendly_name();
qDebug() << " --- Cut Undo: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id << " count: " << entry.contentNode.use_count();
}
}
@@ -421,8 +397,6 @@ void XQViewModel::cmdPaste( const XQCommand& command )
}
// unsere änderungen merken fürs 'undo'
/// fix_xx
const_cast<XQCommand&>(command).saveNodes( selectionModel->selectedRows() );
}
@@ -432,14 +406,11 @@ void XQViewModel::cmdPaste( const XQCommand& command )
void XQViewModel::cmdPasteUndo( const XQCommand& command )
{
command.dumpList("Paste UNDO");
// wir gehen rückwärts über alle markieren knoten ...
for (auto it = command.rbegin(); it != command.rend(); ++it)
{
// ... holen das erste item, das auch den content node enthält
const XQNodeBackup& entry = *it;
XQItem& firstItem = xqFirstItem( (*it).itemPos );
qDebug() << " --- Cut: " << firstItem.text() << " " << firstItem.row();
// jetzt löschen
entry.contentNode->unlink_self();
removeRow(entry.itemPos );
@@ -458,8 +429,6 @@ void XQViewModel::cmdDelete( const XQCommand& command )
{
// ... holen das erste item, das auch den content node enthält
const XQNodeBackup& entry = *it;
XQItem& firstItem = xqFirstItem( (*it).itemPos );
qDebug() << " --- delete: " << firstItem.text() << " " << firstItem.row();
// jetzt löschen
entry.contentNode->unlink_self();
removeRow(entry.itemPos );
@@ -470,10 +439,6 @@ void XQViewModel::cmdDelete( const XQCommand& command )
void XQViewModel::cmdDeleteUndo( const XQCommand& command )
{
for (const auto& entry : command)
{
qDebug() << " --- delete UNDo: " << entry.contentNode->friendly_name();
}
cmdCutUndo(command);
}
@@ -491,8 +456,6 @@ void XQViewModel::cmdNew( const XQCommand& command )
XQNodePtr newNode = XQNode::make_node( node->tag_name(), node->tag_value() );
// store node in node->parent()
newNode->add_me_at( node->own_pos(), node->parent() );
//...
const XQModelSection& section = _sections.sectionByRow( origin.row() );
@@ -531,7 +494,6 @@ void XQViewModel::cmdToggleSection( const XQCommand& command )
// einen doppelten Aufruf und wir sind dann wieder im Anfangszustand.
//toggleSection( section );
emit sectionToggled(section);
}

View File

@@ -17,14 +17,11 @@
#include <vector>
#include <string>
#include <memory>
//#include <typeinfo>
#include <QString>
#include <QDebug>
#include <xqmaptor.h>
#include <xsingleton.h>
#include <znode_iterator.h>
//#include <znode_vector.h>
@@ -41,36 +38,21 @@ namespace znode
*/
// forward declaration of base class zbasic_node ...
//template<typename str_t>
//class zbasic_node;
// ... used here for conveniance typedef
//template<typename str_t>
//using zshared_node = std::shared_ptr<zbasic_node<str_t>>;
//! einfache tree-klasse, besonderheit: der nutzlast-string-type ist templated.
template<typename str_t>
class zbasic_node : public zid, public zpayload<str_t>, public std::enable_shared_from_this<zbasic_node<str_t>>
//! tree-klasse, besonderheit: der nutzlast & string-type sind templated.
template<typename str_t, typename payload_t>
class zbasic_node : public zid, public payload_t, public std::enable_shared_from_this<zbasic_node<str_t,payload_t>>
{
public:
using str_cref = const str_t&;
using str_list = std::vector<str_t>;
//using zshared_node = std::shared_ptr<zbasic_node>;
//using znode_list = znode_vector<zbasic_node>;
//using znode_list = znode_vector<zshared_node<str_t>>;
//using znode_list = std::vector<zshared_node<str_t>>;
using zweak_node = std::weak_ptr<zbasic_node>;
using zshared_node = std::shared_ptr<zbasic_node>;
using znode_list = std::vector<zshared_node>;
using zshared_cref = const std::shared_ptr<zbasic_node>&;
using str_cref = const str_t&;
using str_list = std::vector<str_t>;
using ziterator = znode_iterator<zbasic_node>;
protected:
@@ -108,14 +90,14 @@ namespace znode
//! konstruktor mit tag_name und optionalem elternknoten
zbasic_node( str_cref tag_name, zshared_cref parent = nullptr )
: zpayload<str_t>{tag_name}, _parent{parent}
: payload_t{tag_name}, _parent{parent}
{
}
//! konstruktor mit tag_name, value und optionalem elternknoten
zbasic_node( str_cref tag_name, str_cref value, zshared_cref parent = nullptr )
: zpayload<str_t>{tag_name,value}, _parent{parent}
: payload_t{tag_name,value}, _parent{parent}
{
}
@@ -205,6 +187,17 @@ namespace znode
return !children().empty();
}
bool has_child(int idx) const
{
return (idx>-1 && idx<children().size());
}
//! testet, ob kinder vorhanden sind.
bool has_child(str_cref tagname ) const
{
return child(tagname ) != nullptr;
}
//! gibt das erste kind zurück
zshared_node first_child()
{
@@ -228,6 +221,17 @@ namespace znode
return nullptr;
}
//
zshared_node child(str_cref tagname ) const
{
for( auto child : _children )
{
if( child->tag_name() == tagname )
return child;
}
return nullptr;
}
//! hängt einen knoten an meine kinderliste an.
int add_child( const zshared_node& node )
{
@@ -312,7 +316,7 @@ namespace znode
//! findet den ersten kind-knoten mit dem attribut 'attrkey' welches den
//! wert 'attrvalue' hat.
zshared_node find_child_by_attribute(str_cref attrkey, str_cref attrvalue )
zshared_node find_child_by_attribute(str_cref attrkey, str_cref attrvalue ) const
{
for( auto child : _children )
{
@@ -322,18 +326,9 @@ namespace znode
return nullptr;
}
//
zshared_node find_child_by_tag_name(str_cref tagname )
{
for( auto child : _children )
{
if( child->tag_name() == tagname )
return child;
}
return nullptr;
}
zshared_node find_child_by_id( int id )
zshared_node find_child_by_id( int id ) const
{
for (auto child : _children )
{

View File

@@ -40,15 +40,14 @@ model: muss ich wirklich jeden attibute node einzeln angeben?
*/
namespace znode
{
template<typename str_t>
template<typename str_t,typename payload_t>
class znode_factory
{
public:
using str_cref = const str_t&;
using zshared_node = std::shared_ptr<zbasic_node<str_t>>;
using zshared_node = std::shared_ptr< zbasic_node<str_t,payload_t> >;
znode_factory() = default;
virtual ~znode_factory() = default;
@@ -70,7 +69,7 @@ namespace znode
//tree_document.traverse(parser);
//zbasic_node<str_t>* root_node = new zbasic_node<str_t>*("root!");
zshared_node root_node = zbasic_node<str_t>::make_node("root!");
zshared_node root_node = zbasic_node<str_t, payload_t>::make_node("root!");
//T root_node = T::make_node( "root!" );
// prepare root == model !?
@@ -100,7 +99,7 @@ namespace znode
//parent->add_child( new_node );
//zbasic_node<str_t>* new_node = new zbasic_node<str_t>( node.name(), node.child_value(), parent );
zshared_node new_node = zbasic_node<str_t>::make_node( xml_node.name(), xml_node.child_value() );
zshared_node new_node = zbasic_node<str_t, payload_t>::make_node( xml_node.name(), xml_node.child_value() );
parent->add_child( new_node );
if( !xml_node.attributes().empty() )

View File

@@ -630,7 +630,7 @@ namespace pugi
}
// Find child node using predicate. Returns first child for which predicate returned true.
template <typename Predicate> xml_node find_child_by_tag_name(Predicate pred) const
template <typename Predicate> xml_node child(Predicate pred) const
{
if (!_root) return xml_node();

View File

@@ -1,4 +1,4 @@
QT += core gui widgets quick quickwidgets
QT += core gui widgets quick quickwidgets quickcontrols2
# widgets-private
CONFIG += c++20 qmltypes

View File

@@ -16,7 +16,8 @@
<Inverter InverterID="#4 D12K 04" FriendlyName="@InverterName" InverterName="04 HM600 S2 TMax" Manufacturer="Deye" MaxPowerInput="8000" MaxPowerInputChoice="6000;8000;12000" MaxPowerOutput="600" NumStrings="2" Weight="28"/>
<Battery BatteryID="#1 BYD 01" FriendlyName="@BatteryName" BatteryName="01 BYD T01 Stackable" Manufacturer="BYD" Capacity="4500" Yield="90" MaxCurrent="120" MaxVolt="48">
<Images FrontView="image.png" PackageView="package.png" InstalledView="installed.png"/>
<Documents Manual="manual.docx" Certificate="certificate.pdf"/>
<Documents Manual="manual.docx" Installation="installation.pdf"/>
<Certificates Certificate="certificate.pdf" Conformity="conformity.pdf"/>
</Battery>
<Battery BatteryID="#2 BYD 02" FriendlyName="@BatteryName" BatteryName="02 BYD T02 Stackable" Manufacturer="BYD" Capacity="9000" Yield="94" MaxCurrent="120" MaxVolt="48"/>
<Battery BatteryID="#3 BYD 03" FriendlyName="@BatteryName" BatteryName="03 BYD T01 Stackable" Manufacturer="BYD" Capacity="4500" Yield="86" MaxCurrent="120" MaxVolt="48"/>

View File

@@ -1,12 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<Project ProjectID="HA02" FriendlyName="@ProjectName" ProjectName="Gerbrunn Ost" Established="2006" WattPeak="9840" ContentType="planned">
<Components>
<Panel PanelID="Jingli 01" FriendlyName="@PanelName" PanelName="Jingli 01 Solar T62B" Manufacturer="Jingli Solar" WattPeak="620" Height="2,70" Width="1,10" Weight="12" MaxVolt="67" MaxAmpere="11">
<AdditionalData DataItem="Image" DataValue="image.png"/>
<AdditionalData DataItem="Manual" DataValue="manual.docx"/>
<AdditionalData DataItem="Certificate" DataValue="certificate.pdf"/>
</Panel>
<Panel PanelID="Jingli 02" FriendlyName="@PanelName" PanelName="Jingli 02 Solar X58C" Manufacturer="Jingli Solar" WattPeak="440" Height="1,70" Width="1,10" Weight="12" MaxVolt="42" MaxAmpere="11"/>
<Panel PanelID="Jingli 03" FriendlyName="@PanelName" PanelName="Jingli 03 Solar T62B" Manufacturer="Jingli Solar" WattPeak="620" Height="2,70" Width="1,10" Weight="12" MaxVolt="67" MaxAmpere="11"/>
@@ -24,8 +19,7 @@
<Battery BatteryID="BYD 04" FriendlyName="@BatteryName" BatteryName="04 BYD T02 Stackable" Manufacturer="BYD" Capacity="9000" Yield="32" MaxCurrent="120" MaxVolt="48"/>
<Battery BatteryID="GroWatt 05 G2K" FriendlyName="@BatteryName" BatteryName="05 BYD T01 Stackable" Manufacturer="PylonTech" Capacity="4500" Yield="46" MaxCurrent="120" MaxVolt="48"/>
<Battery BatteryID="GroWatt 06 G4K" FriendlyName="@BatteryName" BatteryName="06 BYD T02 Stackable" Manufacturer="PylonTech" Capacity="9000" Yield="94" MaxCurrent="120" MaxVolt="48">
</Battery>
</Battery>
</Components>
</Project>

View File

@@ -2,11 +2,7 @@
<Project ProjectID="HA03" FriendlyName="@ProjectName" ProjectName="Tauberbischoffsheim SÜD" Established="2006" WattPeak="9840" ContentType="runnning">
<Components>
<Panel PanelID="AIKO 01" FriendlyName="@PanelName" PanelName="AIKO 01 Solar T62B" Manufacturer="AIKO Solar" WattPeak="620" Height="2,70" Width="1,10" Weight="12" MaxVolt="67" MaxAmpere="11">
<AdditionalData DataItem="Image" DataValue="image.png"/>
<AdditionalData DataItem="Manual" DataValue="manual.docx"/>
<AdditionalData DataItem="Certificate" DataValue="certificate.pdf"/>
</Panel>
<Panel PanelID="AIKO 01" FriendlyName="@PanelName" PanelName="AIKO 01 Solar T62B" Manufacturer="AIKO Solar" WattPeak="620" Height="2,70" Width="1,10" Weight="12" MaxVolt="67" MaxAmpere="11"/>
<Panel PanelID="AIKO 02" FriendlyName="@PanelName" PanelName="AIKO 02 Solar X58C" Manufacturer="AIKO Solar" WattPeak="440" Height="1,70" Width="1,10" Weight="12" MaxVolt="42" MaxAmpere="11"/>
<Panel PanelID="AIKO 03" FriendlyName="@PanelName" PanelName="AIKO 03 Solar T62B" Manufacturer="AIKO Solar" WattPeak="620" Height="2,70" Width="1,10" Weight="12" MaxVolt="67" MaxAmpere="11"/>
<Panel PanelID="AIKO 04" FriendlyName="@PanelName" PanelName="AIKO 04 Solar X58C" Manufacturer="AIKO Solar" WattPeak="440" Height="1,70" Width="1,10" Weight="12" MaxVolt="42" MaxAmpere="11"/>

View File

@@ -6,8 +6,6 @@
-->
<ItemTypes>
<TreeParentType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsDropEnabled" Icon="DirIcon" />
<TreeChildType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled" Icon="MediaPlay"/>
@@ -15,6 +13,7 @@
<HeaderType RenderStyle="HeaderStyle" EditorType="LineEditType" ItemFlags="IsEnabled"/>
<HiddenType RenderStyle="HiddenStyle"/>
<StaticType RenderStyle="PlainStyle"/>
<FilePickerType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable" Icon="DirIcon" />
<PlainType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
<ValueType RenderStyle="FormattedStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable" UnitType="Coulomb"/>
<CheckableType RenderStyle="FormattedStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable" />
@@ -56,8 +55,6 @@
</Section>
</DocumentTreeModel>
<DocumentDetailsModel>
<Section ContentType="Panel" CatchBlock="TagName=Panel">
@@ -87,7 +84,7 @@
</ModelSheet>
</Section>
<Section ContentType="Inverter" >
<Section ContentType="Inverter" >
<Header >
<InverterID Caption="Inverter" ItemType="HeaderType" />
<InverterName Caption="Name" ItemType="HeaderType" />
@@ -119,23 +116,28 @@
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
</Header>
<ModelSheet>
<BatteryID ItemType="PlainType" />
<BatteryID ItemType="PlainType">
<Images>
<FrontView ItemType="FilePickerType"/>
<PackageView ItemType="FilePickerType"/>
<InstalledView ItemType="FilePickerType"/>
</Images >
<Documents>
<Manual ItemType="FilePickerType"/>
<Installation ItemType="FilePickerType"/>
</Documents>
<Certificates>
<Certificate ItemType="FilePickerType"/>
<Conformity ItemType="FilePickerType"/>
</Certificates>
</BatteryID>
<BatteryName ItemType="PlainType" />
<Manufacturer ItemType="PlainType" />
<Capacity ItemType="ValueType" UnitType="Wh"/>
<Yield ItemType="PercentageType" UnitType="%"/>
<MaxCurrent ItemType="ValueType" UnitType="A">
<SubType ItemType="PlainType"/>
</MaxCurrent>
<MaxCurrent ItemType="ValueType" UnitType="A"/>
<MaxVolt ItemType="ValueType" UnitType="V"/>
<firz ItemType="PlainType"/>
<Image DataValue="image.png" ItemType="PlainType"/>
<Manual DataValue="manual.docx" ItemType="PlainType"/>
<Certificate DataValue="certificate.pdf" ItemType="PlainType"/>
</ModelSheet>
</Section>

View File

@@ -1,22 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<Components>
<Panel FriendlyName="@PanelName" Height="2,70" Manufacturer="Jingli Solar" MaxAmpere="11" MaxVolt="67" PanelID="Jingli 01" PanelName="Jingli 01 Solar T62B" WattPeak="620" Weight="12" Width="1,10">
<AdditionalData DataItem="Image" DataValue="image.png"/>
<AdditionalData DataItem="Manual" DataValue="manual.docx"/>
<AdditionalData DataItem="Certificate" DataValue="certificate.pdf"/>
</Panel>
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="Jingli Solar" MaxAmpere="11" MaxVolt="42" PanelID="Jingli 02" PanelName="Jingli 02 Solar X58C" WattPeak="440" Weight="12" Width="1,10"/>
<Panel FriendlyName="@PanelName" Height="2,70" Manufacturer="Jingli Solar" MaxAmpere="11" MaxVolt="67" PanelID="Jingli 03" PanelName="Jingli 03 Solar T62B" WattPeak="620" Weight="12" Width="1,10"/>
<Inverter FriendlyName="@InverterName" InverterID="HM600 01" InverterName="01 HM600 S2 TMax" Manufacturer="HoyMiles" MaxPowerInput="4000" MaxPowerInputChoice="2000;4000;6000" MaxPowerOutput="600" NumStrings="2" Weight="28"/>
<Inverter FriendlyName="@InverterName" InverterID="HM800 02" InverterName="02 HM800 S2 TMax" Manufacturer="HoyMiles" MaxPowerInput="4000" MaxPowerInputChoice="2000;4000;6000" MaxPowerOutput="800" NumStrings="2" Weight="29"/>
<Inverter FriendlyName="@InverterName" InverterID="HM1600 03" InverterName="03 HM1600 S4 TMax" Manufacturer="HoyMiles" MaxPowerInput="4000" MaxPowerInputChoice="2000;4000;6000" MaxPowerOutput="1600" NumStrings="4" Weight="32"/>
<Inverter FriendlyName="@InverterName" InverterID="D12K 04" InverterName="04 HM600 S2 TMax" Manufacturer="Deye" MaxPowerInput="4000" MaxPowerInputChoice="2000;4000;6000" MaxPowerOutput="600" NumStrings="2" Weight="28"/>
<Battery BatteryID="BYD 01" BatteryName="FIRZ!" Capacity="4500" FriendlyName="@BatteryName" Manufacturer="BYD" MaxCurrent="120" MaxVolt="48" Yield="88">
<AdditionalData DataItem="Image" DataValue="image.png"/>
<AdditionalData DataItem="Manual" DataValue="manual.docx"/>
<AdditionalData DataItem="Certificate" DataValue="certificate.pdf"/>
<Panel FriendlyName="@PanelName" Height="2,70" Manufacturer="JA Solar 1 XX" MaxAmpere="11" MaxVolt="67" PanelID="#1 JA 01" PanelName="JA 01 Solar T62B" WattPeak="620" Weight="12" Width="1,10"/>
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="JA Solar 2" MaxAmpere="11" MaxVolt="42" PanelID="#2 JA 02" PanelName="JA 02 Solar X58C" WattPeak="440" Weight="12" Width="1,10"/>
<Panel FriendlyName="@PanelName" Height="2,70" Manufacturer="JA Solar 3" MaxAmpere="11" MaxVolt="67" PanelID="#3 JA 03" PanelName="JA 03 Solar T62B" WattPeak="620" Weight="12" Width="1,10"/>
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="JA Solar 4" MaxAmpere="11" MaxVolt="42" PanelID="#4 JA 04" PanelName="JA 04 Solar X58C" WattPeak="440" Weight="12" Width="1,10"/>
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="JA Solar 5" MaxAmpere="11" MaxVolt="42" PanelID="#5 JA 05" PanelName="moo" WattPeak="440" Weight="12" Width="1,10"/>
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="JA Solar 6" MaxAmpere="11" MaxVolt="42" PanelID="#6 JA 06" PanelName="JA 06 Solar X58C" WattPeak="440" Weight="12" Width="1,10"/>
<Inverter FriendlyName="@InverterName" InverterID="#1 HM600 01" InverterName="01 HM600 S2 TMax" Manufacturer="HoyMiles" MaxPowerInput="3000,00" MaxPowerInputChoice="2000;4000;6000" MaxPowerOutput="600" NumStrings="2" Weight="28"/>
<Inverter FriendlyName="@InverterName" InverterID="#2 HM800 02" InverterName="02 HM800 S2 TMax" Manufacturer="HoyMiles" MaxPowerInput="4000" MaxPowerInputChoice="4000;6000;8000" MaxPowerOutput="800" NumStrings="2" Weight="29"/>
<Inverter FriendlyName="@InverterName" InverterID="#3 HM1600 03" InverterName="03 HM1600 S4 TMax" Manufacturer="HoyMiles" MaxPowerInput="9000,00" MaxPowerInputChoice="6000;8000;10000" MaxPowerOutput="1600" NumStrings="4" Weight="32"/>
<Inverter FriendlyName="@InverterName" InverterID="#4 D12K 04" InverterName="04 HM600 S2 TMax" Manufacturer="Deye" MaxPowerInput="8000" MaxPowerInputChoice="6000;8000;12000" MaxPowerOutput="600" NumStrings="2" Weight="28"/>
<Battery BatteryID="#1 BYD 01" BatteryName="01 BYD T01 Stackable" Capacity="4500" FriendlyName="@BatteryName" Manufacturer="BYD" MaxCurrent="120" MaxVolt="48" Yield="90">
<Images FrontView="image.png" InstalledView="installed.png" PackageView="package.png"/>
<Documents Installation="installation.pdf" Manual="manual.docx"/>
<Certificates Certificate="certificate.pdf" Conformity="conformity.pdf"/>
</Battery>
<Battery BatteryID="BYD 04" BatteryName="04 BYD T02 Stackable" Capacity="9000" FriendlyName="@BatteryName" Manufacturer="BYD" MaxCurrent="120" MaxVolt="48" Yield="32"/>
<Battery BatteryID="GroWatt 05 G2K" BatteryName="05 BYD T01 Stackable" Capacity="4500" FriendlyName="@BatteryName" Manufacturer="PylonTech" MaxCurrent="120" MaxVolt="48" Yield="46"/>
<Battery BatteryID="GroWatt 06 G4K" BatteryName="06 BYD T02 Stackable" Capacity="9000" FriendlyName="@BatteryName" Manufacturer="PylonTech" MaxCurrent="120" MaxVolt="48" Yield="94"/>
<Battery BatteryID="#2 BYD 02" BatteryName="02 BYD T02 Stackable" Capacity="9000" FriendlyName="@BatteryName" Manufacturer="BYD" MaxCurrent="120" MaxVolt="48" Yield="94"/>
<Battery BatteryID="#3 BYD 03" BatteryName="03 BYD T01 Stackable" Capacity="4500" FriendlyName="@BatteryName" Manufacturer="BYD" MaxCurrent="120" MaxVolt="48" Yield="86"/>
<Battery BatteryID="#4 BYD 04" BatteryName="04 BYD T02 Stackable" Capacity="9000" FriendlyName="@BatteryName" Manufacturer="BYD" MaxCurrent="120" MaxVolt="48" Yield="91"/>
<Battery BatteryID="#5 GroWatt 05 G2K" BatteryName="05 BYD T01 Stackable" Capacity="4500" FriendlyName="@BatteryName" Manufacturer="GroWatt" MaxCurrent="120" MaxVolt="48" Yield="94"/>
<Battery BatteryID="#6 GroWatt 06 G4K" BatteryName="06 BYD T02 Stackable" Capacity="9000" FriendlyName="@BatteryName" Manufacturer="GroWatt" MaxCurrent="120" MaxVolt="48" Yield="49"/>
<Battery BatteryID="#7 Pyne 07 G4K" BatteryName="07 Pyne K7 Stackable" Capacity="9000" FriendlyName="@BatteryName" Manufacturer="PyNe" MaxCurrent="120" MaxVolt="48" Yield="68"/>
</Components>