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
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
135 width: parent.width - 120
136 height: parent.height
137 anchors.verticalCenter: parent.verticalCenter
138 anchors.left: parent.left
139 BorderImage { source: "Library/images/lineedit.sci"; anchors.fill: parent }
143 height: parent.height
144 anchors.left: parent.left
145 anchors.leftMargin: 5
146 anchors.verticalCenter: parent.verticalCenter
150 font.capitalization: Font.AllUppercase
151 inputMethodHints: Qt.ImhNoPredictiveText
152 color: "#151515"; selectionColor: "green"
153 KeyNavigation.tab: addButton
154 Keys.onReturnPressed: {
155 logRequest("Return pressed");
156 addSymbol(newSymbol.text.trim());
158 newSymbol.closeSoftwareInputPanel();
160 Keys.onEnterPressed: {
161 logRequest("Enter pressed");
162 addSymbol(newSymbol.text.trim());
164 newSymbol.closeSoftwareInputPanel();
172 anchors.verticalCenter: parent.verticalCenter
173 anchors.right: parent.right
175 height: parent.height
179 source: "Library/images/add.png"
180 width: 32; height: 32
181 anchors.centerIn: parent
184 id:addButtonMouseArea
187 addSymbol(newSymbol.text.trim());
189 newSymbol.closeSoftwareInputPanel();
193 name: "pressed"; when: addButtonMouseArea.pressed
194 PropertyChanges { target: addButtonArea; color: "#9a9a9a"}
199 anchors.top: newSymbolRow.bottom
200 anchors.bottom: footerTextArea.top
207 model: symbolsListModel
208 delegate: tickersListDelegate
219 anchors.bottom: parent.bottom
223 text: "Only Yahoo! Finance ticker symbols are supported."
224 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
225 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
227 style: Text.Raised; styleColor: "black"
231 id: footerMessageTimer
235 footerMessage.text = "";
239 Component.onCompleted: {
240 footerMessageTimer.start();