Warning, /libraries/kirigami-addons/src/dateandtime/private/DatePickerDelegate.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
0002 // SPDX-License-Identifier: LGPL-2.1-or-later
0003
0004 import QtQuick 2.15
0005 import QtQuick.Templates 2.15 as T
0006 import QtQuick.Layouts 1.15
0007 import org.kde.kirigami 2.20 as Kirigami
0008 import org.kde.kirigamiaddons.delegates 1.0 as Delegates
0009
0010 Delegates.RoundedItemDelegate {
0011 id: root
0012
0013 required property int index
0014 required property date date
0015 required property date minimumDate
0016 required property date maximumDate
0017 required property Repeater repeater
0018 required property T.Action previousAction
0019 required property T.Action nextAction
0020
0021 readonly property bool inScope: (!minimumDate.valueOf() || minimumDate.valueOf() <= date.valueOf())
0022 && (!maximumDate.valueOf() || maximumDate.valueOf() >= date.valueOf())
0023
0024 leftInset: 0
0025 rightInset: 0
0026 topInset: 0
0027 bottomInset: 0
0028
0029 focusPolicy: inScope ? Qt.TabFocus : Qt.NoFocus
0030 enabled: inScope
0031
0032 focus: inScope && (index === 0 || !repeater.itemAt(index - 1).inScope)
0033
0034 contentItem: Delegates.DefaultContentItem {
0035 itemDelegate: root
0036
0037 labelItem {
0038 leftPadding: Kirigami.Units.mediumSpacing
0039 rightPadding: Kirigami.Units.mediumSpacing
0040 horizontalAlignment: Text.AlignHCenter
0041 }
0042 }
0043
0044 Keys.onLeftPressed: if (inScope) {
0045 if (index !== 0) {
0046 const item = repeater.itemAt(index - 1);
0047 if (item.inScope) {
0048 item.forceActiveFocus();
0049 }
0050 } else {
0051 goPreviousAction.trigger();
0052 }
0053 }
0054
0055 Keys.onRightPressed: if (inScope) {
0056 if (index !== repeater.count - 1) {
0057 const item = repeater.itemAt(index + 1);
0058 if (item.inScope) {
0059 item.forceActiveFocus();
0060 }
0061 } else {
0062 goNextAction.trigger();
0063 }
0064 }
0065
0066 Layout.fillWidth: true
0067 Layout.fillHeight: true
0068 }