added longpress menu on feeditems view

This commit is contained in:
Hauke Schade 2012-11-29 22:02:42 +01:00
parent 502351603b
commit abeae86696
3 changed files with 49 additions and 17 deletions

View file

@ -118,7 +118,7 @@ Page {
onClicked: {
starloading = true
var ttrss = rootWindow.getTTRSS()
ttrss.updateFeedStar(feedId, articleId, !marked, markedCallback)
ttrss.updateFeedStar(articleId, !marked, markedCallback)
} }
BusyIndicator {
visible: unreadloading
@ -131,7 +131,7 @@ Page {
onClicked: {
unreadloading = true
var ttrss = rootWindow.getTTRSS()
ttrss.updateFeedUnread(feedId, articleId, !unread, unreadCallback)
ttrss.updateFeedUnread(articleId, !unread, unreadCallback)
} }
ToolIcon {
iconId: "toolbar-jump-to";

View file

@ -86,6 +86,11 @@ Page {
id: mouseArea
anchors.fill: background
onClicked: { showFeedItem(model.id, feedId, model.title) }
onPressAndHold: {
feeditemMenu.unread = model.unread
feeditemMenu.marked = model.marked
feeditemMenu.articleId = model.id
feeditemMenu.open() }
}
}
}
@ -121,14 +126,14 @@ Page {
itemListModel.clear();
loading = false;
if (feeditems && feeditems.length) {
for(var feeditem = 0; feeditem < feeditems.length; feeditem++) {
itemListModel.append({
title: ttrss.html_entity_decode(feeditems[feeditem].title, 'ENT_QUOTES'),
subtitle: "subtitle",
id: feeditems[feeditem].id,
unread: !!feeditems[feeditem].unread,
title: ttrss.html_entity_decode(feeditems[feeditem].title, 'ENT_QUOTES'),
subtitle: "subtitle",
id: feeditems[feeditem].id,
unread: !!feeditems[feeditem].unread,
marked: !!feeditems[feeditem].marked
});
}
}
@ -138,6 +143,7 @@ Page {
subtitle: "",
id: null,
unread: false,
marked: false
});
}
}
@ -213,4 +219,34 @@ Page {
}
}
}
Menu {
id: feeditemMenu
visualParent: pageStack
property bool marked: false
property bool unread: false
property int articleId: 0
MenuLayout {
MenuItem {
text: (feeditemMenu.marked?qsTr("Unstar"):qsTr("Star"))
onClicked: {
var ttrss = rootWindow.getTTRSS()
ttrss.updateFeedStar(articleId, !marked, markedCallback)
} }
MenuItem {
text: (feeditemMenu.unread?qsTr("Mark read"):qsTr("Mark Unread"))
onClicked: {
var ttrss = rootWindow.getTTRSS()
ttrss.updateFeedUnread(articleId, !unread, unreadCallback)
} }
MenuItem {
text: qsTr("Open in Web Browser")
enabled: url && (url != "")
onClicked: {
Qt.openUrlExternally(url);
} }
}
}
}

View file

@ -465,8 +465,7 @@ function processPendingRequests(callback) {
//Get the auth token
login(callback);
else
updateFeedStar(state['lastfeeditem']['feedId'],
state['lastfeeditem']['articleId'],
updateFeedStar(state['lastfeeditem']['articleId'],
state['lastfeeditem']['value'],
callback);
}
@ -479,8 +478,7 @@ function processPendingRequests(callback) {
//Get the auth token
login(callback);
else
updateFeedUnrad(state['lastfeeditemunread']['feedId'],
state['lastfeeditemunread']['articleId'],
updateFeedUnrad(state['lastfeeditemunread']['articleId'],
state['lastfeeditemunread']['value'],
callback);
}
@ -488,12 +486,11 @@ function processPendingRequests(callback) {
return foundWork;
}
function updateFeedStar(feedId, articleId, starred, callback) {
function updateFeedStar(articleId, starred, callback) {
if(responsesPending['feeditemstar'])
return;
if (state['lastfeeditem']['feedId'] !== feedId || state['lastfeeditem']['articleId'] !== articleId) {
state['lastfeeditem']['feedId'] = feedId;
if (state['lastfeeditem']['articleId'] !== articleId) {
state['lastfeeditem']['articleId'] = articleId;
state['lastfeeditem']['value'] = starred;
}
@ -534,12 +531,11 @@ function updateFeedStar(feedId, articleId, starred, callback) {
http.send(JSON.stringify(params));
}
function updateFeedUnread(feedId, articleId, unread, callback) {
function updateFeedUnread(articleId, unread, callback) {
if(responsesPending['feeditemunread'])
return;
if (state['lastfeeditemunread']['feedId'] !== feedId || state['lastfeeditemunread']['articleId'] !== articleId) {
state['lastfeeditemunread']['feedId'] = feedId;
if (state['lastfeeditemunread']['articleId'] !== articleId) {
state['lastfeeditemunread']['articleId'] = articleId;
state['lastfeeditemunread']['value'] = unread;
}