f15f01c5b8dbfdc190df570f0b8a0252f11522b9
[lichviet] / qml / LichViet / XemNgayTotXauHoangDao.qml
1 /*
2 Copyright (C) 2011  by Cuong Le <metacuong@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>
16 */
17
18 import QtQuick 1.0
19
20 import "amlich-hnd.js" as AmLich
21 import "xemngaytotxau.js" as NTX
22
23 Item{
24     id:main_item
25
26     property string day_month_year_LN_CN:  ""
27     property string nhi_thap_bat_tu:  ""
28     property string truc:  ""
29     property string luan_giai:  ""
30     property string cac_sao_xau:  ""
31     property string cac_sao_tot:  ""
32     property string huong_xuat_hanh:  ""
33
34     property string warnning:  "<span style='color:red;'>Thông tin trên đây được lấy nguồn từ <a href='http://www.xemngay.com'>www.xemngay.com</a> và chỉ mang tính chất <b>tham khảo</b></span>."
35
36     Rectangle {
37         id: rectangle1
38         x: 0
39         y: -5
40         anchors.rightMargin: 0
41         anchors.leftMargin: 0
42         anchors.topMargin:30
43         anchors.fill: parent; anchors.bottomMargin: 16
44         visible: true
45         opacity:0.9
46
47         Component {
48             id: listDelegate
49
50                 Column {
51
52                     Rectangle {
53                                         width:rectangle1.width;
54                                         y:30;
55                                         x:0
56                                         height:1
57                                         border.color: "#b57e8f"
58                     }
59
60                     width:rectangle1.width
61
62                     Rectangle{
63                         width:rectangle1.width;
64                         height:10;color:"transparent"
65                     }
66
67                     Text { x:5;y:50;text:getHD(name,idm) ;textFormat: Text.RichText;wrapMode: Text.WordWrap; font.pixelSize: 20
68                         font.family: "Tahoma";width:parent.width;}
69
70                     Rectangle{
71                         width:rectangle1.width;
72                         height:10;color:"transparent"
73                     }
74                 }
75
76
77         }
78
79         ListModel {
80                  id: listModel
81
82                  ListElement {
83                      idm:0;name: "";
84                  }
85                  ListElement {
86                      idm:-1;name: "";
87                  }
88                  ListElement {
89                      idm:1;name: "<b>Giờ Hoàng Đạo</b>";
90                  }
91                  ListElement {
92                      idm:2;name: "<b>Tiết Khí</b>";
93                  }
94                 ListElement {
95                      idm:3;name: "<b>Nhị Thập Bát Tú</b>";
96                  }
97                 ListElement {
98                      idm:-2;name: "<b>Hướng Xuất Hành</b>";
99                  }
100                 ListElement {
101                      idm:6;name: "<b>Các Sao Tốt</b>";
102                  }
103                ListElement {
104                      idm:7;name: "<b>Các Sao Xấu</b>";
105                  }
106                ListElement {
107                    idm:8;name: "";
108                }
109
110                /* ListElement {
111                      idm:5;name: "<b>Đánh Giá</b>";
112                  }*/
113          }
114
115
116
117         ListView {
118               id: listView
119               anchors.fill: parent;anchors.topMargin: 0;anchors.leftMargin: 0; anchors.bottomMargin: 16
120               model: listModel
121               delegate: listDelegate
122               focus: true
123         }
124
125     }
126
127     ToolBarSingle { id: toolBar; height: 50;
128         y: screen.height-78
129         width: parent.width;
130         button1Label: "Quay Về"
131         onButton1Clicked:
132         {
133             screen.state="mainscreen"
134         }
135     }
136
137     function getHD(name,idm){
138         if (name.length){
139             name="<span style='color:blue;'>"+name+"</span><br>";
140         }
141
142         switch(idm){
143         case 0 : return name+ main_item.day_month_year_LN_CN;break;
144         case 1 : return name+screen.lunarGioHoangDao;break;
145         case 2 : return name+screen.lunarTietKhi();break;
146         case 3 : return name+main_item.nhi_thap_bat_tu; break;
147         case 5 :  return name+main_item.luan_giai;break;
148         case -1: return name+main_item.truc;break;
149         case 6: return name+main_item.cac_sao_tot;break;
150         case 7: return name+main_item.cac_sao_xau;break;
151         case -2: return name+main_item.huong_xuat_hanh;break;
152         case 8: return main_item.warnning;break;
153         }
154     }
155
156     function reset(){
157         main_item.day_month_year_LN_CN = AmLich.getTHU(screen.jd)+",ngày <b>"+screen.curDay+"</b> tháng <b>"+screen.curMonth+"</b> năm <b>"+screen.curYear+"</b><br>Ngày <b>"+screen.lunarDay+"</b> tháng <b>"+screen.lunarMonth+"</b> năm <b>"+screen.lunarYear+"</b> (<b>"+screen.lunarYearInt+"</b>)";
158         main_item.nhi_thap_bat_tu = NTX.sao(screen.curYear,AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).jd - AmLich.getLunarDate(1,1,screen.curYear).jd);
159         main_item.truc = NTX.truc(screen.lunarMonth, screen.lunarDayCanChi, screen.lunarMonthCanChi);
160         main_item.cac_sao_tot = NTX.cacsaotot(screen.lunarMonth, screen.lunarDayCanChi);
161         main_item.cac_sao_xau = NTX.cacsaoxau(screen.lunarMonth, screen.lunarDayCanChi);
162         main_item.luan_giai = NTX.luangiai(screen.curDay);
163         main_item.huong_xuat_hanh = NTX.huong_xuat_hanh(screen.lunarDayCanChi);
164     }
165
166     transitions: [
167         Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutBack } }
168     ]
169 }