Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
QML UI: Selection menu for multi-selector (bug 1463)
The episode multi-action sheet now has got a context
menu that will allow selecting all episodes or just
downloaded episodes. This can be useful for quickly
creating a playlist of e.g. all downloaded episodes
of a podcast.
  • Loading branch information
thp committed Apr 29, 2012
1 parent 581a954 commit 27fd572
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
52 changes: 52 additions & 0 deletions share/gpodder/ui/qml/Main.qml
Expand Up @@ -583,10 +583,62 @@ Image {

multiEpisodesList.selected = newSelection;
}

onContextMenu: multiEpisodesSheetContextMenu.open();
}
}

ScrollDecorator { flickableItem: multiEpisodesList }

ContextMenu {
id: multiEpisodesSheetContextMenu

MenuLayout {
MenuItem {
text: _('Select all')
onClicked: {
var newSelection = [];
for (var i=0; i<multiEpisodesList.count; i++) {
newSelection.push(i);
}
multiEpisodesList.selected = newSelection;
}
}

MenuItem {
text: _('Select downloaded')
onClicked: {
var newSelection = [];
for (var i=0; i<multiEpisodesList.count; i++) {
if (episodeList.model.get_object_by_index(i).qdownloaded) {
newSelection.push(i);
}
}
multiEpisodesList.selected = newSelection;
}
}

MenuItem {
text: _('Select none')
onClicked: {
multiEpisodesList.selected = [];
}
}

MenuItem {
text: _('Invert selection')
onClicked: {
var newSelection = [];
for (var i=0; i<multiEpisodesList.count; i++) {
if (multiEpisodesList.selected.indexOf(i) === -1) {
newSelection.push(i);
}
}
multiEpisodesList.selected = newSelection;
}
}
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/gpodder/qmlui/__init__.py
Expand Up @@ -686,6 +686,7 @@ def get_objects(self):
def get_object(self, index):
return self._filtered[index.row()]

@Slot(int, result=QObject)
def get_object_by_index(self, index):
return self._filtered[index]

Expand Down

0 comments on commit 27fd572

Please sign in to comment.