QML: Settings, about box, graphics update (bug 1554)
[gpodder.git] / share / gpodder / ui / qml / EpisodeList.qml
blobb53e2c905ead233a6f65929c24ab212895d86349
2 import Qt 4.7
4 import com.nokia.meego 1.0
6 import 'config.js' as Config
8 Item {
9     id: episodeList
10     property string currentFilterText
12     property alias model: listView.model
13     property alias moving: listView.moving
14     property alias count: listView.count
16     signal episodeContextMenu(variant episode)
18     function showFilterDialog() {
19         filterDialog.open();
20     }
22     function resetSelection() {
23         listView.openedIndex = -1
24     }
26     onModelChanged: {
27         filterDialog.resetSelection();
28     }
30     Text {
31         anchors.centerIn: parent
32         color: 'white'
33         font.pixelSize: 30
34         horizontalAlignment: Text.AlignHCenter
35         text: '<big>' + _('No episodes') + '</big>' + '<br><small>' + _('Touch to change filter') + '</small>'
36         visible: !listView.visible
38         MouseArea {
39             anchors.fill: parent
40             onClicked: episodeList.showFilterDialog()
41         }
42     }
44     ListView {
45         id: listView
46         anchors.fill: parent
47         property int openedIndex: -1
48         visible: count > 0
50         delegate: Item {
51             id: listItem
53             height: listItem.opened?(Config.listItemHeight + Config.smallSpacing * 3 + Config.headerHeight):(Config.listItemHeight)
54             width: parent.width
55             property bool opened: (index == listView.openedIndex)
57             Image {
58                 source: 'artwork/episode-background.png'
59                 anchors {
60                     fill: parent
61                     topMargin: 3
62                     bottomMargin: 3
63                 }
64                 visible: listItem.opened
65             }
67             Loader {
68                 id: loader
69                 clip: true
70                 source: listItem.opened?'EpisodeActions.qml':''
72                 Behavior on opacity { PropertyAnimation { } }
74                 opacity: listItem.opened
76                 onItemChanged: {
77                     if (item) {
78                         item.episode = modelData
79                     }
80                 }
82                 anchors {
83                     left: parent.left
84                     right: parent.right
85                     top: parent.top
86                     topMargin: episodeItem.y + episodeItem.height
87                     bottom: parent.bottom
88                 }
90                 width: parent.width
91             }
93             Behavior on height { PropertyAnimation { } }
95             EpisodeItem {
96                 id: episodeItem
97                 y: listItem.opened?Config.smallSpacing:0
98                 width: parent.width
99                 onSelected: {
100                     if (listView.openedIndex == index) {
101                         listView.openedIndex = -1
102                     } else {
103                         listView.openedIndex = index
104                     }
105                 }
106                 onContextMenu: episodeList.episodeContextMenu(item)
108                 Behavior on y { PropertyAnimation { } }
109             }
110         }
111     }
113     ScrollDecorator {
114         flickableItem: listView
115     }
117     SelectionDialog {
118         id: filterDialog
119         titleText: _('Show episodes')
121         function resetSelection() {
122             selectedIndex = episodeList.model.getFilter();
123             accepted();
124         }
126         onAccepted: {
127             episodeList.currentFilterText = model.get(selectedIndex).name;
128             episodeList.model.setFilter(selectedIndex);
129         }
131         model: ListModel {}
133         Component.onCompleted: {
134             var filters = controller.getEpisodeListFilterNames();
136             for (var index in filters) {
137                 model.append({name: filters[index]});
138             }
139         }
140     }