718efcf428354b8c367a15946baedfd17e510df4
[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
48         Component {
49             id: listDelegate
50
51                 Column {
52
53                     Rectangle {
54                                         width:rectangle1.width;
55                                         y:30;
56                                         x:0
57                                         height:1
58                                         border.color: "#b57e8f"
59                     }
60
61                     width:rectangle1.width
62
63                     Rectangle{
64                         width:rectangle1.width;
65                         height:10;color:"transparent"
66                     }
67
68                     Text { x:5;y:50;text:getHD(name,idm) ;textFormat: Text.RichText;wrapMode: Text.WordWrap; font.pixelSize: 20
69                         font.family: "Tahoma";width:parent.width;}
70
71                     Rectangle{
72                         width:rectangle1.width;
73                         height:10;color:"transparent"
74                     }
75                 }
76
77         }
78
79
80         ListModel {
81                  id: listModel
82
83                  ListElement {
84                      idm:0;name: "";
85                  }
86                  ListElement {
87                      idm:-1;name: "";
88                  }
89                  ListElement {
90                      idm:1;name: "<b>Giờ Hoàng Đạo</b>";
91                  }
92                  ListElement {
93                      idm:2;name: "<b>Tiết Khí</b>";
94                  }
95                 ListElement {
96                      idm:3;name: "<b>Nhị Thập Bát Tú</b>";
97                  }
98                 ListElement {
99                      idm:-2;name: "<b>Hướng Xuất Hành</b>";
100                  }
101                 ListElement {
102                      idm:6;name: "<b>Các Sao Tốt</b>";
103                  }
104                ListElement {
105                      idm:7;name: "<b>Các Sao Xấu</b>";
106                  }
107                ListElement {
108                    idm:8;name: "";
109                }
110
111                /* ListElement {
112                      idm:5;name: "<b>Đánh Giá</b>";
113                  }*/
114          }
115
116
117
118         ListView {
119               id: listView
120               anchors.fill: parent;anchors.topMargin: 0;anchors.leftMargin: 0; anchors.bottomMargin: 16
121               model: listModel
122               delegate: listDelegate
123               focus: true
124
125               ScrollBar{}
126         }
127
128     }
129
130     ToolBarSingle { id: toolBar; height: 50;
131         y: screen.height-78
132         width: parent.width;
133         button1Label: "Quay Về"
134         onButton1Clicked:
135         {
136             screen.state="mainscreen"
137         }
138     }
139
140     function getHD(name,idm){
141         if (name.length){
142             name="<span style='color:blue;'>"+name+"</span><br>";
143         }
144
145         switch(idm){
146         case 0 : return name+ main_item.day_month_year_LN_CN;break;
147         case 1 : return name+screen.lunarGioHoangDao;break;
148         case 2 : return name+screen.lunarTietKhi();break;
149         case 3 : return name+main_item.nhi_thap_bat_tu; break;
150         case 5 :  return name+main_item.luan_giai;break;
151         case -1: return name+main_item.truc;break;
152         case 6: return name+main_item.cac_sao_tot;break;
153         case 7: return name+main_item.cac_sao_xau;break;
154         case -2: return name+main_item.huong_xuat_hanh;break;
155         case 8: return main_item.warnning;break;
156         }
157     }
158
159     function reset(){
160         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>)";
161         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);
162         main_item.truc = NTX.truc(screen.lunarMonth, screen.lunarDayCanChi, screen.lunarMonthCanChi);
163         main_item.cac_sao_tot = NTX.cacsaotot(screen.lunarMonth, screen.lunarDayCanChi);
164         main_item.cac_sao_xau = NTX.cacsaoxau(screen.lunarMonth, screen.lunarDayCanChi);
165         main_item.luan_giai = NTX.luangiai(screen.curDay);
166         main_item.huong_xuat_hanh = NTX.huong_xuat_hanh(screen.lunarDayCanChi);
167     }
168
169 }