[sailfish] Bugfix: Feeds.qml lost category after adding a new feed

Closes #114 (on sailfish)
This commit is contained in:
Michael Käufl 2014-10-24 19:31:11 +02:00
parent 7f2fadf112
commit 5eb1adce67
2 changed files with 29 additions and 2 deletions

View file

@ -98,6 +98,16 @@ ListModel {
return root.get(root.selectedIndex)
}
function getItemForId(id) {
for (var index = 0; index < root.count; ++index) {
var category = root.get(index)
if (category.categoryId === id) {
return category
}
}
return null;
}
function updateSelectedUnreadCount(op) {
var m = root.getSelectedItem()
root.setProperty(root.selectedIndex, "unreadcount", op(m.unreadcount))

View file

@ -74,7 +74,7 @@ Page {
}
header: PageHeader {
title: category.title
title: category ? category.title : ""
}
ViewPlaceholder {
enabled: listView.count == 0
@ -120,7 +120,24 @@ Page {
break
case 1:
//notification.show(qsTr('Feed added'))
feeds.update()
// During categories.update() the elements in
// categories will be removed and therefore
// feedsPage.category and feeds.category become
// null.
//
// The following code sets both
// feedsPage.category and feeds.category
// back to its previous value.
var catId = feedsPage.category.categoryId;
function tmp() {
feedsPage.category = categories.getItemForId(catId);
feeds.category = feedsPage.category
feeds.update()
categories.updateFinished.disconnect(tmp)
}
categories.updateFinished.connect(tmp)
categories.update()
break
case 2: