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
27 anchors.verticalCenter: parent.verticalCenter
28 width: parent.width; height: parent.height;
29 x:(parent.width * 1.5)
33 property alias theme: theme_manager.item
34 source: Themes.default_theme()
38 signal updatedate(int day, int month, int year)
44 anchors.centerIn: parent
49 border.color: "#b57e8f"
55 anchors.right: parent.right; anchors.rightMargin: 145; y: 185; width: 100; height: 40
56 anchors.horizontalCenter: parent.horizontalCenter
60 var lday = lunarday_pathview.currentIndex+1;
61 var lmonth=lunarmonth_pathview.currentIndex+1;
62 var lyear=lunaryear_pathview.currentIndex+1900;
68 for (var l=0;l<12;l++)
69 if (lunarmonth_model.get(l).nhuan){
73 if(lunarmonth_model.get(lunarmonth_pathview.currentIndex).nhuan){
78 if (thangnhuan!=-1 && lunarmonth_pathview.currentIndex> thangnhuan)
81 var finalSolarDay = Script.convertLunar2Solar(lday,lmonth,lyear,lnhuan,7);
83 amdatetime.state="close";
85 amdatetime.updatedate(finalSolarDay[0], finalSolarDay[1], finalSolarDay[2])
97 anchors.rightMargin: 56
99 amdatetime.state="close"
122 border.color: "#b57e8f"
128 width: 198; height: 129
154 name: "switch_to_day";
155 PropertyChanges { target:lmk;x:10;width:60;}
156 PropertyChanges { target:lunaryear_pathview;pathItemCount:1;}
157 PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;}
158 PropertyChanges { target:lunarday_pathview;pathItemCount:3;}
159 PropertyChanges { target:lunarday_mousearea;visible:false;}
160 PropertyChanges { target:lunaryear_mousearea;visible:true;}
161 PropertyChanges { target:lunarmonth_mousearea;visible:true;}
164 name: "switch_to_year";
165 PropertyChanges { target:lmk;x:207;width:198;}
166 PropertyChanges { target:lunarday_pathview;pathItemCount:1;}
167 PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;}
168 PropertyChanges { target:lunaryear_pathview;pathItemCount:3;}
169 PropertyChanges { target:lunarday_mousearea;visible:true;}
170 PropertyChanges { target:lunaryear_mousearea;visible:false;}
171 PropertyChanges { target:lunarmonth_mousearea;visible:true;}
174 name: "switch_to_month";
175 PropertyChanges { target:lmk;x:60;width:150;}
176 PropertyChanges { target:lunarday_pathview;pathItemCount:1;}
177 PropertyChanges { target:lunaryear_pathview;pathItemCount:1;}
178 PropertyChanges { target:lunarmonth_pathview;pathItemCount:3;}
179 PropertyChanges { target:lunarday_mousearea;visible:true;}
180 PropertyChanges { target:lunaryear_mousearea;visible:true;}
181 PropertyChanges { target:lunarmonth_mousearea;visible:false;}
187 state: "switch_to_year"
190 width: 178; height: 129
193 property int index: 0
194 onIndexChanged: lunaryear_pathview.currentIndex = lunaryear_rec.index
197 id: lunaryear_delegate
204 width: lunaryear_rec.width
205 color: PathView.isCurrentItem ? "#FFFFFF" : "grey"
206 verticalAlignment:Text.AlignLeft
213 id:lunaryear_pathview
215 model: lunaryear_model
216 delegate: lunaryear_delegate
219 preferredHighlightBegin: 0.5
220 preferredHighlightEnd: 0.5
221 highlightRangeMode: PathView.StrictlyEnforceRange
226 PathLine {x: 90; y: lunaryear_rec.height}
230 Script.getYearInfo(lunaryear_pathview.currentIndex+1900);
231 lunarmonth_model.change(lunaryear_pathview.currentIndex+1900, lunarmonth_pathview.currentIndex+1);
235 id:lunaryear_mousearea
238 rec22.state="switch_to_year"
247 for(var i=1900;i<2099;i++){
248 var lunarYear = Script.getYearCanChi(i)
249 append({name:i+" ("+lunarYear+")"})
253 function change(YYYY){
254 lunaryear_pathview.currentIndex=-1;
255 lunaryear_pathview.currentIndex = YYYY - 1900
262 state:"switch_to_day"
266 width: 80; height: 129
269 property int index: 0
270 onIndexChanged: lunarday_pathview.currentIndex = lunarday_rec.index
273 id: lunarday_delegate
281 width: lunarday_rec.width
282 color: PathView.isCurrentItem ? "#FFFFFF" : "grey"
283 verticalAlignment:Text.AlignVCenter
293 model: lunarday_model
294 delegate: lunarday_delegate
297 preferredHighlightBegin: 0.5
298 preferredHighlightEnd: 0.5
299 highlightRangeMode: PathView.StrictlyEnforceRange
304 PathLine {x: 90; y: lunarday_rec.height}
309 id:lunarday_mousearea
312 rec22.state="switch_to_day"
322 for(var i=1;i<=30;i++)
323 lunarday_model.append({name:i})
326 function change(MM,DD){
328 while(lunarday_model.count>0){
329 lunarday_model.remove(lunarday_model.count-1)
333 var daystotal = Script.RMM[MM-1];
335 if(lunarmonth_model.get(MM-1).nhuan){
336 for (var i=1;i<=Script.LML;i++)
337 lunarday_model.append({name:i})
339 for (var i=1;i<=daystotal;i++)
340 lunarday_model.append({name:i})
343 lunarday_pathview.currentIndex=-1;
344 lunarday_pathview.currentIndex= DD-1;
354 state:"switch_to_month"
358 width: 150; height: 129
361 property int index: 0
362 onIndexChanged: lunarmonth_pathview.currentIndex = lunarmonth_rec.index
365 id: lunarmonth_delegate
373 width: lunarmonth_rec.width
374 color: PathView.isCurrentItem ? "#FFFFFF" : "grey"
375 verticalAlignment:Text.AlignVCenter
383 id:lunarmonth_pathview
385 model: lunarmonth_model
386 delegate: lunarmonth_delegate
389 preferredHighlightBegin: 0.5
390 preferredHighlightEnd: 0.5
391 highlightRangeMode: PathView.StrictlyEnforceRange
396 PathLine {x: 90; y: lunarmonth_rec.height}
399 lunarday_model.change(lunarmonth_pathview.currentIndex+1,lunarday_pathview.currentIndex+1);
404 id:lunarmonth_mousearea
407 rec22.state="switch_to_month"
416 Component.onCompleted: {
420 function change(YYYY, MM){
421 while(lunarmonth_model.count>0){
422 lunarmonth_model.remove(lunarmonth_model.count-1)
426 lunarday_model.change(lunarmonth_pathview.currentIndex+1,lunarday_pathview.currentIndex+1);
429 function readd(YYYY, MM){
431 var preFix = "Tháng ";
432 var a=Script.leapMonth(yTest)
435 for(var i=0;i<=12;i++){
436 var l=Script.getYearInfo(yTest)[i].month
438 lunarmonth_model.append({name:preFix+l+" (N)", nhuan:true})
440 lunarmonth_model.append({name:preFix+l, nhuan:false})
446 for(var i=1;i<=12;i++)
447 lunarmonth_model.append({name:preFix+i, nhuan:false})
450 lunarmonth_pathview.currentIndex=-1;
451 lunarmonth_pathview.currentIndex = MM-1;
461 Component.onCompleted: {
468 AnchorChanges { target: amdatetime; anchors.right: parent.right }
472 AnchorChanges { target: amdatetime; anchors.right: parent.left }
477 var acs = Script.getYearInfo(Script.curYear)
478 var a=Script.getLunarDate(Script.curDay,Script.curMonth,Script.curYear)
479 var finalmonth=a.month;
483 var aaa=Script.leapMonth(Script.curYear)
487 for (var i=0;i<=12;i++){
489 if (t==l && a.leap===0){
491 finalmonth = finalmonth+1;
501 lunaryear_model.init()
502 lunarday_model.init()
503 lunaryear_model.change(a.year)
504 lunarmonth_model.change(a.year, finalmonth)
505 lunarday_model.change(finalmonth,a.day)
509 transitions: Transition {
510 AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }