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/>
19 import "../DatePicker/component" as Comp
21 import "amlich-hnd.js" as AmLich
22 import "amlich-aa98.js" as AmLich98
24 import "CacNgayLeTrongNam.js" as CNLTN
29 property int m_day: screen.curDay
30 property int m_month: screen.curMonth
31 property int m_year: screen.curYear
33 property Component headerRenderer:Component {
34 id: defaultHeaderRenderer
41 width: parent.width - 4
42 height: parent.height - 4
44 anchors.centerIn: parent
54 verticalAlignment: Text.AlignVCenter
55 horizontalAlignment: Text.AlignHCenter
59 font.pointSize: width ? width / 6 : 1
65 property Component daysRenderer:
73 width: parent.width - 4
74 height: parent.height - 4
76 anchors.centerIn: parent
79 color: model ? model.inmonth ? (model.current ? "blue" : "lightsteelblue") : "#AAAAAA" : "black"
85 anchors.leftMargin: 10
87 verticalAlignment: Text.AlignVCenter
88 horizontalAlignment: Text.AlignLeft
90 text: model ? model.day : ""
91 color: model ? model.inmonth ? (model.current ? "red" : model.inholiday ? theme_manager.theme.markdate.holidays : "black") : "grey" : "red"
92 font.pointSize: parent.width ? parent.width / 6 : 1
98 anchors.leftMargin: txt_solar_day.anchors.leftMargin+40
101 verticalAlignment: Text.AlignVCenter
102 horizontalAlignment: Text.AlignBottom
104 text: model ? model.lunar_day : ""
105 color: model ? model.inmonth ? (model.current ? "red" : "#700070") : "grey" : "red"
106 font.pointSize: parent.width ? parent.width / 8 : 1
114 property bool hold: false
117 LC.reset(model.day,m_month,m_year)
118 screen.calculateLunar(model.day,m_month,m_year)
119 screen.state="mainscreen"
121 maindatemodel.reset()
122 txtDATEpv.currentIndex = model.day-1;
132 recms.color="#F0F0F0"
138 if (Math.abs(mouseY) >= 30){
166 anchors.fill: parent; anchors.bottomMargin: 0
176 anchors.bottomMargin: -52
177 anchors.topMargin: 78
178 anchors.horizontalCenter: parent.horizontalCenter
179 anchors.bottom: parent.bottom
180 anchors.top: parent.top
186 model: ["CN", "Hai", "Ba", "Tư", "Năm", "Sáu", "Bảy"]
191 width: fullmonthREC.width / grid.columns
192 height: (fullmonthREC.height-92) / grid.rows
194 property int theIndex: index
195 property variant theModel: model
198 property alias model: headerDelegate.theModel
199 property alias index: headerDelegate.theIndex
200 property alias cellWidth: headerDelegate.width
201 property alias cellHeight: headerDelegate.height
205 sourceComponent: headerRenderer
216 property int theIndex: index
217 property variant theModel: model
219 width: fullmonthREC.width / grid.columns
220 height: (fullmonthREC.height-92) / grid.rows
223 property alias model: daysDelegate.theModel
224 property alias index: daysDelegate.theIndex
225 property alias cellWidth: daysDelegate.width
226 property alias cellHeight: daysDelegate.height
230 sourceComponent: daysRenderer
243 text: "Tháng "+m_month+", "+m_year
244 horizontalAlignment: Text.AlignHCenter
251 ToolBarSingle { id: toolBar; height: 50;
254 button1Label: "Quay Về"
257 screen.state="mainscreen"
264 var firstdayofthemonthyear = AmLich.getLunarDate(1,m_month,m_year).jd;
265 var startfrom = (firstdayofthemonthyear+1)%7;
266 var daysofthemonthyear = LC.calDays(m_month,m_year);
270 var nextmonth = get_nextmonth(totalslot - (startfrom+daysofthemonthyear))
271 var prevmonth = get_prevmonth(startfrom)
273 var dayclick, monthclick, yearclick;
274 var datas1,datas,lunarclmonth,inmonth;
276 for (var i=0;i<42;i++){
277 if (i >= startfrom && j<= daysofthemonthyear){
279 monthclick = m_month;
287 datas1=nextmonth[(totalslot-i)-1];
289 dayclick = datas1.duong;
290 monthclick = datas1.month;
291 yearclick = datas1.year;
296 if (dayclick == screen.curDay && monthclick==screen.curMonth && yearclick==screen.curYear)
299 var lunarcl = AmLich.getLunarDate(dayclick,monthclick,yearclick)
300 var lunar_day = lunarcl.day;
302 if (lunarcl.day === 1)
303 lunar_day = lunarcl.day+"/"+lunarcl.month;
305 var stemp = AmLich98.convertSolar2Lunar(dayclick,monthclick,yearclick,7);
306 var inholiday = CNLTN.is_holiday(dayclick, monthclick, stemp[0], stemp[1]);
308 monthModel.append({"day": dayclick, "current": current, "lunar_day":lunar_day, "inmonth":inmonth,"inholiday":inholiday})
313 function get_prevmonth(startfrom){
322 var daysofthemonthyear = LC.calDays(cMonth,cYear);
323 for (var i=daysofthemonthyear;i>daysofthemonthyear-startfrom;i--){
324 var lunarcl = AmLich.getLunarDate(i,cMonth,cYear)
325 pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear})
327 return pmonth.reverse()
330 function get_nextmonth(startfrom){
340 for (var i=1;i<=startfrom;i++){
341 var lunarcl = AmLich.getLunarDate(i,cMonth,cYear)
342 pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear});
344 return pmonth.reverse();