This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
+the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
*/
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: item1
+ id: fullmonth
- Rectangle{
- id: fullmonthREC
- anchors.fill: parent; anchors.bottomMargin: 0
- visible: true
- 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"
- }
- }
-
- 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
-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: 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
- 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: 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
+
+ property real mX
+ property real mY
+ property bool hold: false
+
+ 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: "Hai"
+ onPositionChanged: {
+ mX = mouseX;
+ mY = mouseY;
+ hold=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ư"
+ onPressed: {
+ recms.color="#F0F0F0"
}
- 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: {
+ 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();
}
}
- transitions: [
- Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutBack } }
- ]
+ function reset() {
+ monthModel.clear()
- states: [
- State {
- name: "xemtheothang"
- PropertyChanges {
- target: grid
- width : screen.width
- height: screen.height
- cellWidth: {
- if (screen.width>=800)
- return 110;
- else
- return 64;
- }
+ 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 (i<startfrom)
+ datas1=prevmonth[i];
+ else
+ datas1=nextmonth[(totalslot-i)-1];
+
+ dayclick = datas1.duong;
+ monthclick = datas1.month;
+ yearclick = datas1.year;
+ inmonth = false;
}
+
+ var current = false;
+ if (dayclick == Script.curDay && monthclick==Script.curMonth && yearclick==Script.curYear)
+ current = true
+
+ var lunarcl = Script.getLunarDate(dayclick,monthclick,yearclick)
+ var lunar_day = lunarcl.day;
+
+ if (lunarcl.day === 1)
+ lunar_day = lunarcl.day+"/"+lunarcl.month;
+
+ var stemp = Script.convertSolar2Lunar(dayclick,monthclick,yearclick,7);
+ var inholiday = Script.is_holiday(dayclick, monthclick, stemp[0], stemp[1]);
+
+ monthModel.append({"day": dayclick, "current": current, "lunar_day":lunar_day, "inmonth":inmonth,"inholiday":inholiday})
}
- ]
+
+ }
function get_prevmonth(startfrom){
- var cMonth=screen.curMonth;
- var cYear=screen.curYear;
+ var cMonth=m_month;
+ var cYear=m_year;
var pmonth = [];
if (cMonth == 1){
cMonth = 12
cYear--;
}else
cMonth--;
- var daysofthemonthyear = LC.calDays(cMonth,cYear);
+ var daysofthemonthyear = Script.calDays(cMonth,cYear);
for (var i=daysofthemonthyear;i>daysofthemonthyear-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;
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+"<br><span style='font-size:18px;float:right;color:#700070;'> "+lunarcl.day+lunarclmonth+"</span>";
- dayclick = j;
- monthclick = screen.curMonth;
- yearclick = screen.curYear;
- inmonths = true;
- j++;
- }else{
- if (realnumber<startfrom){
- datas1= prevmonth[realnumber];
- }else
- {
- datas1=nextmonth[(totalslot-realnumber)-1];
- }
- dayclick = datas1.duong;
- monthclick = datas1.month;
- yearclick = datas1.year;
- datas = "<span style='color:grey;font-weight:normal;'>"+datas1.duong+"</span><br><span style='font-size:18px;float:right;color:#CCFFFF;'> "+datas1.am+"</span>";
- 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 }
}
+
}