along with this program. If not, see <http://www.gnu.org/licenses/>
*/
-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: fullmonth
- property int m_day: screen.curDay
- property int m_month: screen.curMonth
- property int m_year: screen.curYear
+ anchors.verticalCenter: parent.verticalCenter
+ width: parent.width; height: parent.height;
+ x:-(parent.width * 1.5)
+
+ signal toolbar
+ signal updatedate(int day, int month, int year)
+
+ Loader {
+ id: theme_manager
+ property alias theme: theme_manager.item
+ source: Themes.default_theme()
+ }
+
+
+ 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
text: model.modelData
font.bold: true
- font.pointSize: width ? width / 6 : 1
+ font.pointSize: parent.width > parent.height ? width ? width / 6 : 1 : width / 4
}
}
}
Text {
id:txt_solar_day
anchors.fill: parent
- anchors.leftMargin: 10
+ anchors.leftMargin: parent.width > parent.height ? 10 : 5
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
+ 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
}
Text {
anchors.fill: parent
- anchors.leftMargin: txt_solar_day.anchors.leftMargin+40
+ anchors.leftMargin: txt_solar_day.anchors.leftMargin+ parent.width > parent.height ? 60 : 35
anchors.topMargin: 20
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignBottom
text: model ? model.lunar_day : ""
- color: model ? model.inmonth ? (model.current ? "red" : "#700070") : "grey" : "red"
- font.pointSize: parent.width ? parent.width / 8 : 1
+ 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: {
- LC.reset(model.day,m_month,m_year)
- screen.calculateLunar(model.day,m_month,m_year)
- screen.state="mainscreen"
- screen.refresh()
- maindatemodel.reset()
- txtDATEpv.currentIndex = model.day-1;
+ 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();
+ }
}
onPositionChanged: {
mX = mouseX;
mY = mouseY;
hold=true;
+ clicked=false;
}
onPressed: {
recms.color="#F0F0F0"
+ clicked=true;
}
onReleased: {
+ recms.color=model ? model.inmonth ? (model.current ? "blue" : "lightsteelblue") : "#AAAAAA" : "black";
if (hold){
if (mouseY+mY<0){
- if (Math.abs(mouseY) >= 30){
- m_month+=1;
+ if (Math.abs(mouseY) >= 100){
+ m_month++;
if (m_month >=13){
m_month=1;
m_year++;
}
+ reset();
}
}
else
{
- if (mouseY >= 50){
- m_month-=1;
+ if (mouseY >= 100){
+ m_month--;
if(m_month<=0){
m_month=12;
m_year--;
}
+ reset();
}
}
- reset();
hold=false;
}
}
Grid {
id: grid
- anchors.bottomMargin: -52
- anchors.topMargin: 78
+ anchors.topMargin: 40
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.top: parent.top
}
- Text {
- id: txt_caption
- y: 40
- width:parent.width
- text: "Tháng "+m_month+", "+m_year
- horizontalAlignment: Text.AlignHCenter
- font.pixelSize: 24
- font.bold: true
- }
+ }
+
+ 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: 50;
- y: screen.height-78
+ 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();
}
}
function reset() {
monthModel.clear()
- var firstdayofthemonthyear = AmLich.getLunarDate(1,m_month,m_year).jd;
+ var firstdayofthemonthyear = Script.getLunarDate(1,m_month,m_year).jd;
var startfrom = (firstdayofthemonthyear+1)%7;
- var daysofthemonthyear = LC.calDays(m_month,m_year);
+ var daysofthemonthyear = Script.calDays(m_month,m_year);
var j=1;
var totalslot = 42;
var prevmonth = get_prevmonth(startfrom)
var dayclick, monthclick, yearclick;
- var datas1,datas,lunarclmonth,inmonth;
+ var datas1,datas,lunarclmonth,inmonth,isprevmonth;
for (var i=0;i<42;i++){
if (i >= startfrom && j<= daysofthemonthyear){
monthclick = m_month;
yearclick = m_year;
inmonth = true;
+ isprevmonth=false;
j++;
}else{
- if (i<startfrom)
+ if (i<startfrom){
datas1=prevmonth[i];
- else
+ isprevmonth = true;
+ }
+ else{
datas1=nextmonth[(totalslot-i)-1];
+ isprevmonth = false;
+ }
dayclick = datas1.duong;
monthclick = datas1.month;
}
var current = false;
- if (dayclick == screen.curDay && monthclick==screen.curMonth && yearclick==screen.curYear)
+ if (dayclick == Script.curDay && monthclick==Script.curMonth && yearclick==Script.curYear)
current = true
- var lunarcl = AmLich.getLunarDate(dayclick,monthclick,yearclick)
+ var lunarcl = Script.getLunarDate(dayclick,monthclick,yearclick)
var lunar_day = lunarcl.day;
if (lunarcl.day === 1)
lunar_day = lunarcl.day+"/"+lunarcl.month;
- var stemp = AmLich98.convertSolar2Lunar(dayclick,monthclick,yearclick,7);
- var inholiday = CNLTN.is_holiday(dayclick, monthclick, stemp[0], stemp[1]);
+ 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})
+ monthModel.append({"day": dayclick, "current": current, "lunar_day":lunar_day, "inmonth":inmonth,"inholiday":inholiday,"isprevmonth":isprevmonth})
}
}
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()
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();
}
+ states: [
+ State {
+ name: "show"
+ AnchorChanges { target: fullmonth; anchors.right: parent.right }
+ },
+ State {
+ name: "close"
+ AnchorChanges { target: fullmonth; anchors.right: parent.left }
+ }
+ ]
+
+ transitions: Transition {
+ AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
+ }
+
}