Kirigami-addons

DatePickerDelegate.qml
1// SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4import QtQuick 2.15
5import QtQuick.Templates 2.15 as T
6import QtQuick.Layouts 1.15
7import org.kde.kirigami 2.20 as Kirigami
8import org.kde.kirigamiaddons.delegates 1.0 as Delegates
9
10Delegates.RoundedItemDelegate {
11 id: root
12
13 required property int index
14 required property date date
15 required property date minimumDate
16 required property date maximumDate
17 required property Repeater repeater
18 required property T.Action previousAction
19 required property T.Action nextAction
20
21 readonly property bool inScope: (!minimumDate.valueOf() || minimumDate.valueOf() <= date.valueOf())
22 && (!maximumDate.valueOf() || maximumDate.valueOf() >= date.valueOf())
23
24 leftInset: 0
25 rightInset: 0
26 topInset: 0
27 bottomInset: 0
28
29 focusPolicy: inScope ? Qt.TabFocus : Qt.NoFocus
30 enabled: inScope
31
32 focus: inScope && (index === 0 || !repeater.itemAt(index - 1).inScope)
33
34 contentItem: Delegates.DefaultContentItem {
35 itemDelegate: root
36
37 labelItem {
38 leftPadding: Kirigami.Units.mediumSpacing
39 rightPadding: Kirigami.Units.mediumSpacing
40 horizontalAlignment: Text.AlignHCenter
41 }
42 }
43
44 Keys.onLeftPressed: if (inScope) {
45 if (index !== 0) {
46 const item = repeater.itemAt(index - 1);
47 if (item.inScope) {
48 item.forceActiveFocus();
49 }
50 } else {
51 goPreviousAction.trigger();
52 }
53 }
54
55 Keys.onRightPressed: if (inScope) {
56 if (index !== repeater.count - 1) {
57 const item = repeater.itemAt(index + 1);
58 if (item.inScope) {
59 item.forceActiveFocus();
60 }
61 } else {
62 goNextAction.trigger();
63 }
64 }
65
66 Layout.fillWidth: true
67 Layout.fillHeight: true
68}
Content item which is used by default in the RoundedItemDelegate and IndicatorItemDelegate.
AlignHCenter
TabFocus
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:46:57 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.