diff options
Diffstat (limited to 'src/styles/Base/TableViewStyle.qml')
-rw-r--r-- | src/styles/Base/TableViewStyle.qml | 62 |
1 files changed, 42 insertions, 20 deletions
diff --git a/src/styles/Base/TableViewStyle.qml b/src/styles/Base/TableViewStyle.qml index 669b934f..ff7237b0 100644 --- a/src/styles/Base/TableViewStyle.qml +++ b/src/styles/Base/TableViewStyle.qml @@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0 \qmltype TableViewStyle \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup viewsstyling \brief Provides custom styling for TableView Note that this class derives from \l ScrollViewStyle @@ -59,7 +60,13 @@ ScrollViewStyle { /*! The text color. */ property color textColor: __syspal.text - /*! The text highlight color, used behind selections. */ + /*! The background color. */ + property color backgroundColor: __syspal.base + + /*! The alternate background color. */ + property color alternateBackgroundColor: Qt.darker(__syspal.base, 1.06) + + /*! The text highlight color, used within selections. */ property color highlightedTextColor: "white" /*! Activates items on single click. */ @@ -67,15 +74,19 @@ ScrollViewStyle { padding.top: control.headerVisible ? 0 : 1 - /* Delegate for header. This delegate is described in \l TableView::headerDelegate */ + /*! \qmlproperty Component TableViewStyle::headerDelegate + Delegate for header. This delegate is described in \l {TableView::headerDelegate} + */ property Component headerDelegate: BorderImage { source: "images/header.png" + border.left: 4 Text { anchors.fill: parent verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignLeft - anchors.leftMargin: 4 - text: itemValue + anchors.leftMargin: 12 + text: styleData.value + elide: Text.ElideRight color: textColor renderType: Text.NativeRendering } @@ -89,52 +100,63 @@ ScrollViewStyle { } } - /* Delegate for header. This delegate is described in \l TableView::rowDelegate */ + /*! \qmlproperty Component TableViewStyle::rowDelegate + Delegate for header. This delegate is described in \l {TableView::rowDelegate} + */ property Component rowDelegate: Rectangle { - implicitHeight: 20 - implicitWidth: 80 - property color selectedColor: hasActiveFocus ? "#38d" : "#999" + height: 20 + property color selectedColor: styleData.hasActiveFocus ? "#38d" : "#999" gradient: Gradient { - GradientStop { color: rowSelected ? Qt.lighter(selectedColor, 1.3) : alternateBackground ? "#f2f2f2" : "white" ; position: 0 } - GradientStop { color: rowSelected ? Qt.lighter(selectedColor, 1.0) : alternateBackground ? "#f2f2f2" : "white" ; position: 1 } + GradientStop { + color: styleData.selected ? Qt.lighter(selectedColor, 1.3) : + styleData.alternate ? alternateBackgroundColor : backgroundColor + position: 0 + } + GradientStop { + color: styleData.selected ? Qt.lighter(selectedColor, 1.0) : + styleData.alternate ? alternateBackgroundColor : backgroundColor + position: 1 + } } Rectangle { anchors.bottom: parent.bottom width: parent.width height: 1 - color: rowSelected ? Qt.darker(selectedColor, 1.4) : "transparent" + color: styleData.selected ? Qt.darker(selectedColor, 1.4) : "transparent" } Rectangle { anchors.top: parent.top width: parent.width ; height: 1 - color: rowSelected ? Qt.darker(selectedColor, 1.1) : "transparent" + color: styleData.selected ? Qt.darker(selectedColor, 1.1) : "transparent" } } - /* Delegate for header. This delegate is described in \l TableView::itemDelegate */ + /*! \qmlproperty Component TableViewStyle::itemDelegate + Delegate for item. This delegate is described in \l {TableView::itemDelegate} + */ property Component itemDelegate: Item { height: Math.max(16, label.implicitHeight) - property int implicitWidth: sizehint.paintedWidth + 4 + property int implicitWidth: sizehint.paintedWidth + 20 Text { id: label objectName: "label" width: parent.width - anchors.margins: 6 + anchors.leftMargin: 12 anchors.left: parent.left anchors.right: parent.right - horizontalAlignment: itemTextAlignment + horizontalAlignment: styleData.textAlignment anchors.verticalCenter: parent.verticalCenter anchors.verticalCenterOffset: 1 - elide: itemElideMode - text: itemValue != undefined ? itemValue : "" - color: itemTextColor + elide: styleData.elideMode + text: styleData.value != undefined ? styleData.value : "" + color: styleData.textColor renderType: Text.NativeRendering } Text { id: sizehint font: label.font - text: itemValue ? itemValue : "" + text: styleData.value ? styleData.value : "" visible: false } } |