Skip to content

Commit

Permalink
Disable multi-selection unusable actions - refs Kernald#7
Browse files Browse the repository at this point in the history
  • Loading branch information
Kernald committed Nov 4, 2013
1 parent cf0e40d commit 2520afc
Showing 1 changed file with 94 additions and 57 deletions.
151 changes: 94 additions & 57 deletions assets/ArticlesListPage/ArticlesListPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,75 +17,81 @@ Page {

multiSelectHandler {
status: qsTr("None selected")
actions: [
actions: [
ActionItem {
id: actionMultiRead
title: qsTr("Mark as read")
imageSource: "asset:///images/mark_as_read.png"

onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
for (var i = 0; i < selectionList.length; ++i)
_articleModel.data(selectionList[i]).unread = false;
_articleModel.data(selectionList[i]).unread = false;
}
},
},
ActionItem {
id: actionMultiUnread
title: qsTr("Keep unread")
imageSource: "asset:///images/keep_unread.png"

onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
imageSource: "asset:///images/keep_unread.png"
onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
for (var i = 0; i < selectionList.length; ++ i)
_articleModel.data(selectionList[i]).unread = true;
}
},

ActionItem {
title: qsTr("Publish")
imageSource: "asset:///images/publish.png"

onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
_articleModel.data(selectionList[i]).unread = true;
}
},

ActionItem {
id: actionMultiPublish
title: qsTr("Publish")
imageSource: "asset:///images/publish.png"

onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
for (var i = 0; i < selectionList.length; ++ i)
_articleModel.data(selectionList[i]).published = true;
}
},
ActionItem {
title: qsTr("Unpublish")
imageSource: "asset:///images/unpublish.png"

onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
_articleModel.data(selectionList[i]).published = true;
}
},
ActionItem {
id: actionMultiUnpublish
title: qsTr("Unpublish")
imageSource: "asset:///images/unpublish.png"

onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
for (var i = 0; i < selectionList.length; ++ i)
_articleModel.data(selectionList[i]).published = false;
}
},

ActionItem {
title: qsTr("Star")
imageSource: "asset:///images/star.png"

onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
_articleModel.data(selectionList[i]).published = false;
}
},

ActionItem {
id: actionMultiStar
title: qsTr("Star")
imageSource: "asset:///images/star.png"

onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
for (var i = 0; i < selectionList.length; ++ i)
_articleModel.data(selectionList[i]).marked = true;
}
},
ActionItem {
title: qsTr("Unstar")
imageSource: "asset:///images/unstar.png"

onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
_articleModel.data(selectionList[i]).marked = true;
}
},
ActionItem {
id: actionMultiUnstar
title: qsTr("Unstar")
imageSource: "asset:///images/unstar.png"

onTriggered: {
var selectionList = listView.selectionList();
listView.clearSelection();
for (var i = 0; i < selectionList.length; ++ i)
_articleModel.data(selectionList[i]).marked = false;
}
}
_articleModel.data(selectionList[i]).marked = false;
}
}
]
}

Expand All @@ -96,7 +102,38 @@ Page {
multiSelectHandler.status = qsTr("1 item selected");
} else {
multiSelectHandler.status = qsTr("None selected");
}
}

// Update available actions
var starred = false;
var unstarred = false;
var published = false;
var unpublished = false;
var read = false;
var unread = false;
for (var i = 0; i < selectionList().length; ++ i) {
var elt = _articleModel.data(selectionList()[i]);
if (elt.marked)
starred = true;
else
unstarred = true;

if (elt.published)
published = true;
else
unpublished = true;

if (elt.unread)
unread = true;
else
read = true;
}
actionMultiUnstar.enabled = starred;
actionMultiStar.enabled = unstarred;
actionMultiUnpublish.enabled = published;
actionMultiPublish.enabled = unpublished;
actionMultiUnread.enabled = read;
actionMultiRead.enabled = unread;
}

listItemComponents: [
Expand Down

0 comments on commit 2520afc

Please sign in to comment.