2
import QtQuick.XmlListModel 2.0
4
import Ubuntu.Components 0.1
5
import Ubuntu.Components.ListItems 0.1 as ListItems
6
import Ubuntu.Components.Popups 0.1
8
import "../databasemodule_v2.js" as DB
13
function reloadPageContent() {
14
feedList.model = null // Sections are not recreated without this line.
17
/* Append feeds with topics.
19
var allFeeds = DB.loadFeeds()
20
var tags = DB.loadTags()
22
for (var i = 0; i < tags.rows.length; i++) {
23
var curTag = tags.rows.item(i) // TMP
24
var feedsByTag = DB.loadFeedsFromTag(curTag.id)
26
for (var j = 0; j < feedsByTag.rows.length; j++) {
27
var curFeed = feedsByTag.rows.item(j)
28
feedListModel.append({"tagName":curTag.name,
30
"feedName" : curFeed.title,
31
"feedId" : curFeed.id,
32
"feedSource": curFeed.source,
33
"feedDescription" : curFeed.description,
34
"isSelected" : false })
38
/* Append rest of feeds.
40
var feedsWithoutTopic = DB.loadFeedsWithoutTopic()
42
for (var j = 0; j < feedsWithoutTopic.rows.length; j++) {
43
var curFeed = feedsWithoutTopic.rows.item(j)
45
feedListModel.append({"tagName": i18n.tr("No topic"),
47
"feedName" : curFeed.title,
48
"feedId" : curFeed.id,
49
"feedSource": curFeed.source,
50
"feedDescription" : curFeed.description,
51
"isSelected" : false })
54
feedList.model = feedListModel
68
header: ListItems.Subtitled {
69
text: i18n.tr("All news")
70
subText: i18n.tr("View news from all channels")
72
visible: feedListModel.count != 0
75
pageStack.push(articleListPage, {"updateData" : {"isAll" : true} })
79
delegate: ListItems.Subtitled {
80
text: (model.feedName == "")? model.feedSource : model.feedName
81
subText: (model.feedDescription !== undefined)? model.feedDescription : ""
85
feedList.currentIndex = model.index
86
PopupUtils.open(popoverComponent, feedList)
90
console.log("Show news in feed:", model.feedSource)
91
pageStack.push(articleListPage, {"updateData" : {"isAll":false, "feedId" : model.feedId} })
92
// pageItself.feedSelected({"isAll":false, "feedId":model.id})
98
criteria: ViewSection.FullString
99
delegate: ListItems.Header {
100
// height: units.gu(5)
101
Component.onCompleted: {
103
for (var i = 0; i < feedListModel.count; i++) {
104
if (feedListModel.get(i).tagId == s) {
105
text = feedListModel.get(i).tagName
115
tools: mainCommonToolbar
120
/* This new popover works like context menu.
121
* Actions can be reused in toolbar.
123
ActionSelectionPopover {
125
actions: ActionList {
126
id: popoverActionsList
129
text: i18n.tr("Update")
131
// var data = feedListModel.get(feedList.currentIndex)
132
// var feedUrl = data.feedSource
133
// console.log("UPDATE STARTED FOR FEED:", data.feedSource, data.feedId)
134
// pageItself.currentTask = {"operation" : "update", "source" : feedUrl, "feedId" : data.feedId}
135
// thinXmlHttpRequestWraper.loadXml(feedUrl)
140
text: i18n.tr("Edit")
142
var data = feedListModel.get(feedList.currentIndex)
143
console.log("START EDIT ", data.source, data.status)
144
if (data.status == '0') {
145
console.log("EDIT ABORT")
149
PopupUtils.open(popoverSheetComponent, tools, {"isForEdit":true, "itemData" : data})
154
text: i18n.tr("Open site")
156
Qt.openUrlExternally(feedListModel.get(feedList.currentIndex).feedSource)
161
text: i18n.tr("Remove")
163
var id = feedListModel.get(feedList.currentIndex).feedId
164
var dbResult = DB.deleteFeed(id)
165
if (dbResult.rowsAffected > 0) {
167
feedListModel.remove(feedList.currentIndex)
173
text: i18n.tr("Remove all")
176
//feedListModel.clear()
180
} // ActionSelectionPopover
181
} // Popover component
186
text: i18n.tr("There are no RSS feeds to show")
187
anchors.centerIn: parent
188
visible: feedListModel.count == 0