Last active
October 9, 2021 18:59
-
-
Save cgiannakidis70/37ac6f6aed0274c2408f9414c1afe1f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ListView{ | |
id: monthofdayCalendar | |
width: dayView.width*.58 | |
height: dayView.height-100 | |
x:10 | |
y:20 | |
interactive: false | |
highlightRangeMode: ListView.StrictlyEnforceRange | |
boundsBehavior:Flickable.StopAtBounds | |
orientation: Qt.Horizontal | |
clip: true | |
model:monthlistModel//12 | |
currentIndex : monthName//calendarMonth.selectedDate.getMonth() | |
highlightMoveDuration : 200 | |
highlightMoveVelocity : 1000 | |
delegate: Item { | |
id:monthofdaycalendarDelegate | |
width:monthofdayCalendar.width | |
height:monthofdayCalendar.height | |
property int monthofdaycalendarIndex: index | |
property var newdayCalendar: dayCalendar | |
Label { | |
id: monthnameLabel | |
x:400 | |
y:20 | |
text:Qt.locale("en_US").standaloneMonthName((monthName===calendarMonth.selectedDate.getMonth() ? monthName : calendarMonth.selectedDate.getMonth()), Locale.LongFormat) + calendarMonth.selectedDate.toLocaleDateString(Qt.locale("en_US"), " yyyy")//calendarMonth.selectedDate.getFullYear(),index,calendarMonth.selectedDate.getDate() ).getMonth()index | |
font.pointSize: 18 | |
} | |
ListView { | |
id:dayCalendar | |
x: 0 | |
y: 50 | |
width: monthofdayCalendar.width | |
height: monthofdayCalendar.height | |
interactive: false | |
highlightRangeMode: ListView.StrictlyEnforceRange | |
boundsBehavior:Flickable.StopAtBounds | |
orientation: Qt.Horizontal | |
clip: true | |
currentIndex : calendarMonth.selectedDate.getDate() | |
model:daylistModel//32 | |
highlightMoveDuration : 500 | |
highlightMoveVelocity : 1000 | |
delegate : Item{ | |
id:calDelegate | |
width: dayCalendar.width | |
height: dayCalendar.height | |
property int calIndex: index | |
property var dayList: daylistView | |
Row { | |
id: eventDateRow | |
width: parent.width | |
height: eventDayLabel.height | |
spacing: 10 | |
Label { | |
id: eventDayLabel | |
text:day===0 ? calendarMonth.selectedDate.getDate() : day | |
font.pointSize: 35 | |
} | |
Column { | |
height: eventDayLabel.height | |
Label { | |
text:Qt.locale("en_US").standaloneDayName((new Date(calendarMonth.selectedDate.getFullYear(),calendarMonth.selectedDate.getMonth(),(day===0 ? calendarMonth.selectedDate.getDate() : day))).getDay(), Locale.LongFormat) //Qt.locale("en_US").standaloneDayName(calendarMonth.selectedDate.getDay(), Locale.LongFormat) | |
font.pointSize: 14 | |
} | |
/* Label { | |
text: Qt.locale("en_US").standaloneMonthName(calendarMonth.selectedDate.getMonth()) | |
+ calendarMonth.selectedDate.toLocaleDateString(Qt.locale("en_US"), " yyyy") | |
font.pointSize: 12 | |
}*/ | |
} | |
} | |
ListView{ | |
id:daylistView | |
width:dayCalendar.width | |
height:dayCalendar.height - 60 | |
boundsBehavior:Flickable.StopAtBounds | |
highlightRangeMode: ListView.ApplyRange//StrictlyEnforceRange | |
orientation: Qt.Vertical | |
anchors.top:eventDateRow.bottom | |
clip:true | |
focus:true | |
model:hourlistModel | |
currentIndex : calendarMonth.selectedDate.getDay() === new Date().getDay() | |
&& calendarMonth.selectedDate.getDate() === new Date().getDate() | |
&& calendarMonth.selectedDate.getMonth() === new Date().getMonth() ? getHour() : 12 | |
interactive: true | |
delegate: Item{ | |
id:hourItem | |
property int daylistIndex:index | |
property var hourTime: hourweeklistviewLabel | |
property var notetaking: notesLabel | |
width: daylistView.width | |
height: 60 | |
MouseArea{ | |
anchors.fill:parent | |
onClicked:{ | |
windowLoader.active =true | |
daylistView.currentIndex=index | |
//dayCalendar.currentIndex = calDelegate.calIndex | |
//dayCalendar.currentIndex = Qt.binding(function() { return calendarMonth.selectedDate.getDate() }) | |
} | |
} | |
Rectangle { | |
z:4 | |
id:hourdaylistviewindexLine | |
y:getdayMinute() | |
width:hourItem.width | |
height:2 | |
border.color: calendarMonth.selectedDate.getDate()===new Date().getDate() | |
&& getHour()+":00" === hourweeklistviewLabel.text | |
&& calendarMonth.selectedDate.getMonth() === new Date().getMonth() | |
?"red" : "transparent" | |
border.width:1 | |
} | |
Rectangle { | |
z:4 | |
id:hourline | |
//anchors.verticalCenter: daylistView | |
width:daylistView.width | |
height:2 | |
border.color: getHour()+":00" === hourweeklistviewLabel.text | |
&& calendarMonth.selectedDate.getDate()===new Date().getDate() | |
&& calendarMonth.selectedDate.getMonth() === new Date().getMonth() | |
&& getdayMinute()=== "00" ? "red": "lightgray" | |
border.width:1 | |
} | |
Label{ | |
z:4 | |
id:hourweeklistviewLabel | |
//anchors.verticalCenter: parent | |
text: hour + ":00" | |
color: getHour()+":00" === hourweeklistviewLabel.text | |
&& calendarMonth.selectedDate.getDate() === new Date().getDate() | |
&& calendarMonth.selectedDate.getDay() === new Date().getDay() | |
&& calendarMonth.selectedDate.getMonth() === new Date().getMonth() | |
? systemPalette.highlight : "lightgray" | |
font.pointSize: 10 | |
} | |
Label{ | |
z:4 | |
id:notesLabel | |
anchors.left:hourweeklistviewLabel.right | |
anchors.leftMargin: 30 | |
text:notes | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
ListModel{ | |
id:hourlistModel | |
ListElement{ hour:0;notes:""} | |
ListElement{ hour:1;notes:""} | |
ListElement{ hour:2;notes:""} | |
ListElement{ hour:3;notes:""} | |
ListElement{ hour:4;notes:""} | |
ListElement{ hour:5;notes:""} | |
ListElement{ hour:6;notes:""} | |
ListElement{ hour:7;notes:""} | |
ListElement{ hour:8;notes:""} | |
ListElement{ hour:9;notes:""} | |
ListElement{ hour:10;notes:""} | |
ListElement{ hour:11;notes:""} | |
ListElement{ hour:12;notes:""} | |
ListElement{ hour:13;notes:""} | |
ListElement{ hour:14;notes:""} | |
ListElement{ hour:15;notes:""} | |
ListElement{ hour:16;notes:""} | |
ListElement{ hour:17;notes:""} | |
ListElement{ hour:18;notes:""} | |
ListElement{ hour:19;notes:""} | |
ListElement{ hour:20;notes:""} | |
ListElement{ hour:21;notes:""} | |
ListElement{ hour:22;notes:""} | |
ListElement{ hour:23;notes:""} | |
/*Component.onCompleted:{ | |
for (var i = 0; i <25; i++){ | |
append(createListElement()) | |
} | |
} | |
property int h:0 | |
function createListElement(){ | |
return { | |
hour : h++ | |
} | |
}*/ | |
} | |
ListModel{ | |
id:daylistModel | |
ListElement{ day:0} | |
ListElement{ day:1} | |
ListElement{ day:2} | |
ListElement{ day:3} | |
ListElement{ day:4} | |
ListElement{ day:5} | |
ListElement{ day:6} | |
ListElement{ day:7} | |
ListElement{ day:8} | |
ListElement{ day:9} | |
ListElement{ day:10} | |
ListElement{ day:11} | |
ListElement{ day:12} | |
ListElement{ day:13} | |
ListElement{ day:14} | |
ListElement{ day:15} | |
ListElement{ day:16} | |
ListElement{ day:17} | |
ListElement{ day:18} | |
ListElement{ day:19} | |
ListElement{ day:20} | |
ListElement{ day:21} | |
ListElement{ day:22} | |
ListElement{ day:23} | |
ListElement{ day:24} | |
ListElement{ day:25} | |
ListElement{ day:26} | |
ListElement{ day:27} | |
ListElement{ day:28} | |
ListElement{ day:29} | |
ListElement{ day:30} | |
ListElement{ day:31} | |
/*Component.onCompleted:{ | |
for (var j=0; j < 32; j++){ | |
append(createListElement()) | |
} | |
} | |
property int dD:0 | |
function createListElement(){ | |
return { | |
day : dD++ | |
} | |
}*/ | |
} | |
ListModel{ | |
id:monthlistModel | |
ListElement{ monthName:0} | |
ListElement{ monthName:1} | |
ListElement{ monthName:2} | |
ListElement{ monthName:3} | |
ListElement{ monthName:4} | |
ListElement{ monthName:5} | |
ListElement{ monthName:6} | |
ListElement{ monthName:7} | |
ListElement{ monthName:8} | |
ListElement{ monthName:9} | |
ListElement{ monthName:10} | |
ListElement{ monthName:11} | |
/*Component.onCompleted:{ | |
for (var k=0; k <12; k++){ | |
append(createListElement()) | |
} | |
} | |
property int mN:0 | |
function createListElement(){ | |
return { | |
monthName : mN++ | |
} | |
}*/ | |
} | |
ListModel{ | |
id:weeklistModel | |
Component.onCompleted:{ | |
for (var l=0; l < 7; l++){ | |
append(createListElement()) | |
} | |
} | |
property int wD:0 | |
function createListElement(){ | |
return { | |
weekDay : wD++ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you set
dayCalendar.currentIndex
on line 93, you are throwing away the binding on line 9. You can restore it with the following code:dayCalendar.currentIndex = Qt.binding(function() { return calendarMonth.selectedDate.getDate() })