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: width ? width / 6 : 1
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: 10
102 verticalAlignment: Text.AlignVCenter
103 horizontalAlignment: Text.AlignLeft
105 text: model ? model.day : ""
106 color: model ? model.inmonth ? (model.current ? "red" : model.inholiday ? theme_manager.theme.markdate.holidays : "black") : "grey" : "red"
107 font.pointSize: parent.width ? parent.width / 6 : 1
113 anchors.leftMargin: txt_solar_day.anchors.leftMargin+40
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 ? "red" : "#700070") : "grey" : "red"
121 font.pointSize: parent.width ? parent.width / 8 : 1
129 property bool hold: false
132 /*LC.reset(model.day,m_month,m_year)
133 screen.calculateLunar(model.day,m_month,m_year)
134 screen.state="mainscreen"
136 maindatemodel.reset()*/
137 fullmonth.state="close";
139 fullmonth.updatedate(model.day, m_month, m_year)
149 recms.color="#F0F0F0"
155 if (Math.abs(mouseY) >= 30){
183 anchors.fill: parent; anchors.bottomMargin: 0
193 anchors.topMargin: 40
194 anchors.horizontalCenter: parent.horizontalCenter
195 anchors.bottom: parent.bottom
196 anchors.top: parent.top
202 model: ["CN", "Hai", "Ba", "Tư", "Năm", "Sáu", "Bảy"]
207 width: fullmonthREC.width / grid.columns
208 height: (fullmonthREC.height-92) / grid.rows
210 property int theIndex: index
211 property variant theModel: model
214 property alias model: headerDelegate.theModel
215 property alias index: headerDelegate.theIndex
216 property alias cellWidth: headerDelegate.width
217 property alias cellHeight: headerDelegate.height
221 sourceComponent: headerRenderer
232 property int theIndex: index
233 property variant theModel: model
235 width: fullmonthREC.width / grid.columns
236 height: (fullmonthREC.height-92) / grid.rows
239 property alias model: daysDelegate.theModel
240 property alias index: daysDelegate.theIndex
241 property alias cellWidth: daysDelegate.width
242 property alias cellHeight: daysDelegate.height
246 sourceComponent: daysRenderer
258 width : fullmonth.width
267 anchors { horizontalCenter: fullmonth.horizontalCenter; top: fullmonth.top; topMargin: 10 }
270 text: "Tháng "+fullmonth.m_month+", "+fullmonth.m_year
276 id: toolBar; height: 42;
279 button1Label: "Quay Về"
281 fullmonth.state="close";
289 var firstdayofthemonthyear = Script.getLunarDate(1,m_month,m_year).jd;
290 var startfrom = (firstdayofthemonthyear+1)%7;
291 var daysofthemonthyear = Script.calDays(m_month,m_year);
295 var nextmonth = get_nextmonth(totalslot - (startfrom+daysofthemonthyear))
296 var prevmonth = get_prevmonth(startfrom)
298 var dayclick, monthclick, yearclick;
299 var datas1,datas,lunarclmonth,inmonth;
301 for (var i=0;i<42;i++){
302 if (i >= startfrom && j<= daysofthemonthyear){
304 monthclick = m_month;
312 datas1=nextmonth[(totalslot-i)-1];
314 dayclick = datas1.duong;
315 monthclick = datas1.month;
316 yearclick = datas1.year;
321 if (dayclick == Script.curDay && monthclick==Script.curMonth && yearclick==Script.curYear)
324 var lunarcl = Script.getLunarDate(dayclick,monthclick,yearclick)
325 var lunar_day = lunarcl.day;
327 if (lunarcl.day === 1)
328 lunar_day = lunarcl.day+"/"+lunarcl.month;
330 var stemp = Script.convertSolar2Lunar(dayclick,monthclick,yearclick,7);
331 var inholiday = Script.is_holiday(dayclick, monthclick, stemp[0], stemp[1]);
333 monthModel.append({"day": dayclick, "current": current, "lunar_day":lunar_day, "inmonth":inmonth,"inholiday":inholiday})
338 function get_prevmonth(startfrom){
347 var daysofthemonthyear = Script.calDays(cMonth,cYear);
348 for (var i=daysofthemonthyear;i>daysofthemonthyear-startfrom;i--){
349 var lunarcl = Script.getLunarDate(i,cMonth,cYear)
350 pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear})
352 return pmonth.reverse()
355 function get_nextmonth(startfrom){
365 for (var i=1;i<=startfrom;i++){
366 var lunarcl = Script.getLunarDate(i,cMonth,cYear)
367 pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear});
369 return pmonth.reverse();
375 AnchorChanges { target: fullmonth; anchors.right: parent.right }
379 AnchorChanges { target: fullmonth; anchors.right: parent.left }
383 transitions: Transition {
384 AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }