X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=qml%2FLichViet%2FAmDateTimeDialog.qml;fp=qml%2FLichViet%2FAmDateTimeDialog.qml;h=9c9d13305e0fa3a652244508077a5532b086a0e8;hb=67ff5ae94ce65b3b1bb04a1eddcea356fd81a1aa;hp=63890b764df7547f1c667b62a8a3d3dc2f713d4b;hpb=149fae2a60de58d911839daae8700ba3a6e2069a;p=lichviet diff --git a/qml/LichViet/AmDateTimeDialog.qml b/qml/LichViet/AmDateTimeDialog.qml index 63890b7..9c9d133 100644 --- a/qml/LichViet/AmDateTimeDialog.qml +++ b/qml/LichViet/AmDateTimeDialog.qml @@ -15,14 +15,28 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 -import "amlich-hnd.js" as AmLich -import "amlich-aa98.js" as AmLich98 +import QtQuick 1.1 + +import "Themes.js" as Themes +import "main.js" as Script Item{ id: amdatetime state: "switch_me" - + + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height; + x:(parent.width * 1.5) + + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } + + signal toolbar + signal updatedate(int day, int month, int year) + Rectangle { id: rectangle1 x: 0 @@ -35,47 +49,44 @@ Item{ border.color: "#b57e8f" visible: true opacity:0.9 - + Button { id: button2 - x: 313 - anchors.right: parent.right; anchors.rightMargin: 8; y: 185; width: 140; height: 40 + anchors.right: parent.right; anchors.rightMargin: 145; y: 185; width: 100; height: 40 + anchors.horizontalCenter: parent.horizontalCenter + text: "OK" onClicked: { - var lday = lunarday_pathview.currentIndex+1; - var lmonth=lunarmonth_pathview.currentIndex+1; - var lyear=lunaryear_pathview.currentIndex+1900; - + var lday = lunarday_pathview.currentIndex+1; + var lmonth=lunarmonth_pathview.currentIndex+1; + var lyear=lunaryear_pathview.currentIndex+1900; + var lnhuan=0; - + var thangnhuan = -1; - + for (var l=0;l<12;l++) - if (lunarmonth_model.get(l).nhuan){ - thangnhuan = l; + if (lunarmonth_model.get(l).nhuan){ + thangnhuan = l; } - - if(lunarmonth_model.get(lunarmonth_pathview.currentIndex).nhuan){ - lnhuan=1; - lmonth=lmonth-1; - } - - if (thangnhuan!=-1 && lunarmonth_pathview.currentIndex> thangnhuan) - lmonth-=1; - - var finalSolarDay = AmLich98.convertLunar2Solar(lday,lmonth,lyear,lnhuan,7) - - LC.reset(finalSolarDay[0],finalSolarDay[1],finalSolarDay[2]) - screen.calculateLunar( finalSolarDay[0], finalSolarDay[1], finalSolarDay[2]) - screen.state="mainscreen" - screen.refresh() - - maindatemodel.reset() - txtDATEpv.currentIndex = finalSolarDay[0]-1; - + + if(lunarmonth_model.get(lunarmonth_pathview.currentIndex).nhuan){ + lnhuan=1; + lmonth=lmonth-1; + } + + if (thangnhuan!=-1 && lunarmonth_pathview.currentIndex> thangnhuan) + lmonth-=1; + + var finalSolarDay = Script.convertLunar2Solar(lday,lmonth,lyear,lnhuan,7); + + amdatetime.state="close"; + amdatetime.toolbar(); + amdatetime.updatedate(finalSolarDay[0], finalSolarDay[1], finalSolarDay[2]) + + } } - } - + Button { id: button3 x: 413 @@ -84,11 +95,14 @@ Item{ height: 40 text: "X" anchors.rightMargin: 56 - onClicked: {screen.state="mainscreen"} - } - + onClicked: { + amdatetime.state="close" + amdatetime.toolbar() + } + } + Rectangle { - id: rectangle2 + id: rec22 x: 23 y: 89 width: 415 @@ -98,15 +112,15 @@ Item{ GradientStop { position: 0 color: "#ffffff" - } - + } + GradientStop { position: 0.1 color: "#7c6969" + } } - } border.color: "#b57e8f" - + Rectangle { id:lmk x: 207 @@ -116,25 +130,57 @@ Item{ GradientStop { position: 0.89 color: "#148ebe" - } - + } + GradientStop { position: 0.01 color: "#19262b" - } - + } + GradientStop { position: 0.13 color: "#6eb3d5" - } - + } + GradientStop { position: 1 color: "#19262b" + } } } - } - + + states: [ + State { + name: "switch_to_day"; + PropertyChanges { target:lmk;x:10;width:60;} + PropertyChanges { target:lunaryear_pathview;pathItemCount:1;} + PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;} + PropertyChanges { target:lunarday_pathview;pathItemCount:3;} + PropertyChanges { target:lunarday_mousearea;visible:false;} + PropertyChanges { target:lunaryear_mousearea;visible:true;} + PropertyChanges { target:lunarmonth_mousearea;visible:true;} + }, + State { + name: "switch_to_year"; + PropertyChanges { target:lmk;x:207;width:198;} + PropertyChanges { target:lunarday_pathview;pathItemCount:1;} + PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;} + PropertyChanges { target:lunaryear_pathview;pathItemCount:3;} + PropertyChanges { target:lunarday_mousearea;visible:true;} + PropertyChanges { target:lunaryear_mousearea;visible:false;} + PropertyChanges { target:lunarmonth_mousearea;visible:true;} + }, + State { + name: "switch_to_month"; + PropertyChanges { target:lmk;x:60;width:150;} + PropertyChanges { target:lunarday_pathview;pathItemCount:1;} + PropertyChanges { target:lunaryear_pathview;pathItemCount:1;} + PropertyChanges { target:lunarmonth_pathview;pathItemCount:3;} + PropertyChanges { target:lunarday_mousearea;visible:true;} + PropertyChanges { target:lunaryear_mousearea;visible:true;} + PropertyChanges { target:lunarmonth_mousearea;visible:false;} + }] + /**LUNAR YEAR**/ Rectangle { id:lunaryear_rec @@ -143,10 +189,10 @@ Item{ y: -39 width: 178; height: 129 color:"transparent" - + property int index: 0 onIndexChanged: lunaryear_pathview.currentIndex = lunaryear_rec.index - + Component { id: lunaryear_delegate Column { @@ -168,361 +214,299 @@ Item{ anchors.fill: parent model: lunaryear_model delegate: lunaryear_delegate - pathItemCount: 3 - clip: true - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlightRangeMode: PathView.StrictlyEnforceRange - focus: true - path: Path { - startX: 90 - startY: 0 - PathLine {x: 90; y: lunaryear_rec.height} - } - - onMovementEnded: { - //console.log(lunaryear_pathview.currentIndex) - AmLich.getYearInfo(lunaryear_pathview.currentIndex+1900); - lunarmonth_model.change(lunaryear_pathview.currentIndex+1900, lunarmonth_pathview.currentIndex+1); - } - } + pathItemCount: 3 + clip: true + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlightRangeMode: PathView.StrictlyEnforceRange + focus: true + path: Path { + startX: 90 + startY: 0 + PathLine {x: 90; y: lunaryear_rec.height} + } + + onMovementEnded: { + Script.getYearInfo(lunaryear_pathview.currentIndex+1900); + lunarmonth_model.change(lunaryear_pathview.currentIndex+1900, lunarmonth_pathview.currentIndex+1); + } + } MouseArea { id:lunaryear_mousearea anchors.fill: parent onClicked: { - amdatetime.state="switch_to_year" + rec22.state="switch_to_year" + } } } - } - + ListModel { id:lunaryear_model - Component.onCompleted: { - init() - } function init(){ for(var i=1900;i<2099;i++){ - var lunarYear = AmLich.getYearCanChi(i) + var lunarYear = Script.getYearCanChi(i) append({name:i+" ("+lunarYear+")"}) + } } - } - + function change(YYYY){ + lunaryear_pathview.currentIndex=-1; lunaryear_pathview.currentIndex = YYYY - 1900 + } } - } /***/ - + /**LUNAR DAY*/ - Rectangle{ - state:"switch_to_day" - id:lunarday_rec - x: -20 - y: -39 - width: 80; height: 129 - color:"transparent" - - property int index: 0 - onIndexChanged: lunarday_pathview.currentIndex = lunarday_rec.index - - Component { - id: lunarday_delegate - Column { - id: wrapper - - Text { - id: nameText - text: name - font.pointSize: 18 - width: lunarday_rec.width - color: PathView.isCurrentItem ? "#FFFFFF" : "grey" - verticalAlignment:Text.AlignVCenter - font.bold: true + Rectangle{ + state:"switch_to_day" + id:lunarday_rec + x: -20 + y: -39 + width: 80; height: 129 + color:"transparent" + + property int index: 0 + onIndexChanged: lunarday_pathview.currentIndex = lunarday_rec.index + + Component { + id: lunarday_delegate + Column { + id: wrapper + + Text { + id: nameText + text: name + font.pointSize: 18 + width: lunarday_rec.width + color: PathView.isCurrentItem ? "#FFFFFF" : "grey" + verticalAlignment:Text.AlignVCenter + font.bold: true } - + } } - - PathView { - id:lunarday_pathview - anchors.fill: parent - model: lunarday_model - delegate: lunarday_delegate - pathItemCount: 1 - clip: true - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlightRangeMode: PathView.StrictlyEnforceRange - focus: true - path: Path { - startX: 90 - startY: 0 - PathLine {x: 90; y: lunarday_rec.height} - } + + PathView { + id:lunarday_pathview + anchors.fill: parent + model: lunarday_model + delegate: lunarday_delegate + pathItemCount: 1 + clip: true + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlightRangeMode: PathView.StrictlyEnforceRange + focus: true + path: Path { + startX: 90 + startY: 0 + PathLine {x: 90; y: lunarday_rec.height} + } } - - MouseArea { - id:lunarday_mousearea - anchors.fill: parent - onClicked: { - amdatetime.state="switch_to_day" + + MouseArea { + id:lunarday_mousearea + anchors.fill: parent + onClicked: { + rec22.state="switch_to_day" } } - + } + + ListModel { + id:lunarday_model - ListModel { - id:lunarday_model - Component.onCompleted: { - for(var i=1;i<=30;i++) - append({name:i}) + function init(){ + for(var i=1;i<=30;i++) + lunarday_model.append({name:i}) } - - function change(MM,DD){ - - while(lunarday_model.count>0){ - lunarday_model.remove(lunarday_model.count-1) + + function change(MM,DD){ + + while(lunarday_model.count>0){ + lunarday_model.remove(lunarday_model.count-1) } - - - var daystotal = AmLich.RMM[MM-1]; - - if(lunarmonth_model.get(MM-1).nhuan){ - - for (var i=1;i<=AmLich.LML;i++) - lunarday_model.append({name:i}) - - }else{ - for (var i=1;i<=daystotal;i++) - lunarday_model.append({name:i}) - + + + var daystotal = Script.RMM[MM-1]; + + if(lunarmonth_model.get(MM-1).nhuan){ + for (var i=1;i<=Script.LML;i++) + lunarday_model.append({name:i}) + }else{ + for (var i=1;i<=daystotal;i++) + lunarday_model.append({name:i}) } - /*if(lunarmonth_model.get(MM-1).nhuan){ - if(AmLich.LML > lunarday_model.count){ - for (var i=lunarday_model.count+1;i<=AmLich.LML;i++) - lunarday_model.append({name:i}) - }else - if(AmLich.LML< lunarday_model.count){ - while(lunarday_model.count>AmLich.LML){ - lunarday_model.remove(lunarday_model.count-1); - } - } - - }else{ - if(daystotal > lunarday_model.count){ - for (var i=lunarday_model.count+1;i<=daystotal;i++) - lunarday_model.append({name:i}) - }else - if(daystotal < lunarday_model.count){ - while(lunarday_model.count>daystotal){ - lunarday_model.remove(lunarday_model.count-1); - } - } - }*/ - - /* - var nhuansetru = 30 - AmLich.LML; - - if(lunarmonth_model.get(MM-1).nhuan && lunarday_model.count==30){ - var j=0; - while(j0){ - lunarmonth_model.remove(lunarmonth_model.count-1) - } - readd(YYYY, MM) - - lunarday_model.change(lunarmonth_pathview.currentIndex+1,lunarday_pathview.currentIndex+1); + } + + } + + ListModel { + id:lunarmonth_model + + Component.onCompleted: { + + } + + function change(YYYY, MM){ + while(lunarmonth_model.count>0){ + lunarmonth_model.remove(lunarmonth_model.count-1) } + readd(YYYY, MM) + + lunarday_model.change(lunarmonth_pathview.currentIndex+1,lunarday_pathview.currentIndex+1); + } - function readd(YYYY, MM){ - var yTest = YYYY; - var preFix = "Tháng "; - var a=AmLich.leapMonth(yTest) - var t=0; - if(a){ // nam nhuan - for(var i=0;i<=12;i++){ - var l=AmLich.getYearInfo(yTest)[i].month - if (t==l) - lunarmonth_model.append({name:preFix+l+" (N)", nhuan:true}) - else - lunarmonth_model.append({name:preFix+l, nhuan:false}) - t=l - } - - }else - { - for(var i=1;i<=12;i++) - lunarmonth_model.append({name:preFix+i, nhuan:false}) + function readd(YYYY, MM){ + var yTest = YYYY; + var preFix = "Tháng "; + var a=Script.leapMonth(yTest) + var t=0; + if(a){ // nam nhuan + for(var i=0;i<=12;i++){ + var l=Script.getYearInfo(yTest)[i].month + if (t==l) + lunarmonth_model.append({name:preFix+l+" (N)", nhuan:true}) + else + lunarmonth_model.append({name:preFix+l, nhuan:false}) + t=l } - - lunarmonth_rec.index = MM -1; - lunarmonth_pathview.currentIndex = MM-1; - + + }else + { + for(var i=1;i<=12;i++) + lunarmonth_model.append({name:preFix+i, nhuan:false}) } + + lunarmonth_pathview.currentIndex=-1; + lunarmonth_pathview.currentIndex = MM-1; + } - - /***/ + } + + /***/ + } + } - - } - + Component.onCompleted: { - - } - + reset(); + } + states: [ State { - name: "switch_to_day"; - PropertyChanges { target:lmk;x:10;width:60;} - PropertyChanges { target:lunaryear_pathview;pathItemCount:1;} - PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;} - PropertyChanges { target:lunarday_pathview;pathItemCount:3;} - PropertyChanges { target:lunarday_mousearea;visible:false;} - PropertyChanges { target:lunaryear_mousearea;visible:true;} - PropertyChanges { target:lunarmonth_mousearea;visible:true;} - }, - State { - name: "switch_to_year"; - PropertyChanges { target:lmk;x:207;width:198;} - PropertyChanges { target:lunarday_pathview;pathItemCount:1;} - PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;} - PropertyChanges { target:lunaryear_pathview;pathItemCount:3;} - PropertyChanges { target:lunarday_mousearea;visible:true;} - PropertyChanges { target:lunaryear_mousearea;visible:false;} - PropertyChanges { target:lunarmonth_mousearea;visible:true;} - }, + name: "show" + AnchorChanges { target: amdatetime; anchors.right: parent.right } + }, State { - name: "switch_to_month"; - PropertyChanges { target:lmk;x:60;width:150;} - PropertyChanges { target:lunarday_pathview;pathItemCount:1;} - PropertyChanges { target:lunaryear_pathview;pathItemCount:1;} - PropertyChanges { target:lunarmonth_pathview;pathItemCount:3;} - PropertyChanges { target:lunarday_mousearea;visible:true;} - PropertyChanges { target:lunaryear_mousearea;visible:true;} - PropertyChanges { target:lunarmonth_mousearea;visible:false;} - } - ] - + name: "close" + AnchorChanges { target: amdatetime; anchors.right: parent.left } + } + ] + function reset(){ - var acs = AmLich.getYearInfo(screen.curYear) - var a=AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear) - var finalmonth=a.month; + var acs = Script.getYearInfo(Script.curYear) + var a=Script.getLunarDate(Script.curDay,Script.curMonth,Script.curYear) + var finalmonth=a.month; if (a.leap) - finalmonth+=1; + finalmonth+=1; else{ - var aaa=AmLich.leapMonth(screen.curYear) - var t=-1; - - if (aaa){ - for (var i=0;i<=12;i++){ - var l=acs[i].month - if (t==l && a.leap===0){ - if (a.month>i){ - finalmonth = finalmonth+1; - break; + var aaa=Script.leapMonth(Script.curYear) + var t=-1; + + if (aaa){ + for (var i=0;i<=12;i++){ + var l=acs[i].month + if (t==l && a.leap===0){ + if (a.month>i){ + finalmonth = finalmonth+1; + break; + } + } + t=l } + } - t=l } - - } - } - + + lunaryear_model.init() + lunarday_model.init() lunaryear_model.change(a.year) lunarmonth_model.change(a.year, finalmonth) lunarday_model.change(finalmonth,a.day) - + + } + + transitions: Transition { + AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } + } } -}