2 import "common" as Common
3 // Depends on qt4-declarative-qmlviewer
12 /*anchors.fill: parent;*/ color: "#343434";
13 anchors.centerIn: parent
14 transformOrigin: Item.Center
15 property bool editMode: false
17 function categoryClicked(catid) {
18 feedsItem.catid = catid;
19 categoriesItem.isShown = false;
20 feedsItem.visible = true;
23 function feedClicked(feedid, updating) {
24 flipper.feedid = feedid;
25 toolBar.feedUpdating = updating;
26 flipper.visible = true;
29 // function articleClicked(articleid, index) {
30 // // Assign the articleId for the current, next and previous article to the associated variables
31 // // Note the modulo, so it goes around
32 // //articleDisplay.articleindex = modulo(index,articlesItem.count)
33 // //articleDisplay.nextArticle = articlesItem.getArticleid(modulo(index+1,articlesItem.count))
34 // //articleDisplay.prevArticle = articlesItem.getArticleid(modulo(index-1,articlesItem.count))
35 // //articleDisplay.articleid = articleid
36 // //flipper.model = articlesItem.articles
37 // flipper.visible = true;
40 function backClicked() {
41 if (flipper.visible && flipper.articleShown) {
42 // We're viewing an article, and going back to article listing
43 flipper.articleShown = false;
45 //flipper.articleid = "";
47 //articlesItem.reload()
50 if (flipper.visible) {
52 toolBar.feedUpdating = false;
53 flipper.visible = false;
58 // if (articlesItem.visible) {
59 // // Viewing articles, going back to feeds
60 // //articlesItem.feedid = "";
61 // feedsItem.reload();
62 // articlesItem.visible = false;
63 // //articlesItem.reload();
66 if (feedsItem.visible) {
67 // Viewing feeds, going back to categories
68 //feedsItem.catid = "";
69 feedsItem.visible = false;
71 categoriesItem.isShown = true;
74 if (!feedsItem.visible) {
75 // Viewing categories, quitting
80 function categoryDeleted(catid) {
81 confirmationMessage.catid=catid;
82 confirmationMessage.state="deleteCat";
85 function feedDeleted(catid, feedid) {
86 confirmationMessage.catid=catid;
87 confirmationMessage.feedid=feedid;
88 confirmationMessage.state="deleteFeed";
91 function addCategory(categoryName) {
92 var doc = new XMLHttpRequest();
93 var url = "http://localhost:8000/addCat/"+categoryName
96 categoriesItem.reload();
100 function addFeed(catid, feedName, feedURL) {
101 var doc = new XMLHttpRequest();
102 var url = "http://localhost:8000/addFeed/"+catid + "/" + feedName + "?url=" + feedURL
103 doc.open("GET", url);
106 console.log(addFeedDialog.visible)
107 addFeedDialog.visible=false;
108 console.log(addFeedDialog.visible)
111 function updateClicked(feedid) {
112 var doc = new XMLHttpRequest();
113 var url = "http://localhost:8000/updateFeed/" + feedid
114 doc.open("GET", url);
118 function updateAllClicked() {
119 var doc = new XMLHttpRequest();
120 var url = "http://localhost:8000/updateAll"
121 doc.open("GET", url);
128 property string hideReadFeeds : "False"
129 property string hideReadArticles : "False"
131 property bool isShown: false;
133 //width: parent.width; height: parent.height;
137 name: "shown"; when: config.isShown == true
138 PropertyChanges { target: config; y: 66 }
141 transitions: Transition {
142 NumberAnimation { properties: "y"; duration: 300; easing.type: "InOutQuad" }
147 Common.ConfirmationMessage {
148 id: confirmationMessage;
149 property string catid: "";
150 property string feedid: "";
153 if (state=="markAll") {
154 flipper.markAllAsRead();
159 if (state=="deleteCat") {
160 var doc = new XMLHttpRequest();
161 var url = "http://localhost:8000/deleteCat/"+catid
162 doc.open("GET", url);
164 categoriesItem.reload();
168 if (state=="deleteFeed") {
169 var doc = new XMLHttpRequest();
170 var url = "http://localhost:8000/deleteFeed/"+catid+"/"+feedid
171 doc.open("GET", url);
179 onOkClicked: action()
180 onCancelClicked: visible=false
182 states: [ State {name: "markAll";
183 PropertyChanges { target: confirmationMessage; text: qsTr("Do you want to mark all items as read?") }
184 PropertyChanges { target: confirmationMessage; visible: true; }
186 }, State {name: "deleteCat";
187 PropertyChanges { target: confirmationMessage; text: qsTr("Do you want to delete this category?") }
188 PropertyChanges { target: confirmationMessage; visible: true; }
189 }, State {name: "deleteFeed";
190 PropertyChanges { target: confirmationMessage; text: qsTr("Do you want to delete this feed and all its articles?") }
191 PropertyChanges { target: confirmationMessage; visible: true; }
192 }, State {name: "hidden";
193 PropertyChanges { target: confirmationMessage; visible: false; }
201 height: 66; anchors.top: parent.top; width: parent.width; opacity: 0.9
202 menuLabel: qsTr("Config"); backLabel: qsTr("Back")
203 nextLabel: qsTr("Next"); prevLabel: qsTr("Previous")
204 markAllLabel: qsTr("Mark All As Read"); zoomLabel: qsTr("Zoom")
205 taskSwitcherLabel: qsTr("Task Switch")
206 onMenuClicked: config.isShown = !config.isShown;
207 onBackClicked: container.backClicked()
208 onPrevClicked: flipper.prev();
209 onNextClicked: flipper.next();
211 confirmationMessage.state = "markAll";
213 onZoomClicked: { flipper.zoomEnabled = !flipper.zoomEnabled; }
214 onTaskSwitcherClicked: {
215 var doc = new XMLHttpRequest();
216 var url = "http://localhost:8000/task"
217 doc.open("GET", url);
221 if (feedsItem.visible) {
222 addFeedDialog.feedName="";
223 addFeedDialog.catid = feedsItem.catid;
224 addFeedDialog.visible = true;
227 if (categoriesItem.visible) {
234 if (flipper.visible) {
235 toolBar.feedUpdating = true
236 container.updateClicked(flipper.feedid);
238 container.updateAllClicked();
243 name: "navButtons"; when: flipper.articleShown
244 PropertyChanges { target: toolBar; nextVisible: !container.inPortrait; }
245 PropertyChanges { target: toolBar; prevVisible: !container.inPortrait; }
246 PropertyChanges { target: toolBar; zoomVisible: true; }
247 PropertyChanges { target: toolBar; addVisible: false; }
250 name: "feedButtons"; when: (flipper.visible)&&(!flipper.articleShown)
251 PropertyChanges { target: toolBar; markAllVisible: true; }
252 PropertyChanges { target: toolBar; addVisible: false; }
253 PropertyChanges { target: toolBar; updateVisible: true; }
256 name: "quitButton"; when: (!feedsItem.visible)
257 PropertyChanges { target: toolBar; quitVisible: true;}
258 PropertyChanges { target: toolBar; backVisible: false; }
259 PropertyChanges { target: toolBar; updateVisible: true; }
260 //PropertyChanges { target: toolBar; addVisible: true; }
269 width: parent.width // - 4
270 height: parent.height-toolBar.height;
271 anchors.top: toolBar.bottom; anchors.bottom: parent.bottom
278 height: parent.height;
286 height: parent.height;
291 function checkUpdates() {
292 if (categoriesItem.visible && !feedsItem.visible) {
293 var doc = new XMLHttpRequest();
294 var url = "http://localhost:8000/isUpdating/"
295 doc.onreadystatechange = function() {
296 if (doc.readyState == XMLHttpRequest.DONE) {
297 var xmlDoc = doc.responseXML.documentElement;
298 //var els = xmlDoc.getElementsByTagName("updating");
299 var isUpdating = xmlDoc.firstChild.firstChild.nodeValue;
301 console.log(isUpdating);
302 if (isUpdating=="True") {
303 toolBar.feedUpdating = true;
305 if (toolBar.feedUpdating) {
306 // We changed from updating to not updating, so we reload the listing
307 toolBar.feedUpdating = false;
308 categoriesItem.reload();
311 var commands = xmlDoc.lastChild.childNodes;
312 for (var ii = 0; ii < commands.length; ++ii) {
313 // process the commands
314 var command = commands[ii].attributes[0].value; //("c")
316 if (command=="openFeed") {
318 var catid = commands[ii].attributes[1].value;
319 var feedid = commands[ii].firstChild.nodeValue;
320 if (!flipper.visible) {
321 container.categoryClicked(catid);
322 container.feedClicked(feedid,false);
323 console.log("feedid: " + feedid);
326 if (command=="openArticle") {
327 // Open feed and article
328 var feedid = commands[ii].attributes[2].value; //("key");
329 var articleid = commands[ii].firstChild.nodeValue;
330 if (!flipper.visible) {
331 container.categoryClicked(catid);
332 container.feedClicked(feedid,false);
333 container.articleClicked(articleid, index)
334 console.log("art: "+feedid+"/"+articleid);
337 if (command=="addFeed") {
338 // Open the addFeed dialog
339 var url = commands[ii].firstChild.nodeValue;
340 console.log("add: "+url)
346 doc.open("GET", url);
348 //categoriesItem.reload()
350 if (feedsItem.visible && !flipper.visible) {
353 if (flipper.visible) {
354 var doc = new XMLHttpRequest();
355 var url = "http://localhost:8000/isUpdating/" + flipper.feedid
356 doc.onreadystatechange = function() {
357 if (doc.readyState == XMLHttpRequest.DONE) {
358 var a = doc.responseXML.documentElement;
359 console.log(a.firstChild.nodeValue);
360 if (a.firstChild.nodeValue=="True") {
361 toolBar.feedUpdating = true;
363 if (toolBar.feedUpdating) {
364 // We changed from updating to not updating, so we reload the listing
365 toolBar.feedUpdating = false;
371 doc.open("GET", url);
377 interval: 2000; running: true; repeat: true
378 onTriggered: checkUpdates();
382 // Loads the categoryList view and delegate
384 property bool isShown: true;
385 inEditMode: container.editMode;
388 name: "shown"; when: categoriesItem.isShown == false
389 PropertyChanges { target: categoriesItem; x: -screen.width }
392 transitions: Transition {
393 NumberAnimation { properties: "x"; duration: 300; easing.type: "InOutQuad" }
400 // Loads the feedList view and delegate
402 property string hideReadFeeds: config.hideReadFeeds
404 inEditMode: container.editMode;
407 State { name: "articlesShown"; when: flipper.visible; PropertyChanges { target: feedsItem; x: -parent.width } },
408 State { name: "shown"; when: feedsItem.visible; PropertyChanges { target: feedsItem; x: 0 } }
411 transitions: Transition {
412 NumberAnimation { properties: "x"; duration: 300; easing.type: "InOutQuad" }
420 property string hideReadArticles: config.hideReadArticles
421 property string feedid: ""
424 states: State { name: "shown"; when: flipper.visible; PropertyChanges { target: flipper; x: 0 }
427 transitions: Transition {
428 NumberAnimation { properties: "x"; duration: 300; easing.type: "InOutQuad" }
433 property bool lockRotation: false
434 property variant selectedOrientation: Orientation.UnknownOrientation
435 property variant activeOrientation: selectedOrientation == Orientation.UnknownOrientation ? runtime.orientation : selectedOrientation
436 state: "orientation " + activeOrientation
437 property bool inPortrait: (activeOrientation == Orientation.Portrait || activeOrientation == Orientation.PortraitInverted);
439 // rotation correction for landscape devices like N900
440 property bool landscapeWindow: screen.width > screen.height
441 property variant rotationDelta: landscapeWindow ? -90 : 0
442 rotation: rotationDelta
444 // initial state is portrait
445 property real baseWidth: landscapeWindow ? screen.height : screen.width
446 property real baseHeight: landscapeWindow ? screen.width : screen.height
451 function getAngle(orientation) {
453 if (orientation == Orientation.Portrait) {
455 } else if (orientation == Orientation.Landscape) {
457 } else if (orientation == Orientation.PortraitInverted) {
459 } else if (orientation == Orientation.LandscapeInverted) {
469 name: "orientation " + Orientation.Landscape
472 rotation: getAngle(Orientation.Landscape)+rotationDelta
476 StateChangeScript { script: console.log(container.width +"/"+container.height) }
479 name: "orientation " + Orientation.PortraitInverted
482 rotation: getAngle(Orientation.PortraitInverted)+rotationDelta
486 StateChangeScript { script: console.log(container.width +"/"+container.height) }
489 name: "orientation " + Orientation.LandscapeInverted
492 rotation: getAngle(Orientation.LandscapeInverted)+rotationDelta
496 StateChangeScript { script: console.log(container.width +"/"+container.height) }
499 transitions: Transition {
502 direction: RotationAnimation.Shortest
504 easing.type: Easing.InOutQuint
507 properties: "x,y,width,height"
509 easing.type: Easing.InOutQuint