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 "amlich-hnd.js" as AmLich
20 import "amlich-aa98.js" as AmLich98
30 anchors.centerIn: parent
35 border.color: "#b57e8f"
42 anchors.right: parent.right; anchors.rightMargin: 8; y: 185; width: 140; height: 40
45 var lday = lunarday_pathview.currentIndex+1;
46 var lmonth=lunarmonth_pathview.currentIndex+1;
47 var lyear=lunaryear_pathview.currentIndex+1900;
53 for (var l=0;l<12;l++)
54 if (lunarmonth_model.get(l).nhuan){
58 if(lunarmonth_model.get(lunarmonth_pathview.currentIndex).nhuan){
63 if (thangnhuan!=-1 && lunarmonth_pathview.currentIndex> thangnhuan)
66 var finalSolarDay = AmLich98.convertLunar2Solar(lday,lmonth,lyear,lnhuan,7)
68 LC.reset(finalSolarDay[0],finalSolarDay[1],finalSolarDay[2])
69 screen.calculateLunar( finalSolarDay[0], finalSolarDay[1], finalSolarDay[2])
70 screen.state="mainscreen"
74 txtDATEpv.currentIndex = finalSolarDay[0]-1;
86 anchors.rightMargin: 56
87 onClicked: {screen.state="mainscreen"}
108 border.color: "#b57e8f"
114 width: 198; height: 129
141 state: "switch_to_year"
144 width: 178; height: 129
147 property int index: 0
148 onIndexChanged: lunaryear_pathview.currentIndex = lunaryear_rec.index
151 id: lunaryear_delegate
158 width: lunaryear_rec.width
159 color: PathView.isCurrentItem ? "#FFFFFF" : "grey"
160 verticalAlignment:Text.AlignLeft
167 id:lunaryear_pathview
169 model: lunaryear_model
170 delegate: lunaryear_delegate
173 preferredHighlightBegin: 0.5
174 preferredHighlightEnd: 0.5
175 highlightRangeMode: PathView.StrictlyEnforceRange
180 PathLine {x: 90; y: lunaryear_rec.height}
184 //console.log(lunaryear_pathview.currentIndex)
185 AmLich.getYearInfo(lunaryear_pathview.currentIndex+1900);
186 lunarmonth_model.change(lunaryear_pathview.currentIndex+1900, lunarmonth_pathview.currentIndex+1);
190 id:lunaryear_mousearea
193 amdatetime.state="switch_to_year"
200 Component.onCompleted: {
205 for(var i=1900;i<2099;i++){
206 var lunarYear = AmLich.getYearCanChi(i)
207 append({name:i+" ("+lunarYear+")"})
211 function change(YYYY){
212 lunaryear_pathview.currentIndex = YYYY - 1900
219 state:"switch_to_day"
223 width: 80; height: 129
226 property int index: 0
227 onIndexChanged: lunarday_pathview.currentIndex = lunarday_rec.index
230 id: lunarday_delegate
238 width: lunarday_rec.width
239 color: PathView.isCurrentItem ? "#FFFFFF" : "grey"
240 verticalAlignment:Text.AlignVCenter
250 model: lunarday_model
251 delegate: lunarday_delegate
254 preferredHighlightBegin: 0.5
255 preferredHighlightEnd: 0.5
256 highlightRangeMode: PathView.StrictlyEnforceRange
261 PathLine {x: 90; y: lunarday_rec.height}
266 id:lunarday_mousearea
269 amdatetime.state="switch_to_day"
277 Component.onCompleted: {
278 for(var i=1;i<=30;i++)
282 function change(MM,DD){
284 while(lunarday_model.count>0){
285 lunarday_model.remove(lunarday_model.count-1)
289 var daystotal = AmLich.RMM[MM-1];
291 if(lunarmonth_model.get(MM-1).nhuan){
293 for (var i=1;i<=AmLich.LML;i++)
294 lunarday_model.append({name:i})
297 for (var i=1;i<=daystotal;i++)
298 lunarday_model.append({name:i})
302 /*if(lunarmonth_model.get(MM-1).nhuan){
303 if(AmLich.LML > lunarday_model.count){
304 for (var i=lunarday_model.count+1;i<=AmLich.LML;i++)
305 lunarday_model.append({name:i})
307 if(AmLich.LML< lunarday_model.count){
308 while(lunarday_model.count>AmLich.LML){
309 lunarday_model.remove(lunarday_model.count-1);
314 if(daystotal > lunarday_model.count){
315 for (var i=lunarday_model.count+1;i<=daystotal;i++)
316 lunarday_model.append({name:i})
318 if(daystotal < lunarday_model.count){
319 while(lunarday_model.count>daystotal){
320 lunarday_model.remove(lunarday_model.count-1);
326 var nhuansetru = 30 - AmLich.LML;
328 if(lunarmonth_model.get(MM-1).nhuan && lunarday_model.count==30){
331 lunarday_model.remove(lunarday_model.count-1);
335 else if(lunarday_model.count<30){
336 for (var i=lunarday_model.count+1;i<=30;i++)
337 lunarday_model.append({name:i})
340 lunarday_rec.index = DD-1;
341 lunarday_pathview.currentIndex= DD-1;
351 state:"switch_to_month"
355 width: 150; height: 129
358 property int index: 0
359 onIndexChanged: lunarmonth_pathview.currentIndex = lunarmonth_rec.index
362 id: lunarmonth_delegate
370 width: lunarmonth_rec.width
371 color: PathView.isCurrentItem ? "#FFFFFF" : "grey"
372 verticalAlignment:Text.AlignVCenter
380 id:lunarmonth_pathview
382 model: lunarmonth_model
383 delegate: lunarmonth_delegate
386 preferredHighlightBegin: 0.5
387 preferredHighlightEnd: 0.5
388 highlightRangeMode: PathView.StrictlyEnforceRange
393 PathLine {x: 90; y: lunarmonth_rec.height}
396 //console.log(lunaryear_pathview.currentIndex)
397 // console.log(AmLich.LML)
399 lunarday_model.change(lunarmonth_pathview.currentIndex+1,lunarday_pathview.currentIndex+1);
404 id:lunarmonth_mousearea
407 amdatetime.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=AmLich.leapMonth(yTest)
435 for(var i=0;i<=12;i++){
436 var l=AmLich.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_rec.index = MM -1;
451 lunarmonth_pathview.currentIndex = MM-1;
461 Component.onCompleted: {
467 name: "switch_to_day";
468 PropertyChanges { target:lmk;x:10;width:60;}
469 PropertyChanges { target:lunaryear_pathview;pathItemCount:1;}
470 PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;}
471 PropertyChanges { target:lunarday_pathview;pathItemCount:3;}
472 PropertyChanges { target:lunarday_mousearea;visible:false;}
473 PropertyChanges { target:lunaryear_mousearea;visible:true;}
474 PropertyChanges { target:lunarmonth_mousearea;visible:true;}
477 name: "switch_to_year";
478 PropertyChanges { target:lmk;x:207;width:198;}
479 PropertyChanges { target:lunarday_pathview;pathItemCount:1;}
480 PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;}
481 PropertyChanges { target:lunaryear_pathview;pathItemCount:3;}
482 PropertyChanges { target:lunarday_mousearea;visible:true;}
483 PropertyChanges { target:lunaryear_mousearea;visible:false;}
484 PropertyChanges { target:lunarmonth_mousearea;visible:true;}
487 name: "switch_to_month";
488 PropertyChanges { target:lmk;x:60;width:150;}
489 PropertyChanges { target:lunarday_pathview;pathItemCount:1;}
490 PropertyChanges { target:lunaryear_pathview;pathItemCount:1;}
491 PropertyChanges { target:lunarmonth_pathview;pathItemCount:3;}
492 PropertyChanges { target:lunarday_mousearea;visible:true;}
493 PropertyChanges { target:lunaryear_mousearea;visible:true;}
494 PropertyChanges { target:lunarmonth_mousearea;visible:false;}
499 var acs = AmLich.getYearInfo(screen.curYear)
500 var a=AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear)
501 var finalmonth=a.month;
505 var aaa=AmLich.leapMonth(screen.curYear)
509 for (var i=0;i<=12;i++){
511 if (t==l && a.leap===0){
513 finalmonth = finalmonth+1;
523 lunaryear_model.change(a.year)
524 lunarmonth_model.change(a.year, finalmonth)
525 lunarday_model.change(finalmonth,a.day)