X-Git-Url: http://git.maemo.org/git/?p=lichviet;a=blobdiff_plain;f=qml%2FLichViet%2FFullMonth.qml;h=a2be992d2beafe531732360a9f5e4632b98100ee;hp=62576640941431a3646d43b5fdd769fc57e233d2;hb=274c1daf9c51c4127195b5e8370722887dace99e;hpb=192d61be4c51bf49aabcb99f19e7ce783a0bcf3c diff --git a/qml/LichViet/FullMonth.qml b/qml/LichViet/FullMonth.qml index 6257664..a2be992 100644 --- a/qml/LichViet/FullMonth.qml +++ b/qml/LichViet/FullMonth.qml @@ -16,237 +16,345 @@ along with this program. If not, see */ import QtQuick 1.0 -import "../DatePicker/component" as Comp -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: 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 "#000000"//"#007070" - } - } - - text: name; anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 21;font.bold: true;font.family: "Tahoma" - anchors.topMargin: 0; - } + signal toolbar + signal updatedate(int day, int month, int year) - 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; - } - } + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } -onPressed:{ - if (index >= 7) - parent.color="#F0F0F0" -} -onReleased:{ - if (index >= 7){ - if (inmonth){ - if (day==initcurDay && month==initcurMonth && year==initcurYear) - parent.color="#00EBEB"; - else - parent.color="lightsteelblue"; - }else - parent.color="#AAAAAA"; - } -} + Component.onCompleted: { + reset(); + } + + 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 + + anchors.centerIn: parent -onCanceled:{ - if (index >= 7){ - if (inmonth) - {if (day==initcurDay && month==initcurMonth && year==initcurYear) parent.color="#00EBEB"; else parent.color="lightsteelblue";} - else - parent.color="#AAAAAA"; + radius: 4 + color: "#FAFAFF" + } + + Text { + width: cellWidth + height: cellHeight + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + + text: model.modelData + font.bold: true + font.pointSize: width ? width / 6 : 1 + } + } } -} - } - } - } + 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 - - 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 - - boundsBehavior:Flickable.DragAndOvershootBounds - flickableDirection:Flickable.VerticalFlick - - model:lmodel - delegate: contactDelegate - focus: true - - onMovementStarted:{ - /* var newMonth = screen.curMonth+1; - LC.reset(screen.curDay,newMonth,screen.curYear) - screen.calculateLunar(screen.curDay,newMonth,screen.curYear) - screen.refresh() - reset()*/ - } + Text { + id:txt_solar_day + anchors.fill: parent + anchors.leftMargin: 10 + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + text: model ? model.day : "" + color: model ? model.inmonth ? (model.current ? "red" : model.inholiday ? theme_manager.theme.markdate.holidays : "black") : "grey" : "red" + font.pointSize: parent.width ? parent.width / 6 : 1 + font.bold: true } - ListModel { - id:lmodel + Text { + anchors.fill: parent + anchors.leftMargin: txt_solar_day.anchors.leftMargin+40 + 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 ? "red" : "#700070") : "grey" : "red" + font.pointSize: parent.width ? parent.width / 8 : 1 + } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "CN" - } + MouseArea { + anchors.fill: parent - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Hai" - } + property real mX + property real mY + property bool hold: false - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Ba" + onClicked: { + /*LC.reset(model.day,m_month,m_year) + screen.calculateLunar(model.day,m_month,m_year) + screen.state="mainscreen" + screen.refresh() + maindatemodel.reset()*/ + fullmonth.state="close"; + fullmonth.toolbar(); + fullmonth.updatedate(model.day, m_month, m_year) } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Tư" + + onPositionChanged: { + mX = mouseX; + mY = mouseY; + hold=true; } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Năm" + + onPressed: { + recms.color="#F0F0F0" } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Sáu" + + onReleased: { + if (hold){ + if (mouseY+mY<0){ + if (Math.abs(mouseY) >= 30){ + m_month+=1; + if (m_month >=13){ + m_month=1; + m_year++; + } + } + } + else + { + if (mouseY >= 50){ + m_month-=1; + 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; + + for (var i=0;i<42;i++){ + if (i >= startfrom && j<= daysofthemonthyear){ + dayclick = j; + monthclick = m_month; + yearclick = m_year; + inmonth = true; + 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; @@ -255,62 +363,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; - - 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}) - } + transitions: Transition { + AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } } + }