Warning, /maui/mauikit-calendar/src/controls.5/YearView.qml is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2018 Michael Bohlender, <bohlender@kolabsys.com> 0002 // Copyright (C) 2018 Christian Mollekopf, <mollekopf@kolabsys.com> 0003 // SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com> 0004 // SPDX-License-Identifier: GPL-2.0-or-later 0005 0006 import QtQuick 2.4 0007 import QtQuick.Layouts 1.1 0008 import QtQuick.Controls 2.15 as QQC2 0009 0010 import org.mauikit.controls 1.3 as Maui 0011 import org.mauikit.calendar 1.0 as Kalendar 0012 0013 import "dateutils.js" as DateUtils 0014 0015 QQC2.Pane 0016 { 0017 id: control 0018 0019 0020 property date selectedDate: currentDate 0021 readonly property date currentDate: new Date() 0022 0023 signal monthClicked(var date) 0024 0025 property date startDate 0026 property date firstDayOfMonth 0027 0028 property int year : currentDate.getUTCFullYear() 0029 0030 property bool initialMonth: true 0031 readonly property bool isLarge: width > Maui.Style.units.gridUnit * 40 0032 readonly property bool isTiny: width <= Maui.Style.units.gridUnit * 40 0033 0034 property alias gridView : _gridView 0035 0036 readonly property string title: control.year 0037 0038 contentItem: Maui.GridBrowser 0039 { 0040 id: _gridView 0041 0042 itemHeight: Math.max(itemSize, 160) 0043 itemSize: Math.min(width/3, 400) 0044 0045 currentIndex: currentDate.getUTCMonth() 0046 model: 12 0047 0048 delegate: Loader 0049 { 0050 id: viewLoader 0051 0052 property bool isNextOrCurrentItem: index >= _gridView.currentIndex -1 && index <= _gridView.currentIndex + 1 0053 property bool isCurrentItem: GridView.isCurrentItem 0054 0055 active: true 0056 asynchronous: !isCurrentItem 0057 visible: status === Loader.Ready 0058 0059 width: GridView.view.cellWidth - (control.isTiny ? 0 : Maui.Style.space.small) 0060 height: GridView.view.cellHeight - (control.isTiny ? 0 : Maui.Style.space.small) 0061 0062 sourceComponent: Kalendar.DaysGrid 0063 { 0064 // Maui.Theme.colorSet: Maui.Theme.Button 0065 // Maui.Theme.inherit: false 0066 // 0067 id: _monthDelegate 0068 year: control.year 0069 month: modelData+1 0070 compact: control.isTiny 0071 onDateClicked: control.selectedDate = date 0072 header: Maui.LabelDelegate 0073 { 0074 width: parent.width 0075 isSection: true 0076 color: Maui.Theme.textColor 0077 label: _monthDelegate.title 0078 } 0079 0080 background: Rectangle 0081 { 0082 color: _monthDelegate.month === control.currentDate.getUTCMonth()+1 ? Maui.Theme.alternateBackgroundColor : (_monthDelegate.hovered ? Maui.Theme.hoverColor : Maui.Theme.backgroundColor) 0083 radius: Maui.Style.radiusV 0084 0085 MouseArea 0086 { 0087 id: _mouseArea 0088 hoverEnabled: true 0089 anchors.fill: parent 0090 onClicked: control.monthClicked(new Date(_monthDelegate.year, _monthDelegate.month)) 0091 } 0092 } 0093 } 0094 } 0095 0096 Component.onCompleted: _gridView.flickable.positionViewAtIndex(_gridView.currentIndex, GridView.Visible) 0097 } 0098 0099 function resetDate() 0100 { 0101 control.year = control.currentDate.getUTCFullYear() 0102 } 0103 0104 function nextDate() 0105 { 0106 control.year++ 0107 } 0108 0109 function previousDate() 0110 { 0111 control.year-- 0112 } 0113 } 0114