6.1.1
by Joey Chan
add my first into current trunk, click the back button in the bottom bar can go back to current trunk version |
1 |
/*
|
2 |
license GPL v3 ...........
|
|
3 |
||
4 |
description of this file:
|
|
5 |
a page for viewing a user selected RSS feed ;
|
|
6 |
||
7 |
*/
|
|
8 |
||
9 |
import QtQuick 2.0 |
|
10 |
import QtQuick.XmlListModel 2.0 |
|
11 |
import Ubuntu.Components 0.1 |
|
12 |
import Ubuntu.Components.ListItems 0.1 as ListItem |
|
27.1.1
by Joey Chan
alpha-1 release |
13 |
import "./dateutils.js" as DateUtils |
62.1.1
by Roman Shchekin
Set of minor changes, like: |
14 |
import "databasemodule_v2.js" as DB |
6.1.1
by Joey Chan
add my first into current trunk, click the back button in the bottom bar can go back to current trunk version |
15 |
|
16 |
Page { |
|
17 |
id: page_feed
|
|
18.2.2
by Roman Shchekin
Stable version of our app. |
18 |
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
19 |
property string rssModelUrl: "" |
20 |
property string rssTitle: "" |
|
13.1.10
by Roman Shchekin
Few bugs removed |
21 |
property int rssIndex: 0 |
65.1.1
by Roman Shchekin
"Saved" tab for list mode. |
22 |
property var rssModel |
23 |
property var rssItem: null |
|
24 |
property bool preventIndexChangeHandler: false |
|
17.1.1
by Joey Chan
hope I find the reason why contents conflict |
25 |
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
26 |
onRssIndexChanged: { |
27 |
rssListview.currentIndex = rssIndex |
|
28 |
rssListview.positionViewAtIndex(rssListview.currentIndex, ListView.Center) |
|
17.1.1
by Joey Chan
hope I find the reason why contents conflict |
29 |
}
|
30 |
||
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
31 |
function setFeed(model, index) { |
70.1.2
by Roman Shchekin
Little bugs related to article read/unread status are fixed. |
32 |
/* Setting new model and not-null index will cause two change events instead of one.
|
33 |
* Settings "preventIndexChangeHandler" to true helps to avoid it.
|
|
34 |
*/
|
|
35 |
if (rssModel != model && index !== 0) |
|
36 |
preventIndexChangeHandler = true |
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
37 |
rssModel = model |
13.1.10
by Roman Shchekin
Few bugs removed |
38 |
rssIndex = index |
13.1.7
by Joey Chan
final version demo of RSS reader, includes topic view, single article view |
39 |
}
|
40 |
||
20.1.1
by Roman Shchekin
Few little bugs fixed. |
41 |
function reloadPageContent() { |
42 |
||
43 |
}
|
|
44 |
||
13.1.7
by Joey Chan
final version demo of RSS reader, includes topic view, single article view |
45 |
tools: ToolbarItems { |
46 |
id: toolbar
|
|
47 |
||
48 |
ToolbarButton { |
|
49 |
action: Action { |
|
65.1.1
by Roman Shchekin
"Saved" tab for list mode. |
50 |
text: rssItem == null ? "" : (rssItem.favourite == "0" ? i18n.tr("Save") : i18n.tr("Unsave")) |
51 |
iconSource: { |
|
52 |
if (rssItem == null || rssItem.favourite == "0") |
|
53 |
return Qt.resolvedUrl("./icons_tmp/favorite-unselected.svg") |
|
54 |
else return Qt.resolvedUrl("./icons_tmp/favorite-selected.svg") |
|
55 |
}
|
|
56 |
onTriggered: { |
|
64.1.1
by Joey Chan
New feature: "Saved" simply implemented, include "Saved" tab and related gridview, listview will be implemented by Roman soon |
57 |
var fav = (rssItem.favourite == "0" ? "1" : "0") |
58 |
var dbResult = DB.updateArticleFavourite(rssItem.id, fav) |
|
59 |
if (dbResult.rowsAffected == 1) { |
|
60 |
rssItem.favourite = fav |
|
61 |
var dbResult1 = DB.updateArticleStatus(rssItem.id, "0") |
|
62 |
if (dbResult1.rowsAffected == 1) { |
|
63 |
rssItem.status = "0" |
|
64 |
}
|
|
65 |
mainView.refreshSavedTab() |
|
66 |
}
|
|
67 |
}
|
|
68 |
}
|
|
69 |
}
|
|
70 |
||
71 |
ToolbarButton { |
|
72 |
action: Action { |
|
13.1.10
by Roman Shchekin
Few bugs removed |
73 |
text: i18n.tr("Open site") |
31.1.1
by Roman Shchekin
Added dialog for "Refresh" operation! |
74 |
iconSource: Qt.resolvedUrl("./icons_tmp/go-to.svg") |
13.1.10
by Roman Shchekin
Few bugs removed |
75 |
onTriggered:
|
76 |
{
|
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
77 |
console.log("Open site", rssListview.model.get(rssListview.currentIndex).link) |
78 |
Qt.openUrlExternally(rssListview.model.get(rssListview.currentIndex).link) |
|
13.1.10
by Roman Shchekin
Few bugs removed |
79 |
}
|
80 |
}
|
|
81 |
}
|
|
6.1.1
by Joey Chan
add my first into current trunk, click the back button in the bottom bar can go back to current trunk version |
82 |
}
|
83 |
||
84 |
////////////////////////////////////////////// a listview to show the RSS content
|
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
85 |
ListView { |
86 |
id: rssListview
|
|
70.1.2
by Roman Shchekin
Little bugs related to article read/unread status are fixed. |
87 |
|
6.1.1
by Joey Chan
add my first into current trunk, click the back button in the bottom bar can go back to current trunk version |
88 |
width: parent.width |
89 |
anchors.bottom: parent.bottom |
|
27.1.1
by Joey Chan
alpha-1 release |
90 |
anchors.bottomMargin: units.gu(2) |
91 |
anchors.top: parent.top |
|
6.1.1
by Joey Chan
add my first into current trunk, click the back button in the bottom bar can go back to current trunk version |
92 |
anchors.topMargin: units.gu(2) |
93 |
snapMode: ListView.SnapOneItem |
|
94 |
cacheBuffer: 90 |
|
95 |
boundsBehavior: Flickable.StopAtBounds |
|
96 |
orientation: ListView.Horizontal |
|
97 |
contentHeight: parent.width * count |
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
98 |
model: rssModel |
99 |
delegate: xmlDelegate |
|
13.1.7
by Joey Chan
final version demo of RSS reader, includes topic view, single article view |
100 |
highlightFollowsCurrentItem: true |
13.1.10
by Roman Shchekin
Few bugs removed |
101 |
highlightRangeMode: ListView.StrictlyEnforceRange |
13.1.7
by Joey Chan
final version demo of RSS reader, includes topic view, single article view |
102 |
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
103 |
onCurrentIndexChanged: { |
70.1.2
by Roman Shchekin
Little bugs related to article read/unread status are fixed. |
104 |
console.log("ListView onCurrentIndexChanged", currentIndex, preventIndexChangeHandler) |
65.1.1
by Roman Shchekin
"Saved" tab for list mode. |
105 |
if (preventIndexChangeHandler) { |
106 |
preventIndexChangeHandler = false |
|
107 |
return
|
|
108 |
}
|
|
64.1.1
by Joey Chan
New feature: "Saved" simply implemented, include "Saved" tab and related gridview, listview will be implemented by Roman soon |
109 |
rssItem = rssModel.get(currentIndex) |
62.1.1
by Roman Shchekin
Set of minor changes, like: |
110 |
rssTitle = rssItem.feed_name |
70.1.2
by Roman Shchekin
Little bugs related to article read/unread status are fixed. |
111 |
|
112 |
if (rssItem.status != "1") { |
|
113 |
var dbResult = DB.updateArticleStatus(rssItem.id, "1") |
|
114 |
if (dbResult.rowsAffected == 1) { |
|
115 |
rssItem.status = "1" |
|
116 |
}
|
|
62.1.1
by Roman Shchekin
Set of minor changes, like: |
117 |
}
|
13.1.7
by Joey Chan
final version demo of RSS reader, includes topic view, single article view |
118 |
}
|
6.1.1
by Joey Chan
add my first into current trunk, click the back button in the bottom bar can go back to current trunk version |
119 |
}
|
120 |
||
121 |
////////////////////////////////////////////// delegate for ListView
|
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
122 |
Component { |
123 |
id: xmlDelegate
|
|
6.1.1
by Joey Chan
add my first into current trunk, click the back button in the bottom bar can go back to current trunk version |
124 |
|
20.1.1
by Roman Shchekin
Few little bugs fixed. |
125 |
Flickable { |
126 |
id: scrollArea
|
|
127 |
||
128 |
clip: true |
|
129 |
||
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
130 |
width: rssListview.width |
131 |
height: rssListview.height |
|
6.1.1
by Joey Chan
add my first into current trunk, click the back button in the bottom bar can go back to current trunk version |
132 |
|
20.1.1
by Roman Shchekin
Few little bugs fixed. |
133 |
contentWidth: width |
134 |
contentHeight: innerAreaColumn.height |
|
135 |
||
136 |
Column { |
|
137 |
id: innerAreaColumn
|
|
138 |
||
139 |
spacing: units.gu(2) |
|
140 |
width: parent.width |
|
141 |
||
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
142 |
Label { |
27.1.1
by Joey Chan
alpha-1 release |
143 |
id: label_time
|
57.1.2
by Joey Chan
all grid items now sort by time value |
144 |
text: DateUtils.formatRelativeTime(i18n, pubdate) |
27.1.1
by Joey Chan
alpha-1 release |
145 |
fontSize: "small" |
146 |
anchors.horizontalCenter: parent.horizontalCenter |
|
147 |
width: parent.width - units.gu(4) |
|
148 |
}
|
|
149 |
||
20.1.1
by Roman Shchekin
Few little bugs fixed. |
150 |
Label { |
151 |
fontSize: "large" |
|
55.1.1
by Joey Chan
what's new: |
152 |
text: title |
20.1.1
by Roman Shchekin
Few little bugs fixed. |
153 |
anchors.horizontalCenter: parent.horizontalCenter |
154 |
width: parent.width - units.gu(4) |
|
155 |
wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
|
156 |
}
|
|
157 |
||
158 |
Label { |
|
55.1.1
by Joey Chan
what's new: |
159 |
text: content |
51.2.1
by Roman Shchekin
Fix for https://bugs.launchpad.net/ubuntu-rssreader-app/+bug/1217359. |
160 |
linkColor: UbuntuColors.orange // Temporary. Mb bad color, but better than dark blue. |
20.1.1
by Roman Shchekin
Few little bugs fixed. |
161 |
anchors.horizontalCenter: parent.horizontalCenter |
162 |
width: parent.width - units.gu(4) |
|
163 |
wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
|
164 |
clip: true |
|
27.1.1
by Joey Chan
alpha-1 release |
165 |
}
|
20.1.1
by Roman Shchekin
Few little bugs fixed. |
166 |
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
167 |
Label { |
27.1.1
by Joey Chan
alpha-1 release |
168 |
id: label_feedname
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
169 |
text: rssTitle |
27.1.1
by Joey Chan
alpha-1 release |
170 |
fontSize: "small" |
171 |
anchors.horizontalCenter: parent.horizontalCenter |
|
172 |
width: parent.width - units.gu(4) |
|
173 |
wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
|
6.1.1
by Joey Chan
add my first into current trunk, click the back button in the bottom bar can go back to current trunk version |
174 |
}
|
175 |
}
|
|
29.1.1
by Roman Shchekin
A lot of little fixes of careless mistakes. |
176 |
} // Flickable |
177 |
} // Component |
|
6.1.1
by Joey Chan
add my first into current trunk, click the back button in the bottom bar can go back to current trunk version |
178 |
}
|