2
license GPL v3 ...........
4
description of this file:
5
a page for viewing a user selected RSS feed ;
10
import QtQuick.XmlListModel 2.0
11
import Ubuntu.Components 1.2
12
import Ubuntu.Components.ListItems 1.0 as ListItem
13
import Ubuntu.Components.Popups 1.0
15
import "../utils/dateutils.js" as DateUtils
16
import "../utils/databasemodule_v2.js" as DB
21
signal articleStatusChanged(int tagId, int articleId, string status)
22
signal articleFavouriteChanged(var article, string favourite)
24
property bool showEmptyPlaceholder: true
25
property bool isEmbeddedMode: false // Deprecated for now.
27
property string feedTitle: ""
28
property var articleModel: null
29
property var modelItem: null
31
property bool __preventIndexChangeHandler: false
33
function setFeed(model, index) {
34
/* Setting new model and not-null index will cause two change events instead of one.
35
* Settings "preventIndexChangeHandler" to true helps to avoid it.
37
if (articleModel != model && index !== 0)
38
__preventIndexChangeHandler = true
43
function setNewIndex(rssIndex) {
44
rssListview.currentIndex = rssIndex
45
rssListview.positionViewAtIndex(rssListview.currentIndex, ListView.Center)
48
function showNextArticle() {
49
var index = rssListview.currentIndex + 1
50
if (index < rssListview.model.count) {
51
rssListview.currentIndex = index
55
function showPrevArticle() {
56
var index = rssListview.currentIndex - 1
58
rssListview.currentIndex = index
63
////////////////////////////////////////////// a listview to show the RSS content
67
property int contentFontSize: optionsKeeper.fontSize()
68
property bool contentDarkTheme: optionsKeeper.useDarkTheme()
73
bottomMargin: units.gu(1)
75
topMargin: units.gu(1)
80
snapMode: ListView.SnapOneItem
81
cacheBuffer: 90 // value in pixels, for what?
82
// boundsBehavior: Flickable.StopAtBounds
83
orientation: ListView.Horizontal
84
contentHeight: parent.width * count
85
highlightFollowsCurrentItem: true
86
highlightMoveVelocity: 1000
87
highlightRangeMode: ListView.StrictlyEnforceRange
90
onCurrentIndexChanged: {
91
console.log("ListView onCurrentIndexChanged", currentIndex, __preventIndexChangeHandler)
93
if (__preventIndexChangeHandler) {
94
__preventIndexChangeHandler = false
98
if (articleModel == null || articleModel.get == undefined) {
99
console.log("---- Stange behavior ----")
104
if (articleModel.count == 0) // It is normal bevaviour.
107
modelItem = articleModel.get(currentIndex)
108
feedTitle = modelItem.feed_name
110
if (modelItem.status != "1") {
111
var dbResult = DB.updateArticleStatus(modelItem.id, "1")
112
if (dbResult.rowsAffected == 1) {
113
articleStatusChanged(modelItem.tagId, modelItem.id, "1")
119
// We want to show it only when view isn't initialized.
120
visible: !articleModel && articleViewRoot.showEmptyPlaceholder
121
anchors.centerIn: parent
122
text: i18n.tr("Select article")
127
////////////////////////////////////////////// delegate for ListView
133
objectName: "articleview_flickable"
137
width: rssListview.width
138
height: rssListview.height
141
contentHeight: innerAreaColumn.height
149
property int mediaDownloadInProgress: 0
151
function mediaDownloaded() {
152
mediaDownloadInProgress = mediaDownloadInProgress - 1
156
width: parent.width - units.gu(4)
157
height: labelTime.paintedHeight
158
anchors.horizontalCenter: parent.horizontalCenter
163
anchors.verticalCenter: labelTime.verticalCenter
164
fillMode: Image.PreserveAspectCrop
165
source: Qt.resolvedUrl("/img/qml/icons/favorite-selected.svg")
166
sourceSize.height: modelItem == null ? 0 : (modelItem.favourite == "1" ? units.gu(2) : 0)
167
visible: modelItem == null ? false : (modelItem.favourite == "1")
173
text: DateUtils.formatRelativeTime(i18n, pubdate)
175
width: parent.width - units.gu(3)
176
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
181
objectName: "articleviewitem_title"
184
anchors.horizontalCenter: parent.horizontalCenter
185
width: parent.width - units.gu(4)
186
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
192
text: model.author ? model.author : ""
193
anchors.horizontalCenter: parent.horizontalCenter
194
width: parent.width - units.gu(4)
195
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
196
visible: text !== "" && text !== '""'
203
switch(rssListview.contentFontSize) {
212
// color: rssListview.contentDarkTheme ? "lightgray" : "white" // TODO BUG design needed
213
linkColor: "lightblue"
214
anchors.horizontalCenter: parent.horizontalCenter
215
width: parent.width - units.gu(4)
216
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
219
onLinkActivated: Qt.openUrlExternally(model.link)
224
text: model.feed_name ? model.feed_name : ""
226
anchors.horizontalCenter: parent.horizontalCenter
227
width: parent.width - units.gu(4)
228
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
236
id: readingOptionsPopoverComponent