diff --git a/qml/xqtreeview.qml b/qml/xqtreeview.qml index a4b3be9..b2652f0 100644 --- a/qml/xqtreeview.qml +++ b/qml/xqtreeview.qml @@ -33,18 +33,38 @@ TreeView //color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff") //color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff") + + TextField { - id: entry + id: currentEntry anchors.centerIn: parent text: display font.pixelSize: 12 - background: Rectangle - { - //color: entry.enabled ? "transparent" : "#353637" - //border.color: entry.enabled ? "#21be2b" : "transparent" - border.color: "transparent" + + // Ä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: 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 aef7a27..35ba1d3 100644 --- a/src/items/xqitemdelegate.cpp +++ b/src/items/xqitemdelegate.cpp @@ -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; @@ -119,49 +120,32 @@ void XQItemDelegate::drawHeaderStyle(QPainter* painter, const QStyleOptionViewIt { QStyleOptionHeader headerOption; -/* - QWidget* srcWidget = nullptr; - const QTreeView* treeView = qobject_cast(option.widget); - if (treeView != nullptr) - { - srcWidget = (QWidget*)treeView; - // is never nullptr !? - if (treeView->header() != nullptr) - { - // use the header as "parent" for style init - srcWidget = treeView->header(); - } - headerOption.initFrom(srcWidget); - headerOption.text = "FIRZ";//index.data(Qt::DisplayRole).toString(); - headerOption.rect = option.rect; - headerOption.styleObject = option.styleObject; - // __ch: reduce inner offset when painting - headerOption.textAlignment |= Qt::AlignVCenter; - - // -- - } -*/ - // 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; headerOption.icon = item.icon(); - // 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(); - QApplication::style()->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(); + } @@ -186,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(); @@ -222,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); @@ -244,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) { @@ -253,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()); } 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/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.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..e522e97 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;quickcontrols2;quickdialogs2;quicklayouts;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/saved_testfile.xtr b/xml/saved_testfile.xtr index 7a52cb6..c2fec54 100644 --- a/xml/saved_testfile.xtr +++ b/xml/saved_testfile.xtr @@ -6,14 +6,13 @@ - - + + - + - - - + +