TumblerColumn.qml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 Extras 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 TumblerColumn
  44. \inqmlmodule QtQuick.Extras
  45. \since 5.5
  46. \ingroup extras
  47. \brief A column within a tumbler.
  48. TumblerColumn represents a column within a tumbler, providing the interface
  49. to define the items and width of each column.
  50. \code
  51. Tumbler {
  52. TumblerColumn {
  53. model: [1, 2, 3]
  54. }
  55. TumblerColumn {
  56. model: ["A", "B", "C"]
  57. visible: false
  58. }
  59. }
  60. \endcode
  61. You can create a custom appearance for a Tumbler by assigning a
  62. \l {TumblerStyle}.
  63. */
  64. QtObject {
  65. id: tumblerColumn
  66. /*! \internal */
  67. property Item __tumbler: null
  68. /*!
  69. \internal
  70. The index of this column within the tumbler.
  71. */
  72. property int __index: -1
  73. /*!
  74. \internal
  75. The index of the current item, if the PathView has items instantiated,
  76. or the last current index if it doesn't.
  77. */
  78. property int __currentIndex: -1
  79. property int accessibleRole: Accessible.ColumnHeader
  80. /*!
  81. \qmlproperty int TumblerColumn::currentIndex
  82. This read-only property holds the index of the current item for this
  83. column. If the model count is reduced, the current index will be
  84. reduced to the new count minus one.
  85. \sa {Tumbler::currentIndexAt}, {Tumbler::setCurrentIndexAt}
  86. */
  87. readonly property alias currentIndex: tumblerColumn.__currentIndex
  88. /*!
  89. This property holds the model that provides data for this column.
  90. */
  91. property var model: null
  92. /*!
  93. This property holds the model role of this column.
  94. */
  95. property string role: ""
  96. /*!
  97. The item delegate for this column.
  98. If set, this delegate will be used to display items in this column,
  99. instead of the
  100. \l {TumblerStyle::}{delegate}
  101. property in \l {TumblerStyle}.
  102. The \l {Item::implicitHeight}{implicitHeight} property must be set,
  103. and it must be the same for each delegate.
  104. */
  105. property Component delegate
  106. /*!
  107. The highlight delegate for this column.
  108. If set, this highlight will be used to display the highlight in this
  109. column, instead of the
  110. \l {TumblerStyle::}{highlight}
  111. property in \l {TumblerStyle}.
  112. */
  113. property Component highlight
  114. /*!
  115. The foreground of this column.
  116. If set, this component will be used to display the foreground in this
  117. column, instead of the
  118. \l {TumblerStyle::}{columnForeground}
  119. property in \l {TumblerStyle}.
  120. */
  121. property Component columnForeground
  122. /*!
  123. This property holds the visibility of this column.
  124. */
  125. property bool visible: true
  126. /*!
  127. This read-only property indicates whether the item has active focus.
  128. See Item's \l {Item::activeFocus}{activeFocus} property for more
  129. information.
  130. */
  131. readonly property bool activeFocus: {
  132. if (__tumbler === null)
  133. return null;
  134. var view = __tumbler.__viewAt(__index);
  135. return view && view.activeFocus ? true : false;
  136. }
  137. /*!
  138. This property holds the width of this column.
  139. */
  140. property real width: TextSingleton.implicitHeight * 4
  141. }