MauiKit Calendar

YearsGrid.qml
1import QtQuick
2import QtQuick.Layouts
3import QtQuick.Controls
4
5import org.mauikit.controls 1.3 as Maui
6import org.mauikit.calendar 1.0 as Kalendar
7
8/**
9 * @inherit QtQuick.Controls.Page
10 * @brief A view for browsing calendar years.
11 *
12 * @image html yearsgrid.png "Years view control"
13 *
14 * @code
15 * YearsGrid
16 * {
17 * anchors.fill: parent
18 *
19 * from: 2010
20 * to: 2029
21 * }
22 * @endcode
23 */
24Page
25{
26 id: control
27
28 background: null
29 padding: Maui.Style.defaultPadding
30
31 /**
32 * @brief
33 */
34 property int from : 1999
35
36 /**
37 * @brief
38 */
39 property int to : 2100
40
41 /**
42 * @brief
43 */
44 property int selectedYear :
45 {
46 var date = new Date()
47 return date.getFullYear()
48 }
49
50 /**
51 * @brief
52 */
53 property alias columns : _yearsGrid.columns
54
55 /**
56 * @brief
57 * @param year
58 */
59 signal yearSelected(var year)
60
61 contentItem: ScrollView
62 {
63 Flickable
64 {
65 contentHeight: _yearsGrid.implicitHeight
66 contentWidth: availableWidth
67
68 GridLayout
69 {
70 id: _yearsGrid
71
72 anchors.fill: parent
73 columns: Math.max(3, width/80)
74
75 ButtonGroup
76 {
77 buttons: _yearsGrid.children
78 }
79
80 Repeater
81 {
82 model: control.to - control.from + 1
83 delegate: Button
84 {
85 property int year : control.from + modelData
86 Layout.fillWidth: true
87 Layout.maximumWidth: 80
88 text: year
89
90 checkable: true
91 checked: year === control.selectedYear
92 onClicked: control.yearSelected(year)
93
94 background: Rectangle
95 {
96 visible: checked
97 color: checked ? Maui.Theme.highlightColor : hovered ? Maui.Theme.hoverColor : "transparent"
98 radius: Maui.Style.radiusV
99 }
100 }
101 }
102 }
103 }
104 }
105}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:50:32 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.