3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
8 import "Library/js/DBUtility.js" as DBUtility
12 property int componentWidth
13 property int itemHeight: 75
14 signal logRequest(string strMessage)
16 Component.onCompleted: {
17 DBUtility.initialize();
21 function loadSymbols(){
22 var symbolsArray = DBUtility.getAllSymbols();
23 if (symbolsArray && symbolsArray.length > 0){
25 for (i = 0; i< symbolsArray.length; i++) {
26 logRequest("Appending "+symbolsArray[i]+ " to ListModel");
27 symbolsListModel.append({"symbol": symbolsArray[i]});
29 logRequest("ListModel count is "+symbolsListModel.count);
33 function removeSymbol(symbol,index){
34 logRequest("Removing symbol "+symbol+" at index "+index);
36 var result = DBUtility.removeSymbol(symbol);
37 if (result !== "Error"){
38 symbolsListModel.remove(index);
41 logRequest("Error: DB error while removing "+symbol+" at index "+index);
46 function addSymbol(symbol){
47 if (symbol && symbol.length > 0){
48 symbol = symbol.toUpperCase();
49 logRequest("Adding symbol "+symbol);
50 var result = DBUtility.addSymbol(symbol);
51 logRequest("Result is "+result);
53 if (result !== "Error"){
54 symbolsListModel.append({"symbol": symbol});
57 logRequest("Error: DB error while adding "+symbol);
61 logRequest("Error: Invalid symbol "+symbol);
70 id: tickersListDelegate
73 id: wrapper; width: componentWidth; height: itemHeight
74 Rectangle { id: listRecord;
76 opacity: index % 2 ? 0.2 : 0.4;
77 height: parent.height - 2;
78 width: parent.width; y: 1 }
82 anchors.left: parent.left
83 anchors.leftMargin: 30
84 anchors.verticalCenter: parent.verticalCenter
85 verticalAlignment: Text.AlignVCenter
86 width: parent.width - 120;
90 elide: Text.ElideRight;
100 anchors.right: parent.right
104 source: "Library/images/remove.png"
105 anchors.centerIn: parent
106 width: 32; height: 32
110 id:removeButtonMouseArea
113 removeSymbol(symbol,index)
118 name: "pressed"; when: removeButtonMouseArea.pressed
119 PropertyChanges { target: removeButtonArea; color: "#9a9a9a"}
127 //width: parent.width
128 width: componentWidth
130 anchors.top: parent.top
136 width: parent.width - 120
137 height: parent.height
138 anchors.verticalCenter: parent.verticalCenter
139 anchors.left: parent.left
140 BorderImage { source: "Library/images/lineedit.sci"; anchors.fill: parent }
144 height: parent.height
145 anchors.left: parent.left
146 anchors.leftMargin: 5
147 anchors.verticalCenter: parent.verticalCenter
151 font.capitalization: Font.AllUppercase
152 inputMethodHints: Qt.ImhNoPredictiveText
153 color: "#151515"; selectionColor: "green"
154 KeyNavigation.tab: addButton
155 Keys.onReturnPressed: {
156 logRequest("Return pressed");
157 addSymbol(newSymbol.text.trim());
159 newSymbol.closeSoftwareInputPanel();
161 Keys.onEnterPressed: {
162 logRequest("Enter pressed");
163 addSymbol(newSymbol.text.trim());
165 newSymbol.closeSoftwareInputPanel();
173 anchors.verticalCenter: parent.verticalCenter
174 anchors.right: parent.right
176 height: parent.height
180 source: "Library/images/add.png"
181 width: 32; height: 32
182 anchors.centerIn: parent
185 id:addButtonMouseArea
188 addSymbol(newSymbol.text.trim());
190 newSymbol.closeSoftwareInputPanel();
194 name: "pressed"; when: addButtonMouseArea.pressed
195 PropertyChanges { target: addButtonArea; color: "#9a9a9a"}
200 anchors.top: newSymbolRow.bottom
201 anchors.bottom: footerTextArea.top
208 model: symbolsListModel
209 delegate: tickersListDelegate
220 anchors.bottom: parent.bottom
224 text: "Only Yahoo! Finance ticker symbols are supported."
225 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
226 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
228 style: Text.Raised; styleColor: "black"
232 id: footerMessageTimer
236 footerMessage.text = "";
240 Component.onCompleted: {
241 footerMessageTimer.start();