rollback to qtquick 1.0 to compatible with qtlib 4.7 maemo5 fremantle pr 1.3
[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 "main.js" as Script
21 import "Themes.js" as Themes
22
23 Item{
24     id:xntxhd
25
26     anchors.verticalCenter: parent.verticalCenter
27     width: parent.width; height: parent.height;
28     x:(parent.width * 1.5)
29
30     signal close
31
32     Loader {
33         id: theme_manager
34         property alias theme: theme_manager.item
35         source: Themes.default_theme()
36     }
37
38     Connections {
39         target: xntxhd.parent
40
41         onDialogClose: {
42             xntxhd.state = "close";
43             xntxhd.destroy(600);
44         }
45     }
46
47     property string day_month_year_LN_CN:  ""
48     property string nhi_thap_bat_tu:  ""
49     property string truc:  ""
50     property string luan_giai:  ""
51     property string cac_sao_xau:  ""
52     property string cac_sao_tot:  ""
53     property string huong_xuat_hanh:  ""
54
55     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>."
56
57     Rectangle {
58         id: rectangle1
59
60         anchors.fill: parent; anchors.bottomMargin: 0;
61         visible: true
62         opacity:0.9
63
64
65         Component {
66             id: listDelegate
67
68                 Column {
69
70                     Rectangle {
71                                         width:rectangle1.width;
72                                         y:30;
73                                         x:0
74                                         height:1
75                                         border.color: "#b57e8f"
76                     }
77
78                     width:rectangle1.width
79
80                     Rectangle{
81                         width:rectangle1.width;
82                         height:10;color:"transparent"
83                     }
84
85                     Text { x:5;y:50;text:getHD(name,idm) ;textFormat: Text.RichText;wrapMode: Text.WordWrap; font.pixelSize: 20
86                         font.family: "Tahoma";width:parent.width-10;}
87
88                     Rectangle{
89                         width:rectangle1.width;
90                         height:10;color:"transparent"
91                     }
92                 }
93
94         }
95
96
97         ListModel {
98                  id: listModel
99
100                  ListElement {
101                      idm:0;name: "";
102                  }
103                  ListElement {
104                      idm:-1;name: "";
105                  }
106                  ListElement {
107                      idm:1;name: "<b>Giờ Hoàng Đạo</b>";
108                  }
109                  ListElement {
110                      idm:2;name: "<b>Tiết Khí</b>";
111                  }
112                 ListElement {
113                      idm:3;name: "<b>Nhị Thập Bát Tú</b>";
114                  }
115                 ListElement {
116                      idm:-2;name: "<b>Hướng Xuất Hành</b>";
117                  }
118                 ListElement {
119                      idm:6;name: "<b>Các Sao Tốt</b>";
120                  }
121                ListElement {
122                      idm:7;name: "<b>Các Sao Xấu</b>";
123                  }
124                ListElement {
125                    idm:8;name: "";
126                }
127
128                /* ListElement {
129                      idm:5;name: "<b>Đánh Giá</b>";
130                  }*/
131          }
132
133
134
135         ListView {
136               id: listView
137               anchors.fill: parent;anchors.topMargin: 45;anchors.leftMargin: 0;anchors.rightMargin: 0;anchors.bottomMargin: 55
138               model: listModel
139               delegate: listDelegate
140               focus: true
141
142               ScrollBar{}
143         }
144
145     }
146
147     ToolBarSingle {
148         id: toolBar; height: 42;
149         y: parent.height-52
150         width: parent.width;
151         button1Label: "Quay Về"
152         onButton1Clicked:xntxhd.close()
153     }
154
155     function getHD(name,idm){
156         if (name.length){
157             name="<span style='color:blue;'>"+name+"</span><br>";
158         }
159
160         reset();
161
162         switch(idm){
163         case 0 : return name+ xntxhd.day_month_year_LN_CN;break;
164         case 1 : return name+Script.lunarGioHoangDao;break;
165         case 2 : return name+Script.lunarTietKhi();break;
166         case 3 : return name+xntxhd.nhi_thap_bat_tu; break;
167         case 5 :  return name+xntxhd.luan_giai;break;
168         case -1: return name+xntxhd.truc;break;
169         case 6: return name+xntxhd.cac_sao_tot;break;
170         case 7: return name+xntxhd.cac_sao_xau;break;
171         case -2: return name+xntxhd.huong_xuat_hanh;break;
172         case 8: return xntxhd.warnning;break;
173         }
174     }
175
176     function reset(){
177         xntxhd.day_month_year_LN_CN = Script.thu()+",ngày <b>"+Script.curDay+"</b> tháng <b>"+Script.curMonth+"</b> năm <b>"+Script.curYear+"</b><br>Ngày <b>"+Script.lunarDay+"</b> tháng <b>"+Script.lunarMonth+"</b> năm <b>"+Script.lunarYear+"</b> (<b>"+Script.lunarYearInt+"</b>)";
178         xntxhd.nhi_thap_bat_tu = Script.sao(Script.curYear,Script.getLunarDate(Script.curDay,Script.curMonth,Script.curYear).jd - Script.getLunarDate(1,1,Script.curYear).jd);
179         xntxhd.truc = Script.truc(Script.lunarMonth, Script.lunarDayCanChi, Script.lunarMonthCanChi);
180         xntxhd.cac_sao_tot = Script.cacsaotot(Script.lunarMonth, Script.lunarDayCanChi);
181         xntxhd.cac_sao_xau = Script.cacsaoxau(Script.lunarMonth, Script.lunarDayCanChi);
182         xntxhd.luan_giai = Script.luangiai(Script.curDay);
183         xntxhd.huong_xuat_hanh = Script.huong_xuat_hanh(Script.lunarDayCanChi);
184     }
185
186     Rectangle {
187         width : xntxhd.width
188         height: 45
189         color:"white"
190         opacity: 0.5
191     }
192
193     Text {
194         id: title
195
196         anchors { horizontalCenter: xntxhd.horizontalCenter; top: xntxhd.top; topMargin: 10 }
197         font.pixelSize: 22
198         color: "black"
199         text: "Xem Ngày Tốt/Xấu"
200         smooth: true
201         font.bold: true
202     }
203
204     states: [
205         State {
206             name: "show"
207             AnchorChanges { target: xntxhd; anchors.right: parent.right }
208         },
209         State {
210             name: "close"
211             AnchorChanges { target: xntxhd; anchors.right: parent.left }
212         }
213     ]
214
215     transitions: Transition {
216         AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
217     }
218
219 }