/*anchors.fill: parent;*/ color: "#343434";
anchors.centerIn: parent
transformOrigin: Item.Center
+ property bool editMode: false
function categoryClicked(catid) {
feedsItem.catid = catid;
feedsItem.visible = true;
}
- function feedClicked(feedid) {
+ function feedClicked(feedid, updating) {
flipper.feedid = feedid;
+ toolBar.feedUpdating = updating;
flipper.visible = true;
}
}
if (flipper.visible) {
feedsItem.reload();
+ toolBar.feedUpdating = false;
flipper.visible = false;
flipper.feedid = "";
return;
}
}
+ function categoryDeleted(catid) {
+ confirmationMessage.catid=catid;
+ confirmationMessage.state="deleteCat";
+ }
+
+ function feedDeleted(catid, feedid) {
+ confirmationMessage.catid=catid;
+ confirmationMessage.feedid=feedid;
+ confirmationMessage.state="deleteFeed";
+ }
+
+ function addCategory(categoryName) {
+ var doc = new XMLHttpRequest();
+ var url = "http://localhost:8000/addCat/"+categoryName
+ doc.open("GET", url);
+ doc.send();
+ categoriesItem.reload();
+ addCat.visible=false;
+ }
+
+ function addFeed(catid, feedName, feedURL) {
+ var doc = new XMLHttpRequest();
+ var url = "http://localhost:8000/addFeed/"+catid + "/" + feedName + "?url=" + feedURL
+ doc.open("GET", url);
+ doc.send();
+ feedsItem.reload();
+ console.log(addFeedDialog.visible)
+ addFeedDialog.visible=false;
+ console.log(addFeedDialog.visible)
+ }
+
+ function updateClicked(feedid) {
+ var doc = new XMLHttpRequest();
+ var url = "http://localhost:8000/updateFeed/" + feedid
+ doc.open("GET", url);
+ doc.send();
+ }
+
+ function updateAllClicked() {
+ var doc = new XMLHttpRequest();
+ var url = "http://localhost:8000/updateAll"
+ doc.open("GET", url);
+ doc.send();
+ }
+
Common.Menu {
id: config
z: 5
Common.ConfirmationMessage {
id: confirmationMessage;
- visible: false
- onOkClicked: { var doc = new XMLHttpRequest();
- console.log(articlesItem.url+"&markAllAsRead=True")
- var url = articlesItem.url+"&markAllAsRead=True"
- console.log(url)
- doc.open("GET", url);
- doc.send();
- var xmlDoc=doc.responseXML;
- articlesItem.reload();
- feedsItem.reload()
- visible=false
+ property string catid: "";
+ property string feedid: "";
+
+ function action() {
+ if (state=="markAll") {
+ flipper.markAllAsRead();
+ state="hidden"
+ feedsItem.reload()
+ return;
+ }
+ if (state=="deleteCat") {
+ var doc = new XMLHttpRequest();
+ var url = "http://localhost:8000/deleteCat/"+catid
+ doc.open("GET", url);
+ doc.send();
+ categoriesItem.reload();
+ state="hidden";
+ return;
+ }
+ if (state=="deleteFeed") {
+ var doc = new XMLHttpRequest();
+ var url = "http://localhost:8000/deleteFeed/"+catid+"/"+feedid
+ doc.open("GET", url);
+ doc.send();
+ feedsItem.reload();
+ state="hidden";
+ return;
+ }
}
+ visible: false
+ onOkClicked: action()
onCancelClicked: visible=false
+ state: "hidden"
+ states: [ State {name: "markAll";
+ PropertyChanges { target: confirmationMessage; text: qsTr("Do you want to mark all items as read?") }
+ PropertyChanges { target: confirmationMessage; visible: true; }
+
+ }, State {name: "deleteCat";
+ PropertyChanges { target: confirmationMessage; text: qsTr("Do you want to delete this category?") }
+ PropertyChanges { target: confirmationMessage; visible: true; }
+ }, State {name: "deleteFeed";
+ PropertyChanges { target: confirmationMessage; text: qsTr("Do you want to delete this feed and all its articles?") }
+ PropertyChanges { target: confirmationMessage; visible: true; }
+ }, State {name: "hidden";
+ PropertyChanges { target: confirmationMessage; visible: false; }
+ }
+ ]
+
}
Common.ToolBar {
onPrevClicked: flipper.prev();
onNextClicked: flipper.next();
onMarkAllClicked: {
- confirmationMessage.text = qsTr("Do you want to mark all items as read?");
- confirmationMessage.visible = true;
+ confirmationMessage.state = "markAll";
}
onZoomClicked: { flipper.zoomEnabled = !flipper.zoomEnabled; }
onTaskSwitcherClicked: {
var url = "http://localhost:8000/task"
doc.open("GET", url);
doc.send();
- //var xmlDoc=doc.responseXML;
}
- //onRotateClicked: { container.rotation=-90; container.width=screen.height; container.height=screen.width; }
+ onAddClicked: {
+ if (feedsItem.visible) {
+ addFeedDialog.feedName="";
+ addFeedDialog.catid = feedsItem.catid;
+ addFeedDialog.visible = true;
+ return;
+ }
+ if (categoriesItem.visible) {
+ addCat.catName="";
+ addCat.visible=true;
+ return;
+ }
+ }
+ onUpdateClicked: {
+ if (flipper.visible) {
+ toolBar.feedUpdating = true
+ container.updateClicked(flipper.feedid);
+ } else {
+ container.updateAllClicked();
+ }
+ }
states: [ State {
name: "navButtons"; when: flipper.articleShown
PropertyChanges { target: toolBar; nextVisible: !container.inPortrait; }
PropertyChanges { target: toolBar; prevVisible: !container.inPortrait; }
PropertyChanges { target: toolBar; zoomVisible: true; }
+ PropertyChanges { target: toolBar; addVisible: false; }
},
State {
name: "feedButtons"; when: (flipper.visible)&&(!flipper.articleShown)
PropertyChanges { target: toolBar; markAllVisible: true; }
+ PropertyChanges { target: toolBar; addVisible: false; }
+ PropertyChanges { target: toolBar; updateVisible: true; }
},
State {
name: "quitButton"; when: (!feedsItem.visible)
PropertyChanges { target: toolBar; quitVisible: true;}
PropertyChanges { target: toolBar; backVisible: false; }
+ PropertyChanges { target: toolBar; updateVisible: true; }
+ //PropertyChanges { target: toolBar; addVisible: true; }
}
]
}
anchors.top: toolBar.bottom; anchors.bottom: parent.bottom
y: toolBar.height;
+ Common.AddCat {
+ visible: false;
+ id: addCat
+ width: parent.width;
+ height: parent.height;
+ z: 10;
+ }
+
+ Common.AddFeed {
+ visible: false;
+ id: addFeedDialog
+ width: parent.width;
+ height: parent.height;
+ z: 10;
+ }
+
+ Timer {
+ function checkUpdates() {
+ if (categoriesItem.visible && !feedsItem.visible) {
+ var doc = new XMLHttpRequest();
+ var url = "http://localhost:8000/isUpdating/"
+ doc.onreadystatechange = function() {
+ if (doc.readyState == XMLHttpRequest.DONE) {
+ var xmlDoc = doc.responseXML.documentElement;
+ //var els = xmlDoc.getElementsByTagName("updating");
+ var isUpdating = xmlDoc.firstChild.firstChild.nodeValue;
+
+ console.log(isUpdating);
+ if (isUpdating=="True") {
+ toolBar.feedUpdating = true;
+ } else {
+ if (toolBar.feedUpdating) {
+ // We changed from updating to not updating, so we reload the listing
+ toolBar.feedUpdating = false;
+ categoriesItem.reload();
+ }
+ }
+ var commands = xmlDoc.lastChild.childNodes;
+ for (var ii = 0; ii < commands.length; ++ii) {
+ // process the commands
+ var command = commands[ii].attributes[0].value; //("c")
+ console.log(command)
+ if (command=="openFeed") {
+ // Open feed feed
+ var catid = commands[ii].attributes[1].value;
+ var feedid = commands[ii].firstChild.nodeValue;
+ if (!flipper.visible) {
+ container.categoryClicked(catid);
+ container.feedClicked(feedid,false);
+ console.log("feedid: " + feedid);
+ }
+ }
+ if (command=="openArticle") {
+ // Open feed and article
+ var feedid = commands[ii].attributes[2].value; //("key");
+ var articleid = commands[ii].firstChild.nodeValue;
+ if (!flipper.visible) {
+ container.categoryClicked(catid);
+ container.feedClicked(feedid,false);
+ container.articleClicked(articleid, index)
+ console.log("art: "+feedid+"/"+articleid);
+ }
+ }
+ if (command=="addFeed") {
+ // Open the addFeed dialog
+ var url = commands[ii].firstChild.nodeValue;
+ console.log("add: "+url)
+ }
+ }
+
+ }
+ }
+ doc.open("GET", url);
+ doc.send();
+ //categoriesItem.reload()
+ }
+ if (feedsItem.visible && !flipper.visible) {
+ //feedsItem.reload()
+ }
+ if (flipper.visible) {
+ var doc = new XMLHttpRequest();
+ var url = "http://localhost:8000/isUpdating/" + flipper.feedid
+ doc.onreadystatechange = function() {
+ if (doc.readyState == XMLHttpRequest.DONE) {
+ var a = doc.responseXML.documentElement;
+ console.log(a.firstChild.nodeValue);
+ if (a.firstChild.nodeValue=="True") {
+ toolBar.feedUpdating = true;
+ } else {
+ if (toolBar.feedUpdating) {
+ // We changed from updating to not updating, so we reload the listing
+ toolBar.feedUpdating = false;
+ flipper.reload();
+ }
+ }
+ }
+ }
+ doc.open("GET", url);
+ doc.send();
+
+ //flipper.reload()
+ }
+ }
+ interval: 2000; running: true; repeat: true
+ onTriggered: checkUpdates();
+ }
+
Categories {
// Loads the categoryList view and delegate
id: categoriesItem
property bool isShown: true;
+ inEditMode: container.editMode;
states: State {
name: "shown"; when: categoriesItem.isShown == false
id: feedsItem;
property string hideReadFeeds: config.hideReadFeeds
visible: false;
+ inEditMode: container.editMode;
states: [
State { name: "articlesShown"; when: flipper.visible; PropertyChanges { target: feedsItem; x: -parent.width } },