X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=qml%2FLichViet%2FFullMonth.qml;fp=qml%2FLichViet%2FFullMonth.qml;h=4c3156830e695d7b6903ce4b78053169720468a8;hb=67ff5ae94ce65b3b1bb04a1eddcea356fd81a1aa;hp=331b3f788f6a540207db50327e5717eb17fb3b45;hpb=149fae2a60de58d911839daae8700ba3a6e2069a;p=lichviet diff --git a/qml/LichViet/FullMonth.qml b/qml/LichViet/FullMonth.qml index 331b3f7..4c31568 100644 --- a/qml/LichViet/FullMonth.qml +++ b/qml/LichViet/FullMonth.qml @@ -15,227 +15,372 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 -import "../DatePicker/component" as Comp +import QtQuick 1.1 -import "amlich-hnd.js" as AmLich -import "amlich-aa98.js" as AmLich98 - -import "CacNgayLeTrongNam.js" as CNLTN +import "Themes.js" as Themes +import "main.js" as Script Item{ - id: item1 + id: fullmonth - Rectangle{ - id: fullmonthREC - anchors.fill: parent; anchors.bottomMargin: 0 - opacity:0.9 + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height; + x:-(parent.width * 1.5) - Component { - id: contactDelegate - Item { - width: grid.cellWidth; height: { - if (header) - return grid.cellHeight - 15; - else return grid.cellHeight; - } - Rectangle { - anchors.fill: parent;anchors.rightMargin: 2;anchors.topMargin: 2; - Text { color: { - if (header) - return "#000000"; - else{ - var stemp = AmLich98.convertSolar2Lunar(txtDATEpv.currentIndex+1,curMonth,curYear,7); - if (CNLTN.is_holiday(day, month, stemp[0], stemp[1])) - return theme_manager.theme.markdate.holidays; - else - return "#007070" - } - } + signal toolbar + signal updatedate(int day, int month, int year) - text: name; anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 21;font.bold: true;font.family: "Tahoma" - anchors.topMargin: 0; - } + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } - color: { - if (header) - return "#FAFAFF"; - else{ - if (inmonth){ - if (day==initcurDay && month==initcurMonth && year==initcurYear) - return "#00EBEB"; - else - return "lightsteelblue"; - } - else - return "#AAAAAA"; - } - } - radius: 4 - MouseArea{ - id:fullmonthMouse - anchors.fill: parent - - onClicked: { - if (index >= 7){ - LC.reset(day,month,year) - screen.calculateLunar(day,month,year) - screen.state="mainscreen" - screen.refresh() - maindatemodel.reset() - txtDATEpv.currentIndex = day-1; - } - } -onPressed:{ - if (index >= 7) - parent.color="#F0F0F0" -} + Component.onCompleted: { + reset(); + } -onReleased:{ - if (index >= 7){ - if (inmonth){ - if (day==initcurDay && month==initcurMonth && year==initcurYear) - parent.color="#00EBEB"; - else - parent.color="lightsteelblue"; - }else - parent.color="#AAAAAA"; - } -} + property int m_day: Script.curDay + property int m_month: Script.curMonth + property int m_year: Script.curYear + + property Component headerRenderer:Component { + id: defaultHeaderRenderer + + Item { + width: cellWidth + height: cellHeight + + Rectangle { + width: parent.width - 4 + height: parent.height - 4 -onCanceled:{ - if (index >= 7){ - if (inmonth) - {if (day==initcurDay && month==initcurMonth && year==initcurYear) parent.color="#00EBEB"; else parent.color="lightsteelblue";} - else - parent.color="#AAAAAA"; + anchors.centerIn: parent + + radius: 4 + color: "#FAFAFF" + } + + Text { + width: cellWidth + height: cellHeight + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + + text: model.modelData + font.bold: true + font.pointSize: parent.width > parent.height ? width ? width / 6 : 1 : width / 4 + } + } } -} - } - } - } + property Component daysRenderer: + Component { + Item { + width: cellWidth + height: cellHeight + + Rectangle { + id:recms + width: parent.width - 4 + height: parent.height - 4 + + anchors.centerIn: parent + + radius: 4 + color: model ? model.inmonth ? (model.current ? "blue" : "lightsteelblue") : "#AAAAAA" : "black" } - GridView { - id: grid - x: -335 - y: 41 - width:800 - height: 480 - anchors.horizontalCenterOffset: 15 - anchors.bottomMargin: -52 - anchors.topMargin: 42 - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - anchors.top: parent.top - cellWidth: 110; cellHeight: 50 - //Dung : 64 | Nam :110 - model:lmodel - delegate: contactDelegate - focus: false + Text { + id:txt_solar_day + anchors.fill: parent + anchors.leftMargin: parent.width > parent.height ? 10 : 5 + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + + text: model ? model.day : "" + color: model ? model.inmonth ? (model.current ? "grey" : model.inholiday ? theme_manager.theme.markdate.holidays : "black") : "grey" : "red" + font.pointSize: parent.width > parent.height ? parent.width ? parent.width / 6 : 1 : parent.width / 4 + font.bold: true } - ListModel { - id:lmodel + Text { + anchors.fill: parent + anchors.leftMargin: txt_solar_day.anchors.leftMargin+ parent.width > parent.height ? 60 : 35 + anchors.topMargin: 20 - Component.onCompleted: { - reset() - } + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignBottom - function reset(){ - for(var i=0;i<42;i++){ - append({header:false,name:"",inmonths:false,day:0,month:0,year:0}) + text: model ? model.lunar_day : "" + color: model ? model.inmonth ? (model.current ? "white" : "#700070") : "grey" : "red" + font.pointSize: parent.width > parent.height ? parent.width ? parent.width / 8 : 1 : parent.width / 5 + } + + MouseArea { + id:memouse + anchors.fill: parent + + property real mX + property real mY + property bool hold: false + property bool clicked: false + + onClicked: { + if (model.inmonth){ + fullmonth.updatedate(model.day, m_month, m_year) + hold=false; + m_day = model.day; + fullmonth.state="close"; + fullmonth.toolbar(); + + }else{ + if (model.isprevmonth){ + m_month--; + if(m_month<=0){ + m_month=12; + m_year--; + } + }else{ + m_month++; + if (m_month >=13){ + m_month=1; + m_year++; + } + } + fullmonth.reset(); } } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "CN" + onPositionChanged: { + mX = mouseX; + mY = mouseY; + hold=true; + clicked=false; } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Hai" + onPressed: { + recms.color="#F0F0F0" + clicked=true; } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Ba" - } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Tư" - } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Năm" - } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Sáu" + onReleased: { + recms.color=model ? model.inmonth ? (model.current ? "blue" : "lightsteelblue") : "#AAAAAA" : "black"; + if (hold){ + if (mouseY+mY<0){ + if (Math.abs(mouseY) >= 100){ + m_month++; + if (m_month >=13){ + m_month=1; + m_year++; + } + reset(); + } + } + else + { + if (mouseY >= 100){ + m_month--; + if(m_month<=0){ + m_month=12; + m_year--; + } + reset(); + } + } + hold=false; + } } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Bảy" + } + } + } + + Rectangle{ + id: fullmonthREC + anchors.fill: parent; anchors.bottomMargin: 0 + opacity:0.9 + + ListModel { + id: monthModel + } + + Grid { + id: grid + + anchors.topMargin: 40 + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.top: parent.top + + columns: 7 + rows: 7 + + Repeater { + model: ["CN", "Hai", "Ba", "Tư", "Năm", "Sáu", "Bảy"] + + delegate: Item { + id: headerDelegate + + width: fullmonthREC.width / grid.columns + height: (fullmonthREC.height-92) / grid.rows + + property int theIndex: index + property variant theModel: model + + Loader { + property alias model: headerDelegate.theModel + property alias index: headerDelegate.theIndex + property alias cellWidth: headerDelegate.width + property alias cellHeight: headerDelegate.height + + anchors.fill: parent + + sourceComponent: headerRenderer + } } } - Component.onCompleted: { + Repeater { + model: monthModel + + delegate: Item { + id: daysDelegate + + property int theIndex: index + property variant theModel: model + + width: fullmonthREC.width / grid.columns + height: (fullmonthREC.height-92) / grid.rows + + Loader { + property alias model: daysDelegate.theModel + property alias index: daysDelegate.theIndex + property alias cellWidth: daysDelegate.width + property alias cellHeight: daysDelegate.height + + anchors.fill: parent + + sourceComponent: daysRenderer + } + + } } + + } + } - ToolBarSingle { id: toolBar; height: 50; - y: screen.height-78 + Rectangle { + width : fullmonth.width + height: 45 + color:"white" + opacity: 0.5 + } + + Text { + id: title + + anchors { horizontalCenter: fullmonth.horizontalCenter; top: fullmonth.top; topMargin: 10 } + font.pixelSize: 22 + color: "black" + text: "Tháng "+fullmonth.m_month+", "+fullmonth.m_year + smooth: true + font.bold: true + } + + ToolBarSingle { + id: toolBar; height: 42; + y: parent.height-52 width: parent.width; button1Label: "Quay Về" - onButton1Clicked: - { - screen.state="mainscreen" + onButton1Clicked:{ + fullmonth.state="close"; + fullmonth.toolbar(); } } - states: [ - State { - name: "xemtheothang" - PropertyChanges { - target: grid - width : screen.width - height: screen.height - cellWidth: { - if (screen.width>=800) - return 110; - else - return 64; + function reset() { + monthModel.clear() + + var firstdayofthemonthyear = Script.getLunarDate(1,m_month,m_year).jd; + var startfrom = (firstdayofthemonthyear+1)%7; + var daysofthemonthyear = Script.calDays(m_month,m_year); + var j=1; + var totalslot = 42; + + var nextmonth = get_nextmonth(totalslot - (startfrom+daysofthemonthyear)) + var prevmonth = get_prevmonth(startfrom) + + var dayclick, monthclick, yearclick; + var datas1,datas,lunarclmonth,inmonth,isprevmonth; + + for (var i=0;i<42;i++){ + if (i >= startfrom && j<= daysofthemonthyear){ + dayclick = j; + monthclick = m_month; + yearclick = m_year; + inmonth = true; + isprevmonth=false; + j++; + }else{ + if (idaysofthemonthyear-startfrom;i--){ - var lunarcl = AmLich.getLunarDate(i,cMonth,cYear) + var lunarcl = Script.getLunarDate(i,cMonth,cYear) pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear}) } return pmonth.reverse() } function get_nextmonth(startfrom){ - var cMonth=screen.curMonth; - var cYear=screen.curYear; + var cMonth=m_month; + var cYear=m_year; var pmonth = []; if (cMonth==12){ cMonth = 1; @@ -244,62 +389,25 @@ onCanceled:{ cMonth++; for (var i=1;i<=startfrom;i++){ - var lunarcl = AmLich.getLunarDate(i,cMonth,cYear) + var lunarcl = Script.getLunarDate(i,cMonth,cYear) pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear}); } return pmonth.reverse(); } - function reset(){ - var firstdayofthemonthyear = AmLich.getLunarDate(1,screen.curMonth,screen.curYear).jd; - var startfrom = (firstdayofthemonthyear+1)%7; - var daysofthemonthyear = LC.calDays(screen.curMonth,screen.curYear); - var j=1; - - var totalslot = 42; - - var nextmonth = get_nextmonth(totalslot - (startfrom+daysofthemonthyear)) - var prevmonth = get_prevmonth(startfrom) - - var dayclick, monthclick, yearclick; - - while(lmodel.count>7){ - lmodel.remove(lmodel.count-1); + states: [ + State { + name: "show" + AnchorChanges { target: fullmonth; anchors.right: parent.right } + }, + State { + name: "close" + AnchorChanges { target: fullmonth; anchors.right: parent.left } } + ] - var datas1,datas,lunarclmonth,inmonths; + transitions: Transition { + AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } + } - for (var i=7;i<49;i++){ - var realnumber = i - 7; - if (realnumber >= startfrom && j<= daysofthemonthyear){ - var lunarcl = AmLich.getLunarDate(j,screen.curMonth,screen.curYear) - if (lunarcl.day==1){ - lunarclmonth = "/"+lunarcl.month - }else{ - lunarclmonth = "" - } - - datas = j+"
  "+lunarcl.day+lunarclmonth+""; - dayclick = j; - monthclick = screen.curMonth; - yearclick = screen.curYear; - inmonths = true; - j++; - }else{ - if (realnumber
  "+datas1.am+""; - inmonths=false; - } - - lmodel.append({header:false,name:datas,inmonth:inmonths,day:dayclick,month:monthclick,year:yearclick}) - } - } }