Merge lp:~qqworini/ubuntu-rssreader-app/saved into lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk

Proposed by Joey Chan
Status: Merged
Approved by: Roman Shchekin
Approved revision: 65
Merged at revision: 65
Proposed branch: lp:~qqworini/ubuntu-rssreader-app/saved
Merge into: lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk
Diff against target: 187 lines (+78/-12)
5 files modified
OrganicGrid.qml (+9/-1)
RssFeedPage.qml (+22/-1)
TopicTab.qml (+15/-6)
databasemodule_v2.js (+16/-2)
ubuntu-rssreader-app.qml (+16/-2)
To merge this branch: bzr merge lp:~qqworini/ubuntu-rssreader-app/saved
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Ubuntu Shorts Developers Pending
Review via email: mp+185029@code.launchpad.net

Commit message

New feature: "Saved" simply implemented, include save button in article view, "Saved" tab and related gridview, listview will be implemented by Roman soon, and multiselect not implemented yet.

Description of the change

New feature: "Saved" simply implemented, include save button in article view, "Saved" tab and related gridview, listview will be implemented by Roman soon, and multiselect not implemented yet.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'OrganicGrid.qml'
2--- OrganicGrid.qml 2013-09-03 18:47:49 +0000
3+++ OrganicGrid.qml 2013-09-11 12:16:27 +0000
4@@ -71,7 +71,15 @@
5 addArticleToModel(feedArticles.rows[i])
6 }
7 }
8- } else {
9+ }
10+ else if (tag_id == -2) {
11+ var favArticles = DB.loadFavouriteArticles()
12+ for (var i=0; i < favArticles.rows.length; i++)
13+ {
14+ addArticleToModel(favArticles.rows[i])
15+ }
16+ }
17+ else {
18 var feedArticles = DB.loadArticles({"isAll": true});
19 for (var i=0; i < feedArticles.rows.length; i++)
20 {
21
22=== modified file 'RssFeedPage.qml'
23--- RssFeedPage.qml 2013-09-07 16:38:50 +0000
24+++ RssFeedPage.qml 2013-09-11 12:16:27 +0000
25@@ -20,6 +20,7 @@
26 property string rssTitle: ""
27 property int rssIndex: 0
28 property variant rssModel
29+ property variant rssItem
30
31 onRssIndexChanged: {
32 rssListview.currentIndex = rssIndex
33@@ -41,6 +42,26 @@
34
35 ToolbarButton {
36 action: Action {
37+ text: rssItem.favourite == "0" ? i18n.tr("Save") : i18n.tr("Unsave")
38+ iconSource: Qt.resolvedUrl("./icons_tmp/go-to.svg")
39+ onTriggered:
40+ {
41+ var fav = (rssItem.favourite == "0" ? "1" : "0")
42+ var dbResult = DB.updateArticleFavourite(rssItem.id, fav)
43+ if (dbResult.rowsAffected == 1) {
44+ rssItem.favourite = fav
45+ var dbResult1 = DB.updateArticleStatus(rssItem.id, "0")
46+ if (dbResult1.rowsAffected == 1) {
47+ rssItem.status = "0"
48+ }
49+ mainView.refreshSavedTab()
50+ }
51+ }
52+ }
53+ }
54+
55+ ToolbarButton {
56+ action: Action {
57 text: i18n.tr("Open site")
58 iconSource: Qt.resolvedUrl("./icons_tmp/go-to.svg")
59 onTriggered:
60@@ -72,7 +93,7 @@
61
62 onCurrentIndexChanged: {
63 // console.log("ListView onCurrentIndexChanged", currentIndex)
64- var rssItem = rssModel.get(currentIndex)
65+ rssItem = rssModel.get(currentIndex)
66 rssTitle = rssItem.feed_name
67 var dbResult = DB.updateArticleStatus(rssItem.id, "1")
68 if (dbResult.rowsAffected == 1) {
69
70=== modified file 'TopicTab.qml'
71--- TopicTab.qml 2013-09-07 16:38:50 +0000
72+++ TopicTab.qml 2013-09-11 12:16:27 +0000
73@@ -58,13 +58,22 @@
74 // flickable: null
75
76 function reload () {
77- var feedTags = DB.loadFeedsFromTag(topicId)
78- var feeds = []
79- for (var i=0; i < feedTags.rows.length; i++) {
80- feeds.push(feedTags.rows.item(i))
81+ switch (topicId) {
82+ case -1:
83+ break
84+ case -2:
85+ organicGridView.reload()
86+ break
87+
88+ default:
89+ var feedTags = DB.loadFeedsFromTag(topicId)
90+ var feeds = []
91+ for (var i=0; i < feedTags.rows.length; i++) {
92+ feeds.push(feedTags.rows.item(i))
93+ }
94+ feedArray = feeds
95+ organicGridView.reload()
96 }
97- feedArray = feeds
98- organicGridView.reload()
99 }
100
101 OrganicGrid {
102
103=== modified file 'databasemodule_v2.js'
104--- databasemodule_v2.js 2013-09-06 07:27:18 +0000
105+++ databasemodule_v2.js 2013-09-11 12:16:27 +0000
106@@ -238,6 +238,20 @@
107 return dbResult;
108 }
109
110+// load all favourite articles
111+function loadFavouriteArticles()
112+{
113+ var db = openStdDataBase()
114+ var dbResult
115+
116+ db.transaction(function(tx) {
117+ dbResult = tx.executeSql('SELECT article.*, feed.title as feed_name FROM article inner join feed on article.feed_id = feed.id WHERE article.favourite = "1" ORDER BY article.pubdate DESC' )
118+ }
119+ )
120+ console.log("loadFavouriteArticles: ", dbResult.rows.length)
121+ return dbResult;
122+}
123+
124 // insert
125 function addArticle(title, content, link, description, pubdate, guid, feed_id)
126 {
127@@ -319,7 +333,7 @@
128 // ensureFeedTableExists(tx)
129 dbResult = tx.executeSql('UPDATE article SET status=? WHERE id=?',
130 [status, id])
131- console.log("article UPDATE, AFFECTED ROWS: ", dbResult.rowsAffected)
132+ console.log("article status UPDATE, AFFECTED ROWS: ", dbResult.rowsAffected)
133 }
134 )
135 return dbResult
136@@ -333,7 +347,7 @@
137 // ensureFeedTableExists(tx)
138 dbResult = tx.executeSql('UPDATE article SET favourite=? WHERE id=?',
139 [favourite, id])
140- //console.log("article UPDATE, AFFECTED ROWS: ", dbResult.rowsAffected)
141+ console.log("article favourite UPDATE, AFFECTED ROWS: ", dbResult.rowsAffected)
142 }
143 )
144 return dbResult
145
146=== modified file 'ubuntu-rssreader-app.qml'
147--- ubuntu-rssreader-app.qml 2013-09-07 16:38:50 +0000
148+++ ubuntu-rssreader-app.qml 2013-09-11 12:16:27 +0000
149@@ -70,7 +70,12 @@
150 xmlnetwork.updateFeeds(feedarray, topicId)
151 }
152
153- function toRssPage(model, index) // go to single article page // bugs remain
154+ // refresh "Saved" Tab
155+ function refreshSavedTab() {
156+ repeater.reloadSaved()
157+ }
158+
159+ function toRssPage(model, index) // go to single article page
160 {
161 feed_page.setFeed(model, index)
162 pageStack.push(feed_page)
163@@ -193,7 +198,7 @@
164 function reloadTabs() {
165 repeater.model = 0
166 var tags = DB.loadTags()
167- repeater.model = tags.rows.length
168+ repeater.model = tags.rows.length + 1 // plus 1 for "Saved" tab
169
170 for (var i = 0; i< tags.rows.length; i++) {
171 repeater.itemAt(i).title = tags.rows.item(i).name
172@@ -201,6 +206,15 @@
173 repeater.itemAt(i).isAll = false
174 repeater.itemAt(i).reload()
175 }
176+ // for "Saved" tab (means "favourite" in db)
177+ repeater.itemAt(tags.rows.length).title = i18n.tr("Saved")
178+ repeater.itemAt(tags.rows.length).topicId = -2
179+ repeater.itemAt(tags.rows.length).isAll = true
180+ repeater.itemAt(tags.rows.length).reload()
181+ }
182+
183+ function reloadSaved() {
184+ repeater.itemAt(repeater.model - 1).reload()
185 }
186 } // Repeater
187 }

Subscribers

People subscribed via source and target branches