diff --git a/.gitignore b/.gitignore index 13f2cda..2f58971 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ UsersC998D~1.HOLAppDataLocalTemptmpj0mbo3rd xml/fitzefatz.xml build* doc/ +src/xtree.vcxproj.user diff --git a/qml/xqtableview.qml b/qml/xqtableview.qml deleted file mode 100644 index 01e1d3d..0000000 --- a/qml/xqtableview.qml +++ /dev/null @@ -1,65 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -Window -{ - width: 640 - height: 480 - visible: true - title: qsTr("StringListModel") - - TableView - { - id: childTableView - anchors.fill: parent - - model: myChildModel // z. B. QStandardItemModel mit 9 Spalten - - delegate: Rectangle - { - required property string display - - //height: 5 - //width: childTableView.width - color : "blue" - border.color: "#ccc" - width: childTableView.width; - - RowLayout - { - anchors.fill: parent - anchors.margins: 2 - - TextField - { - text : display - font.pixelSize: 10 - Layout.fillWidth: true - - background: Rectangle - { - color : "white" - } - - onEditingFinished: - { - console.log("Editing finished, new text is :"+ text + " at index :" + index) - model.names = text //The roles here are defined in model class - } - } - } - - } - - ScrollBar.horizontal: ScrollBar {} - ScrollBar.vertical: ScrollBar {} - - // // Optional: Spaltenbreiten setzen - // onModelChanged: { - // for (let i = 0; i < model.columns; ++i) - // table.setColumnWidth(i, 100) - // } - } - -} diff --git a/qml/xqtreeview.qml b/qml/xqtreeview.qml index 3d65da9..b2652f0 100644 --- a/qml/xqtreeview.qml +++ b/qml/xqtreeview.qml @@ -30,14 +30,50 @@ TreeView implicitHeight: 20 border.color: "#cccccc" //color: index % 2 === 0 ? "#f9f9f9" : "#e0e0e0" - color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff") + //color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff") + //color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff") - Text + + + TextField { + id: currentEntry anchors.centerIn: parent text: display font.pixelSize: 12 + + + // Ä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 } + } + } + + onEditingFinished: + { + console.log("Editing finished, new text is :"+ text + " at index :" + index) + model.display = text //The roles here are defined in model class + } } + } ScrollBar.horizontal: ScrollBar {} diff --git a/src/application/xqchildmodel.cpp b/src/application/xqchildmodel.cpp index 0b16fc9..54bb88d 100644 --- a/src/application/xqchildmodel.cpp +++ b/src/application/xqchildmodel.cpp @@ -49,6 +49,7 @@ 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)) @@ -67,6 +68,14 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot ) // _hinter_ der letzen zeile einfügen insertRow( newRow+1, list); + if( contentEntry->has_children()) + { + qDebug() << " --- AddModelData: CHILD Found for: :" << contentEntry->tag_name() << " sheet parent: " << sheetNode->tag_name(); + if( !sheetNode->has_children() ) + qDebug() << " --- AUA"; + //else + } + } // for } diff --git a/src/items/xqitem.cpp b/src/items/xqitem.cpp index d4f24e0..c3c3450 100644 --- a/src/items/xqitem.cpp +++ b/src/items/xqitem.cpp @@ -183,6 +183,7 @@ bool XQItem::hasContentNode() const XQItem& firstItem = xqItemFromIndex( pIndex ); return firstItem.hasContentNode(); } + return false; } //! gibt den content-node zurück. diff --git a/src/items/xqitemdelegate.cpp b/src/items/xqitemdelegate.cpp index 8d33c11..c20161b 100644 --- a/src/items/xqitemdelegate.cpp +++ b/src/items/xqitemdelegate.cpp @@ -52,7 +52,7 @@ public: //! kontruktor mit dem zusändigen viewModel XQItemDelegate::XQItemDelegate( XQViewModel& viewModel) - : _modelView{viewModel} + : QStyledItemDelegate(), _modelView{viewModel} { static XQItemEditorFactory s_EditorFactory; setItemEditorFactory(&s_EditorFactory); @@ -86,6 +86,7 @@ void XQItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option { case XQItem::HeaderStyle : return drawHeaderStyle( painter, option, item ); + //return drawHeaderStyleX( painter, option, index ); case XQItem::ComboBoxStyle : return drawComboBoxStyle( painter, option, item ); @@ -93,9 +94,9 @@ void XQItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option case XQItem::ColorBarStyle : return drawColorBarStyle( painter, option, item ); - // das funktioniert nicht unter windows11 - //case XQItem::SpinBoxStyle : - // return drawSpinBoxStyle( painter, option, item ); + // das funktioniert nicht unter windows11 + //case XQItem::SpinBoxStyle : + // return drawSpinBoxStyle( painter, option, item ); case XQItem::HiddenStyle : return; @@ -122,8 +123,8 @@ void XQItemDelegate::drawHeaderStyle(QPainter* painter, const QStyleOptionViewIt // use the header as "parent" for style init QWidget* srcWidget = treeTable();//->header(); headerOption.initFrom(srcWidget); - headerOption.text = item.text(); - headerOption.rect = option.rect.adjusted(0,0,0,3); + headerOption.text = item.text();//index.data(Qt::DisplayRole).toString(); + headerOption.rect = option.rect;//.adjusted(0,0,0,3); headerOption.styleObject = option.styleObject; // __ch: reduce inner offset when painting headerOption.textAlignment |= Qt::AlignVCenter; @@ -131,12 +132,20 @@ void XQItemDelegate::drawHeaderStyle(QPainter* painter, const QStyleOptionViewIt // save painter painter->save(); + //value = index.data(Qt::ForegroundRole); + //if (value.canConvert()) + //headerOption.palette.setBrush(QPalette::Text, Qt::red ); + //headerOption.palette.setBrush(QPalette::Window, Qt::red ); + //QCommonStyle itemStyle; - QStyle* widgetStyle = srcWidget->style(); - widgetStyle->drawControl(QStyle::CE_Header, &headerOption, painter, srcWidget); + //qApp->style()->drawControl(QStyle::CE_Header, &headerOption, painter, srcWidget); + //srcWidget->style()->drawControl(QStyle::CE_Header, &headerOption, painter, srcWidget); + // warum das nur mit dem commonstyle, ist mir echt unklar. + _commonStyle.drawControl(QStyle::CE_Header, &headerOption, painter, srcWidget); // restore painter painter->restore(); + } @@ -161,14 +170,12 @@ void XQItemDelegate::drawColorBarStyle(QPainter* painter, const QStyleOptionView painter->setRenderHint(QPainter::Antialiasing); QRect barRect(rect.left(), rect.top(), barWidth, rect.height()); - QColor barColor = QColor(100, 180, 255); // z. B. hellblau + QColor barColor = QColor(100, 180, 255); painter->setBrush(barColor); painter->setPen(Qt::NoPen); painter->drawRect(barRect); - // Text (Zahl) zentriert zeichnen painter->setPen(Qt::black); - //painter->drawText(rect, Qt::AlignCenter, QString::number(value)+" %"); painter->drawText(rect, Qt::AlignCenter, item.text() ); painter->restore(); @@ -197,6 +204,8 @@ void XQItemDelegate::drawComboBoxStyle(QPainter* painter, const QStyleOptionView // save painter painter->save(); + + // hier wiederum funktioniert der '_commonStyle' nicht QStyle* widgetStyle = srcWidget->style(); // draw combo widgetStyle->drawComplexControl(QStyle::CC_ComboBox, &comboOption, painter, srcWidget); @@ -219,8 +228,6 @@ void XQItemDelegate::drawSpinBoxStyle(QPainter* painter, const QStyleOptionViewI QStyleOptionSpinBox spinBoxOption; spinBoxOption.initFrom(srcWidget); - - // 1. Grundlegende Optionen initialisieren und Hintergrund zeichnen (wichtig für Selektion) initStyleOption(&viewOption, item.index()); if (option.state & QStyle::State_HasFocus) { @@ -228,16 +235,15 @@ void XQItemDelegate::drawSpinBoxStyle(QPainter* painter, const QStyleOptionViewI } QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewOption, painter); - spinBoxOption.rect = option.rect; + spinBoxOption.rect = option.rect;//.adjusted( 0,0,-40,0); spinBoxOption.state = option.state | QStyle::State_Sunken; // Sunken-State für den "LineEdit"-Look spinBoxOption.buttonSymbols = QAbstractSpinBox::UpDownArrows; spinBoxOption.stepEnabled = QAbstractSpinBox::StepUpEnabled | QAbstractSpinBox::StepDownEnabled; spinBoxOption.frame = true; - QStyle* widgetStyle = srcWidget->style(); - widgetStyle->drawComplexControl(QStyle::CC_SpinBox, &spinBoxOption, painter, nullptr); - QRect editRect = widgetStyle->subControlRect(QStyle::CC_SpinBox, &spinBoxOption, QStyle::SC_SpinBoxEditField, nullptr); - painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignCenter, item.text()); + _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()); } @@ -254,6 +260,8 @@ QSize XQItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelI QWidget* XQItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { + Q_UNUSED(option); + XQItem& item = xqItemFromIndex(index); XQItem::EditorType edType = item.editorType(); if( edType == XQItem::NoEditorType ) diff --git a/src/items/xqitemdelegate.h b/src/items/xqitemdelegate.h index b87a0da..5ba3488 100644 --- a/src/items/xqitemdelegate.h +++ b/src/items/xqitemdelegate.h @@ -16,6 +16,7 @@ #define XQITEMDELEGATE_H #include +#include #include class XQItem; @@ -52,6 +53,7 @@ protected: void drawSpinBoxStyle(QPainter* painter, const QStyleOptionViewItem& option, const XQItem& item) const; XQViewModel& _modelView; + QCommonStyle _commonStyle; }; diff --git a/src/items/xqitemfactory.cpp b/src/items/xqitemfactory.cpp index b780ee4..6433cc6 100644 --- a/src/items/xqitemfactory.cpp +++ b/src/items/xqitemfactory.cpp @@ -105,7 +105,7 @@ XQItemType* XQItemFactory::makeItemType(const XQNodePtr& sheetEntry ) XQItemType* XQItemFactory::findItemTypeTemplate(const QString& key ) const { if( !key.isEmpty() && s_ItemTypeTemplates.contains(key)) - return s_ItemTypeTemplates[key]; + return s_ItemTypeTemplates[key]; throw XQException( "itemfactory: findItemTypeTemplate: not found:", key ); } @@ -136,54 +136,6 @@ void XQItemFactory::setItemTypeDataFromString( XQItem& item, const QString& role } - - -/// -/// ------------------------------------------------ -/// - -/* -XQItemList XQItemFactory::makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ) -{ - Q_UNUSED(contentNode) - - XQItemList list; - - // create a data node for each sheet entry - size_t max = sheetNode->children().size(); - for( size_t i=0; ichildren() ) - { - QString value = "[" + sheetEntry->tag_name() + "]"; - if( sheetEntry->has_attribute("Unit") ) - value = "0"; - contentNode->set_attribute( sheetEntry->tag_name(), value ); - } - - if( sheetNode->has_attribute( c_FriendlyName ) ) - contentNode->set_attribute( c_FriendlyName, sheetNode->friendly_name() ); - - // now, we can create a normal entry row - return makeContentRow(contentNode, sheetNode ); - -} -*/ - - //! erzeugt eine item-row. XQItemList XQItemFactory::makeRow(const XQNodePtr& sheetNode, const XQNodePtr& contentNode ) @@ -213,6 +165,14 @@ 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 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 diff --git a/src/items/xqitemfactory.h b/src/items/xqitemfactory.h index 31e44b3..59636f8 100644 --- a/src/items/xqitemfactory.h +++ b/src/items/xqitemfactory.h @@ -33,6 +33,7 @@ public: XQNodePtr findModelSheet( const QString& modelName ) const; XQItemList makeRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode ); + XQItemList makeChildRow( XQItem* 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; diff --git a/src/nodes/znode_payload.h b/src/nodes/znode_payload.h index a3f878f..2299224 100644 --- a/src/nodes/znode_payload.h +++ b/src/nodes/znode_payload.h @@ -4,9 +4,6 @@ #include #include -//#include -//#include - namespace znode { template diff --git a/src/xtree.qrc b/src/xtree.qrc index 7df0b75..ef4aeec 100644 --- a/src/xtree.qrc +++ b/src/xtree.qrc @@ -4,7 +4,6 @@ ../xml/modeldata2.xtr ../xml/modeldata3.xtr ../xml/modelsheets.xml - ../qml/xqtableview.qml ../qml/xqtreeview.qml diff --git a/src/xtree.sln b/src/xtree.sln index 60aa5b0..253fcb9 100644 --- a/src/xtree.sln +++ b/src/xtree.sln @@ -7,14 +7,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xtree", "xtree.vcxproj", "{ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D9E56CB4-F99F-4F88-B721-1443A0AFD5D0}.Debug|x86.ActiveCfg = Debug|Win32 - {D9E56CB4-F99F-4F88-B721-1443A0AFD5D0}.Debug|x86.Build.0 = Debug|Win32 - {D9E56CB4-F99F-4F88-B721-1443A0AFD5D0}.Release|x86.ActiveCfg = Release|Win32 - {D9E56CB4-F99F-4F88-B721-1443A0AFD5D0}.Release|x86.Build.0 = Release|Win32 + {D9E56CB4-F99F-4F88-B721-1443A0AFD5D0}.Debug|x64.ActiveCfg = Debug|x64 + {D9E56CB4-F99F-4F88-B721-1443A0AFD5D0}.Debug|x64.Build.0 = Debug|x64 + {D9E56CB4-F99F-4F88-B721-1443A0AFD5D0}.Release|x64.ActiveCfg = Release|x64 + {D9E56CB4-F99F-4F88-B721-1443A0AFD5D0}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/xtree.vcxproj b/src/xtree.vcxproj index b8d92af..de7fe2a 100644 --- a/src/xtree.vcxproj +++ b/src/xtree.vcxproj @@ -5,16 +5,26 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {D9E56CB4-F99F-4F88-B721-1443A0AFD5D0} QtVS_v304 10.0 + 10.0 10.0 + 10.0 $(MSBuildProjectDirectory)\QtMsBuild @@ -24,6 +34,12 @@ true Unicode + + Application + v143 + true + Unicode + Application v143 @@ -31,13 +47,25 @@ true Unicode + + Application + v143 + false + true + Unicode + - qt691 - core;gui;widgets + qt692 + core;gui;quick;quickcontrols2;quickdialogs2;quicklayouts;widgets;quickwidgets + debug + + + qt692 + core;gui;quick;widgets;quickwidgets debug @@ -45,6 +73,11 @@ core;gui;widgets release + + VS2017x86Default + core;gui;widgets + release + @@ -54,13 +87,22 @@ + + + + + + + + + @@ -69,6 +111,12 @@ stdcpp17 + + + items;model;application;widgets;util;nodes;pugixml;%(AdditionalIncludeDirectories) + stdcpp17 + + true @@ -81,6 +129,18 @@ true + + + true + Level3 + true + true + + + Windows + true + + true @@ -97,62 +157,70 @@ true + + + true + Level3 + true + true + true + true + + + Windows + false + true + true + + - + - + - - - + - - - - + - - + + - - - - - - + + - + + - + + - @@ -166,10 +234,7 @@ - - - diff --git a/src/xtree.vcxproj.filters b/src/xtree.vcxproj.filters index f823e37..89a1b81 100644 --- a/src/xtree.vcxproj.filters +++ b/src/xtree.vcxproj.filters @@ -76,42 +76,21 @@ Source Files\model - - Source Files\model - - - Source Files\model - Source Files\model - - Source Files\application - Source Files\application Source Files\nodes - - Source Files\widgets - - - Source Files\widgets - Source Files\pugixml - - Source Files\model - Source Files\model - - Source Files\application - Source Files\model @@ -127,21 +106,9 @@ Source Files\model - - Source Files\model - Source Files\application - - Source Files\model - - - Source Files\model - - - Source Files\Items - Source Files\Items @@ -154,6 +121,24 @@ Source Files\Items + + Source Files\model + + + Source Files\model + + + Source Files\widgets + + + Source Files\widgets + + + Source Files\application + + + Source Files\application + @@ -183,9 +168,6 @@ Header Files\pugixml - - Header Files\model - Header Files\util @@ -216,12 +198,6 @@ Header Files\nodes - - Header Files\nodes - - - Header Files\items - Header Files\items @@ -234,33 +210,36 @@ Header Files\items + + Header Files\model + - - Header Files\model - - - Header Files\application - Header Files\application - - Header Files\widgets - - - Header Files\widgets - Header Files\widgets Header Files\model - + Header Files\application - + + Header Files\model + + + Header Files\widgets + + + Header Files\widgets + + + Header Files\application + + Header Files\application diff --git a/src/xtree.vcxproj.user b/src/xtree.vcxproj.user deleted file mode 100644 index a1e3c97..0000000 --- a/src/xtree.vcxproj.user +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/xml/modeldata1.xtr b/xml/modeldata1.xtr index 205ea34..4a15fda 100644 --- a/xml/modeldata1.xtr +++ b/xml/modeldata1.xtr @@ -15,9 +15,8 @@ - - - + + diff --git a/xml/modelsheets.xml b/xml/modelsheets.xml index ec9a8d6..62de50f 100644 --- a/xml/modelsheets.xml +++ b/xml/modelsheets.xml @@ -124,8 +124,18 @@ - - + + + + + + + + + + + + diff --git a/xml/saved_testfile.xtr b/xml/saved_testfile.xtr index 62c70bd..c2fec54 100644 --- a/xml/saved_testfile.xtr +++ b/xml/saved_testfile.xtr @@ -7,13 +7,12 @@ - + - - - + +