2 Copyright (C) 2011 by Cuong Le <metacuong@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>
20 import "Themes.js" as Themes
21 import "main.js" as Script
26 anchors.verticalCenter: parent.verticalCenter
27 width: parent.width; height: parent.height;
28 x:-(parent.width * 1.5)
31 signal updatedate(int day, int month, int year)
35 property alias theme: theme_manager.item
36 source: Themes.default_theme()
40 Component.onCompleted: {
44 property int m_day: Script.curDay
45 property int m_month: Script.curMonth
46 property int m_year: Script.curYear
48 property Component headerRenderer:Component {
49 id: defaultHeaderRenderer
56 width: parent.width - 4
57 height: parent.height - 4
59 anchors.centerIn: parent
69 verticalAlignment: Text.AlignVCenter
70 horizontalAlignment: Text.AlignHCenter
74 font.pointSize: parent.width > parent.height ? width ? width / 6 : 1 : width / 4
80 property Component daysRenderer:
88 width: parent.width - 4
89 height: parent.height - 4
91 anchors.centerIn: parent
94 color: model ? model.inmonth ? (model.current ? "blue" : "lightsteelblue") : "#AAAAAA" : "black"
100 anchors.leftMargin: parent.width > parent.height ? 10 : 5
102 verticalAlignment: Text.AlignVCenter
103 horizontalAlignment: Text.AlignLeft
105 text: model ? model.day : ""
106 color: model ? model.inmonth ? (model.current ? "grey" : model.inholiday ? theme_manager.theme.markdate.holidays : "black") : "grey" : "red"
107 font.pointSize: parent.width > parent.height ? parent.width ? parent.width / 6 : 1 : parent.width / 4
113 anchors.leftMargin: txt_solar_day.anchors.leftMargin+ parent.width > parent.height ? 60 : 35
114 anchors.topMargin: 20
116 verticalAlignment: Text.AlignVCenter
117 horizontalAlignment: Text.AlignBottom
119 text: model ? model.lunar_day : ""
120 color: model ? model.inmonth ? (model.current ? "white" : "#700070") : "grey" : "red"
121 font.pointSize: parent.width > parent.height ? parent.width ? parent.width / 8 : 1 : parent.width / 5
130 property bool hold: false
131 property bool clicked: false
135 fullmonth.updatedate(model.day, m_month, m_year)
138 fullmonth.state="close";
142 if (model.isprevmonth){
167 recms.color="#F0F0F0"
172 recms.color=model ? model.inmonth ? (model.current ? "blue" : "lightsteelblue") : "#AAAAAA" : "black";
175 if (Math.abs(mouseY) >= 100){
204 anchors.fill: parent; anchors.bottomMargin: 0
214 anchors.topMargin: 40
215 anchors.horizontalCenter: parent.horizontalCenter
216 anchors.bottom: parent.bottom
217 anchors.top: parent.top
223 model: ["CN", "Hai", "Ba", "Tư", "Năm", "Sáu", "Bảy"]
228 width: fullmonthREC.width / grid.columns
229 height: (fullmonthREC.height-92) / grid.rows
231 property int theIndex: index
232 property variant theModel: model
235 property alias model: headerDelegate.theModel
236 property alias index: headerDelegate.theIndex
237 property alias cellWidth: headerDelegate.width
238 property alias cellHeight: headerDelegate.height
242 sourceComponent: headerRenderer
253 property int theIndex: index
254 property variant theModel: model
256 width: fullmonthREC.width / grid.columns
257 height: (fullmonthREC.height-92) / grid.rows
260 property alias model: daysDelegate.theModel
261 property alias index: daysDelegate.theIndex
262 property alias cellWidth: daysDelegate.width
263 property alias cellHeight: daysDelegate.height
267 sourceComponent: daysRenderer
279 width : fullmonth.width
288 anchors { horizontalCenter: fullmonth.horizontalCenter; top: fullmonth.top; topMargin: 10 }
291 text: "Tháng "+fullmonth.m_month+", "+fullmonth.m_year
297 id: toolBar; height: 42;
300 button1Label: "Quay Về"
302 fullmonth.state="close";
310 var firstdayofthemonthyear = Script.getLunarDate(1,m_month,m_year).jd;
311 var startfrom = (firstdayofthemonthyear+1)%7;
312 var daysofthemonthyear = Script.calDays(m_month,m_year);
316 var nextmonth = get_nextmonth(totalslot - (startfrom+daysofthemonthyear))
317 var prevmonth = get_prevmonth(startfrom)
319 var dayclick, monthclick, yearclick;
320 var datas1,datas,lunarclmonth,inmonth,isprevmonth;
322 for (var i=0;i<42;i++){
323 if (i >= startfrom && j<= daysofthemonthyear){
325 monthclick = m_month;
336 datas1=nextmonth[(totalslot-i)-1];
340 dayclick = datas1.duong;
341 monthclick = datas1.month;
342 yearclick = datas1.year;
347 if (dayclick == Script.curDay && monthclick==Script.curMonth && yearclick==Script.curYear)
350 var lunarcl = Script.getLunarDate(dayclick,monthclick,yearclick)
351 var lunar_day = lunarcl.day;
353 if (lunarcl.day === 1)
354 lunar_day = lunarcl.day+"/"+lunarcl.month;
356 var stemp = Script.convertSolar2Lunar(dayclick,monthclick,yearclick,7);
357 var inholiday = Script.is_holiday(dayclick, monthclick, stemp[0], stemp[1]);
359 monthModel.append({"day": dayclick, "current": current, "lunar_day":lunar_day, "inmonth":inmonth,"inholiday":inholiday,"isprevmonth":isprevmonth})
364 function get_prevmonth(startfrom){
373 var daysofthemonthyear = Script.calDays(cMonth,cYear);
374 for (var i=daysofthemonthyear;i>daysofthemonthyear-startfrom;i--){
375 var lunarcl = Script.getLunarDate(i,cMonth,cYear)
376 pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear})
378 return pmonth.reverse()
381 function get_nextmonth(startfrom){
391 for (var i=1;i<=startfrom;i++){
392 var lunarcl = Script.getLunarDate(i,cMonth,cYear)
393 pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear});
395 return pmonth.reverse();
401 AnchorChanges { target: fullmonth; anchors.right: parent.right }
405 AnchorChanges { target: fullmonth; anchors.right: parent.left }
409 transitions: Transition {
410 AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }