added a basic feeditem view
This commit is contained in:
parent
5482a9fe81
commit
e9cdfeaf84
3 changed files with 132 additions and 5 deletions
108
qml/ttrss/FeedItem.qml
Normal file
108
qml/ttrss/FeedItem.qml
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
//Copyright Hauke Schade, 2012
|
||||
//
|
||||
//This file is part of TTRss.
|
||||
//
|
||||
//TTRss is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
|
||||
//Free Software Foundation, either version 2 of the License, or (at your option) any later version.
|
||||
//TTRss is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//You should have received a copy of the GNU General Public License along with TTRss (on a Maemo/Meego system there is a copy
|
||||
//in /usr/share/common-licenses. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
import QtQuick 1.1
|
||||
import com.nokia.meego 1.0
|
||||
import QtWebKit 1.0
|
||||
|
||||
Page {
|
||||
id: itemPage
|
||||
tools: itemTools
|
||||
property string feedId: ""
|
||||
property string articleId: ""
|
||||
property string pageTitle: ""
|
||||
property string url: ""
|
||||
property bool loading: false
|
||||
property bool marked: false
|
||||
|
||||
anchors.margins: 0
|
||||
|
||||
Flickable {
|
||||
id: flick
|
||||
width: parent.width;
|
||||
height: parent.height
|
||||
contentWidth: itemView.width
|
||||
contentHeight: itemView.height
|
||||
interactive: true
|
||||
clip: true
|
||||
anchors{ top: pageHeader.bottom; bottom: parent.bottom; left: parent.left; right: parent.right }
|
||||
|
||||
signal newWindowRequested(string url)
|
||||
|
||||
WebView {
|
||||
id: itemView
|
||||
transformOrigin: Item.TopLeft
|
||||
settings.standardFontFamily: "Arial"
|
||||
settings.defaultFontSize: 22
|
||||
preferredWidth: flick.width
|
||||
preferredHeight: flick.height
|
||||
}
|
||||
}
|
||||
|
||||
ScrollDecorator {
|
||||
flickableItem: flick
|
||||
}
|
||||
|
||||
function showFeedItem() {
|
||||
var ttrss = rootWindow.getTTRSS();
|
||||
numStatusUpdates = ttrss.getNumStatusUpdates();
|
||||
var data = ttrss.getFeedItem(feedId, articleId);
|
||||
// var dataFeed = ttrss.getFeed(feedId);
|
||||
|
||||
if (data) {
|
||||
itemView.html = data.content;
|
||||
url = data.link
|
||||
pageTitle = data.title
|
||||
}
|
||||
}
|
||||
|
||||
onArticleIdChanged: {
|
||||
showFeedItem();
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
showFeedItem();
|
||||
}
|
||||
|
||||
PageHeader {
|
||||
id: pageHeader
|
||||
text: pageTitle
|
||||
}
|
||||
|
||||
ToolBarLayout {
|
||||
id: itemTools
|
||||
|
||||
ToolIcon { iconId: "toolbar-back"; onClicked: { itemMenu.close(); pageStack.pop(); } }
|
||||
ToolIcon { iconId: "toolbar-favorite-"+(marked?"":"un")+"mark"; onClicked: { marked = !marked } }
|
||||
ToolIcon { iconId: "toolbar-share"; onClicked: { } }
|
||||
|
||||
BusyIndicator {
|
||||
visible: loading
|
||||
running: loading
|
||||
platformStyle: BusyIndicatorStyle { size: 'medium' }
|
||||
}
|
||||
ToolIcon { iconId: "toolbar-view-menu" ; onClicked: (itemMenu.status === DialogStatus.Closed) ? itemMenu.open() : itemMenu.close() }
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: itemMenu
|
||||
visualParent: pageStack
|
||||
|
||||
MenuLayout {
|
||||
MenuItem {
|
||||
text: qsTr("About")
|
||||
onClicked: {
|
||||
rootWindow.openFile("About.qml");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -88,9 +88,7 @@ Page {
|
|||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: background
|
||||
onClicked: {
|
||||
//TODO open item view with this item
|
||||
}
|
||||
onClicked: { showFeedItem(model.id, feedId, model.title) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -98,6 +96,21 @@ Page {
|
|||
flickableItem: listView
|
||||
}
|
||||
|
||||
function showFeedItem(articleId, feedId, title) {
|
||||
if(articleId != null && feedId != null) {
|
||||
console.log("Loading items for "+articleId+" in "+feedId+"\n");
|
||||
var component = Qt.createComponent("FeedItem.qml");
|
||||
if (component.status === Component.Ready)
|
||||
pageStack.push(component, {
|
||||
articleId: articleId,
|
||||
feedId: feedId,
|
||||
pageTitle: title
|
||||
});
|
||||
else
|
||||
console.log("Error loading component:", component.errorString());
|
||||
}
|
||||
}
|
||||
|
||||
function updateFeedItems() {
|
||||
loading = true;
|
||||
var ttrss = rootWindow.getTTRSS();
|
||||
|
|
@ -112,7 +125,7 @@ Page {
|
|||
itemListModel.clear();
|
||||
|
||||
loading = false;
|
||||
ttrss.trace(2, ttrss.dump(feeditems))
|
||||
|
||||
if (!ttrss.isEmpty(feeditems)) {
|
||||
for(var feeditem in feeditems) {
|
||||
itemListModel.append({
|
||||
|
|
|
|||
|
|
@ -325,7 +325,6 @@ function updateFeedItems(feedId, callback) {
|
|||
'view_mode': (state['showall'] ? 'all_articles' : 'unread'),
|
||||
'skip': state['lastfeed']['continuation']
|
||||
}
|
||||
trace(2, 'request: ' + dump(params))
|
||||
|
||||
var http = new XMLHttpRequest();
|
||||
http.open("POST", state['url'], true);
|
||||
|
|
@ -462,3 +461,10 @@ function getFeeds(catId) {
|
|||
function getFeedItems(feedId) {
|
||||
return state['feeditems'][feedId];
|
||||
}
|
||||
|
||||
function getFeedItem(feedId, articleId) {
|
||||
if (state['feeditems'][feedId])
|
||||
return state['feeditems'][feedId][articleId]
|
||||
else
|
||||
console.log("no cache found")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue