2 import "common" as Common
3 // Depends on qt4-declarative-qmlviewer
13 anchors.fill: parent; color: "#343434";
14 anchors.centerIn: parent
15 //transformOrigin: Item.Center
16 property bool editMode: false
17 property bool inPortrait: width < height
19 function categoryClicked(catid) {
20 feedsItem.catid = catid;
22 categoriesItem.isShown = false;
23 feedsItem.visible = true;
26 function feedClicked(feedid, updating) {
27 flipper.feedid = feedid;
29 toolBar.feedUpdating = updating;
30 flipper.visible = true;
33 function backClicked() {
34 if (flipper.visible && flipper.articleShown) {
35 // We're viewing an article, and going back to article listing
36 flipper.articleShown = false;
38 //flipper.articleid = "";
40 //articlesItem.reload()
43 if (flipper.visible) {
45 toolBar.feedUpdating = false;
46 flipper.visible = false;
52 if (feedsItem.visible) {
53 // Viewing feeds, going back to categories
54 //feedsItem.catid = "";
55 feedsItem.visible = false;
57 categoriesItem.isShown = true;
60 if (!feedsItem.visible) {
61 // Viewing categories, quitting
66 function categoryDeleted(catid) {
67 confirmationMessage.catid=catid;
68 confirmationMessage.state="deleteCat";
71 function feedDeleted(catid, feedid) {
72 confirmationMessage.catid=catid;
73 confirmationMessage.feedid=feedid;
74 confirmationMessage.state="deleteFeed";
77 function feedEdit(feedname, feedid, url) {
78 addFeed.feedEdit = true;
79 addFeed.feedName = feedname;
80 addFeed.feedUrl = url;
81 addFeed.visible = true;
84 function addCategory(categoryName) {
85 controller.addCategory(categoryName)
86 categoriesItem.reload();
90 function addFeed(catid, feedName, feedURL) {
91 controller.addFeed(feedName, feedURL, catid)
92 var doc = new XMLHttpRequest();
94 addFeedDialog.visible=false;
97 function updateClicked(feedid) {
98 controller.updateFeed(feedid);
101 function updateAllClicked() {
102 controller.updateAll();
108 property string hideReadFeeds : "False"
109 property string hideReadArticles : "False"
111 property bool isShown: false;
113 //width: parent.width; height: parent.height;
117 name: "shown"; when: config.isShown == true
118 PropertyChanges { target: config; y: 66 }
121 transitions: Transition {
122 NumberAnimation { properties: "y"; duration: 300; easing.type: "InOutQuad" }
127 Common.ConfirmationMessage {
128 id: confirmationMessage;
129 property string catid: "";
130 property string feedid: "";
133 if (state=="markAll") {
134 flipper.markAllAsRead();
139 if (state=="deleteCat") {
140 var doc = new XMLHttpRequest();
141 var url = "http://localhost:8000/deleteCat/"+catid
142 doc.open("GET", url);
144 categoriesItem.reload();
148 if (state=="deleteFeed") {
149 var doc = new XMLHttpRequest();
150 var url = "http://localhost:8000/deleteFeed/"+catid+"/"+feedid
151 doc.open("GET", url);
159 onOkClicked: action()
160 onCancelClicked: visible=false
162 states: [ State {name: "markAll";
163 PropertyChanges { target: confirmationMessage; text: qsTr("Do you want to mark all items as read?") }
164 PropertyChanges { target: confirmationMessage; visible: true; }
166 }, State {name: "deleteCat";
167 PropertyChanges { target: confirmationMessage; text: qsTr("Do you want to delete this category?") }
168 PropertyChanges { target: confirmationMessage; visible: true; }
169 }, State {name: "deleteFeed";
170 PropertyChanges { target: confirmationMessage; text: qsTr("Do you want to delete this feed and all its articles?") }
171 PropertyChanges { target: confirmationMessage; visible: true; }
172 }, State {name: "hidden";
173 PropertyChanges { target: confirmationMessage; visible: false; }
181 height: 66; anchors.top: parent.top; width: parent.width; opacity: 0.9
182 menuLabel: qsTr("Config"); backLabel: qsTr("Back")
183 nextLabel: qsTr("Next"); prevLabel: qsTr("Previous")
184 markAllLabel: qsTr("Mark All As Read"); zoomLabel: qsTr("Zoom")
185 taskSwitcherLabel: qsTr("Task Switch")
186 onMenuClicked: config.isShown = !config.isShown;
187 onBackClicked: container.backClicked()
188 onPrevClicked: flipper.prev();
189 onNextClicked: flipper.next();
191 confirmationMessage.state = "markAll";
193 onZoomClicked: { flipper.zoomEnabled = !flipper.zoomEnabled; }
194 onTaskSwitcherClicked: {
195 var doc = new XMLHttpRequest();
196 var url = "http://localhost:8000/task"
197 doc.open("GET", url);
201 if (feedsItem.visible) {
202 addFeedDialog.feedName="";
203 addFeedDialog.catid = feedsItem.catid;
204 addFeedDialog.visible = true;
207 if (categoriesItem.visible) {
214 if (flipper.visible) {
215 toolBar.feedUpdating = true
216 container.updateClicked(flipper.feedid);
218 container.updateAllClicked();
223 name: "navButtons"; when: flipper.articleShown
224 PropertyChanges { target: toolBar; nextVisible: !container.inPortrait; }
225 PropertyChanges { target: toolBar; prevVisible: !container.inPortrait; }
226 //PropertyChanges { target: toolBar; zoomVisible: true; }
227 PropertyChanges { target: toolBar; addVisible: false; }
230 name: "feedButtons"; when: (flipper.visible)&&(!flipper.articleShown)
231 PropertyChanges { target: toolBar; markAllVisible: true; }
232 PropertyChanges { target: toolBar; addVisible: false; }
233 PropertyChanges { target: toolBar; updateVisible: true; }
236 name: "quitButton"; when: (!feedsItem.visible)
237 PropertyChanges { target: toolBar; quitVisible: true;}
238 PropertyChanges { target: toolBar; updateVisible: true; }
239 //PropertyChanges { target: toolBar; addVisible: true; }
248 width: parent.width // - 4
249 height: parent.height-toolBar.height;
250 anchors.top: toolBar.bottom; anchors.bottom: parent.bottom
257 height: parent.height;
265 height: parent.height;
270 function checkUpdates() {
271 if (categoriesItem.visible && !feedsItem.visible) {
272 var doc = new XMLHttpRequest();
273 var url = "http://localhost:8000/isUpdating/"
274 doc.onreadystatechange = function() {
275 if (doc.readyState == XMLHttpRequest.DONE) {
276 var xmlDoc = doc.responseXML.documentElement;
277 //var els = xmlDoc.getElementsByTagName("updating");
278 var isUpdating = xmlDoc.firstChild.firstChild.nodeValue;
280 //console.log(isUpdating);
281 if (isUpdating=="True") {
282 toolBar.feedUpdating = true;
284 if (toolBar.feedUpdating) {
285 // We changed from updating to not updating, so we reload the listing
286 toolBar.feedUpdating = false;
287 categoriesItem.reload();
290 var commands = xmlDoc.lastChild.childNodes;
291 for (var ii = 0; ii < commands.length; ++ii) {
292 // process the commands
293 var command = commands[ii].attributes[0].value; //("c")
294 //console.log(command)
295 if (command=="openFeed") {
297 var catid = commands[ii].attributes[1].value;
298 var feedid = commands[ii].firstChild.nodeValue;
299 if (!flipper.visible) {
300 container.categoryClicked(catid);
301 container.feedClicked(feedid,false);
302 console.log("feedid: " + feedid);
305 if (command=="openArticle") {
306 // Open feed and article
307 var catid = commands[ii].attributes[1].value;
308 var feedid = commands[ii].attributes[2].value; //("key");
309 var articleid = commands[ii].firstChild.nodeValue;
310 if (!flipper.visible) {
311 container.categoryClicked(catid);
312 container.feedClicked(feedid,false);
313 flipper.viewArticle(articleid)
316 if (command=="addFeed") {
317 // Open the addFeed dialog
318 var url = commands[ii].firstChild.nodeValue;
319 //console.log("add: "+url)
326 doc.open("GET", url);
328 //categoriesItem.reload()
330 if (feedsItem.visible && !flipper.visible) {
333 if (flipper.visible) {
334 var doc = new XMLHttpRequest();
335 var url = "http://localhost:8000/isUpdating/" + flipper.feedid
336 doc.onreadystatechange = function() {
337 if (doc.readyState == XMLHttpRequest.DONE) {
338 var xmlDoc = doc.responseXML.documentElement;
339 var isUpdating = xmlDoc.firstChild.firstChild.nodeValue;
340 //console.log(isUpdating);
341 if (isUpdating=="True") {
342 toolBar.feedUpdating = true;
344 if (toolBar.feedUpdating) {
345 // We changed from updating to not updating, so we reload the listing
346 toolBar.feedUpdating = false;
352 doc.open("GET", url);
358 interval: 2000; running: false; repeat: true
359 onTriggered: checkUpdates();
363 // Loads the categoryList view and delegate
365 property bool isShown: true;
366 inEditMode: container.editMode;
369 name: "shown"; when: categoriesItem.isShown == false
370 PropertyChanges { target: categoriesItem; x: -screen.width }
373 transitions: Transition {
374 NumberAnimation { properties: "x"; duration: 300; easing.type: "InOutQuad" }
381 // Loads the feedList view and delegate
383 property string hideReadFeeds: config.hideReadFeeds
385 inEditMode: container.editMode;
388 State { name: "articlesShown"; when: flipper.visible; PropertyChanges { target: feedsItem; x: -parent.width } },
389 State { name: "shown"; when: feedsItem.visible; PropertyChanges { target: feedsItem; x: 0 } }
392 transitions: Transition {
393 NumberAnimation { properties: "x"; duration: 300; easing.type: "InOutQuad" }
401 property string hideReadArticles: config.hideReadArticles
402 property string feedid: ""
405 states: State { name: "shown"; when: flipper.visible; PropertyChanges { target: flipper; x: 0 }
408 transitions: Transition {
409 NumberAnimation { properties: "x"; duration: 300; easing.type: "InOutQuad" }
415 // x: container.width/2
416 // y:container.height/2
417 // text: runtime.orientation;