Details Screen Started
[marketstoday] / src / qml / StockDetailsComponent.qml
1 /*
2 @version: 0.1
3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
5 */
6
7 import Qt 4.7
8
9 Item {
10
11     width: 800
12     height: 380
13
14     id: stockDetailsComponent
15     property int itemHeight: 50
16     property string symbol: "YHOO"
17     property string stockName: "Yahoo"
18     property string lastTradedPrice: ""
19     property string lastTradedTime: ""
20     property string change: ""
21     property string changePercentage: ""
22     property string dayLow: ""
23     property string dayHigh: ""
24     property string fiftyTwoWeekLow: ""
25     property string fiftyTwoWeekHigh: ""
26     property string marketVolume: ""
27     property string prevClose: ""
28     property string marketCap: ""
29     property string chartURL: ""
30
31     signal logRequest(string strMessage)
32
33     Rectangle {
34         anchors.fill: parent
35         color:"#343434"
36
37         Component.onCompleted: {
38             loadDetails();
39             if (symbol !== "") {
40                 chartURL = "http://chart.finance.yahoo.com/z?t=1d&q=&l=&z=m&p=s&a=v&p=s&lang=en-US&region=US&s="+symbol;
41                 stockDetailsLoader.sourceComponent = stockChartComponent;
42                 console.log(stockDetailsLoader.width + " x "+ stockDetailsLoader.height);
43             }
44         }
45
46         function loadDetails(){
47             if (symbol === "") return;
48
49         }
50
51         Text {
52             id: stockNameLabel
53             anchors.top: parent.top
54             width: parent.width
55             anchors.horizontalCenter: parent.horizontalCenter
56             height: 30
57             horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter
58             font.pixelSize: 18; font.bold: true; elide: Text.ElideMiddle; color: "#B8B8B8"; style: Text.Raised; styleColor: "black"
59             text: (stockName != "")? (stockName +" ("+symbol+")"):symbol
60         }
61
62         Rectangle {
63             id: stockDetailsSection
64             border.width: 1
65             border.color: "#BFBFBF"
66             color:"#2E2E2E"
67             anchors {top: stockNameLabel.bottom;left: parent.left;leftMargin: 40;right: parent.right;rightMargin: 40}
68             height: 125
69             radius: 15
70
71             Column{
72                 id: stockDetailsColumn
73                 anchors {top: parent.top; left: parent.left; leftMargin: 10}
74                 width: (parent.width - 10)
75
76                 StockDetailsRow{
77                     label1: "Last Traded"
78                     value1: lastTradedPrice
79                     cell1Width: stockDetailsColumn.width/2
80
81                     label2: "Day's Range"
82                     value2: ((dayHigh != "" && dayLow != "")? (dayLow + " - " + dayHigh) : "")
83                     cell2Width: stockDetailsColumn.width/2
84                 }
85
86                 StockDetailsRow{
87                     label1: "Last Trade Time"
88                     value1: lastTradedTime
89                     cell1Width: stockDetailsColumn.width/2
90
91                     label2: "52w Range"
92                     value2: ((fiftyTwoWeekHigh != "" && fiftyTwoWeekLow != "")? (fiftyTwoWeekLow + " - " + fiftyTwoWeekHigh) : "")
93                     cell2Width: stockDetailsColumn.width/2
94                 }
95
96                 StockDetailsRow{
97                     label1: "Change"
98                     value1: ((change != "" && changePercentage != "")? change + " ("+changePercentage+")":"")
99                     cell1Width: stockDetailsColumn.width/2
100
101                     label2: "Volume"
102                     value2: marketVolume
103                     cell2Width: stockDetailsColumn.width/2
104                 }
105
106                 StockDetailsRow{
107                     label1: "Prev. Close"
108                     value1: prevClose
109                     cell1Width: stockDetailsColumn.width/2
110
111                     label2: "Market Cap"
112                     value2: marketCap
113                     cell2Width: stockDetailsColumn.width/2
114                 }
115             }
116         }
117
118         Loader {
119           id: stockDetailsLoader
120           anchors {top: stockDetailsSection.bottom;bottom: parent.bottom; horizontalCenter: parent.horizontalCenter}
121           //width: parent.width
122           width: 480
123         }
124
125         Component{
126             id: stockChartComponent
127             Rectangle {
128                 id: rectangleChart
129                 border.width: 1
130                 border.color: "#BFBFBF"
131                 color:"#2E2E2E"
132                 anchors {top: parent.top;topMargin: 5;bottom: parent.bottom; left: parent.left;leftMargin: 40;right: parent.right;rightMargin: 40}
133                 radius: 15
134                 Image {
135                     anchors.fill: parent
136                     id: name
137                     source: chartURL
138                     fillMode: Image.PreserveAspectFit
139                 }
140             }
141         }
142     }
143 }