BasicTableViewStyle.qml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the Qt Quick Controls module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or (at your option) the GNU General
  28. ** Public license version 3 or any later version approved by the KDE Free
  29. ** Qt Foundation. The licenses are as published by the Free Software
  30. ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
  31. ** included in the packaging of this file. Please review the following
  32. ** information to ensure the GNU General Public License requirements will
  33. ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
  34. ** https://www.gnu.org/licenses/gpl-3.0.html.
  35. **
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. import QtQuick 2.2
  40. import QtQuick.Controls 1.4
  41. import QtQuick.Controls.Private 1.0
  42. /*!
  43. \qmltype BasicTableViewStyle
  44. \internal
  45. \inqmlmodule QtQuick.Controls.Styles
  46. \inherits ScrollViewStyle
  47. \qmlabstract
  48. */
  49. ScrollViewStyle {
  50. id: root
  51. /*! \qmlproperty BasicTableView BasicTableViewStyle::control
  52. \internal */
  53. readonly property BasicTableView control: __control
  54. /*! \qmlproperty color BasicTableViewStyle::textColor
  55. The text color. */
  56. property color textColor: SystemPaletteSingleton.text(control.enabled)
  57. /*! \qmlproperty color BasicTableViewStyle::backgroundColor
  58. The background color. */
  59. property color backgroundColor: control.backgroundVisible ? SystemPaletteSingleton.base(control.enabled) : "transparent"
  60. /*! \qmlproperty color BasicTableViewStyle::alternateBackgroundColor
  61. The alternate background color. */
  62. property color alternateBackgroundColor: "#f5f5f5"
  63. /*! \qmlproperty color BasicTableViewStyle::highlightedTextColor
  64. The text highlight color, used within selections. */
  65. property color highlightedTextColor: "white"
  66. /*! \qmlproperty bool BasicTableViewStyle::activateItemOnSingleClick
  67. Activates items on single click.
  68. Its default value is \c false.
  69. */
  70. property bool activateItemOnSingleClick: false
  71. padding.top: control.headerVisible ? 0 : 1
  72. /*! \qmlproperty Component BasicTableViewStyle::headerDelegate
  73. \internal
  74. Different documentation for TableViewStyle and TreeViewStyle.
  75. See qtquickcontrolsstyles-tableviewstyle.qdoc and qtquickcontrolsstyles-treeviewstyle.qdoc
  76. */
  77. property Component headerDelegate: BorderImage {
  78. height: Math.round(textItem.implicitHeight * 1.2)
  79. source: "images/header.png"
  80. border.left: 4
  81. border.bottom: 2
  82. border.top: 2
  83. Text {
  84. id: textItem
  85. anchors.fill: parent
  86. verticalAlignment: Text.AlignVCenter
  87. horizontalAlignment: styleData.textAlignment
  88. anchors.leftMargin: horizontalAlignment === Text.AlignLeft ? 12 : 1
  89. anchors.rightMargin: horizontalAlignment === Text.AlignRight ? 8 : 1
  90. text: styleData.value
  91. elide: Text.ElideRight
  92. color: textColor
  93. renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
  94. }
  95. Rectangle {
  96. width: 1
  97. height: parent.height - 2
  98. y: 1
  99. color: "#ccc"
  100. }
  101. }
  102. /*! \qmlproperty Component BasicTableViewStyle::rowDelegate
  103. \internal
  104. Different documentation for TableViewStyle and TreeViewStyle.
  105. See qtquickcontrolsstyles-tableviewstyle.qdoc and qtquickcontrolsstyles-treeviewstyle.qdoc
  106. */
  107. property Component rowDelegate: Rectangle {
  108. height: Math.round(TextSingleton.implicitHeight * 1.2)
  109. property color selectedColor: control.activeFocus ? "#07c" : "#999"
  110. color: styleData.selected ? selectedColor :
  111. !styleData.alternate ? alternateBackgroundColor : backgroundColor
  112. }
  113. /*! \qmlproperty Component BasicTableViewStyle::itemDelegate
  114. \internal
  115. Different documentation for TableViewStyle and TreeViewStyle.
  116. See qtquickcontrolsstyles-tableviewstyle.qdoc and qtquickcontrolsstyles-treeviewstyle.qdoc
  117. */
  118. property Component itemDelegate: Item {
  119. height: Math.max(16, label.implicitHeight)
  120. property int implicitWidth: label.implicitWidth + 20
  121. Text {
  122. id: label
  123. objectName: "label"
  124. width: parent.width - x - (horizontalAlignment === Text.AlignRight ? 8 : 1)
  125. x: (styleData.hasOwnProperty("depth") && styleData.column === 0) ? 0 :
  126. horizontalAlignment === Text.AlignRight ? 1 : 8
  127. horizontalAlignment: styleData.textAlignment
  128. anchors.verticalCenter: parent.verticalCenter
  129. anchors.verticalCenterOffset: 1
  130. elide: styleData.elideMode
  131. text: styleData.value !== undefined ? styleData.value.toString() : ""
  132. color: styleData.textColor
  133. renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
  134. }
  135. }
  136. /*! \internal
  137. Part of TreeViewStyle
  138. */
  139. property Component __branchDelegate: null
  140. /*! \internal
  141. Part of TreeViewStyle
  142. */
  143. property int __indentation: 12
  144. }