~music-app-dev/music-app/remix

« back to all changes in this revision

Viewing changes to MusicTracks.qml

* Refactor ColumnFlow so that it uses insert/removes instead of resetting the view
* Add search support to MusicAlbums.qml MusicArtists.qml MusicGenres.qml MusicPlaylists.qml MusicTracks.qml MusicaddtoPlaylist.qml
* Remove any references to sheets as they have been removed. Fixes: https://bugs.launchpad.net/bugs/1297253, https://bugs.launchpad.net/bugs/1301893, https://bugs.launchpad.net/bugs/1332877, https://bugs.launchpad.net/bugs/1342928.

Approved by Victor Thompson, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2013, 2014
 
2
 * Copyright (C) 2013, 2014, 2015
3
3
 *      Andrew Hayzen <ahayzen@gmail.com>
4
4
 *      Daniel Holm <d.holmen@gmail.com>
5
5
 *      Victor Thompson <victor.thompson@gmail.com>
29
29
 
30
30
 
31
31
MusicPage {
32
 
    id: mainpage
 
32
    id: tracksPage
33
33
    objectName: "tracksPage"
34
34
    title: i18n.tr("Songs")
35
 
 
36
 
    state: tracklist.state === "multiselectable" ? "selection" : "default"
 
35
    searchable: true
 
36
    searchResultsCount: songsModelFilter.count
 
37
    state: "default"
37
38
    states: [
38
39
        PageHeadState {
 
40
            name: "default"
 
41
            head: tracksPage.head
 
42
            actions: Action {
 
43
                iconName: "search"
 
44
                onTriggered: tracksPage.state = "search"
 
45
            }
 
46
        },
 
47
        PageHeadState {
39
48
            id: selectionState
40
49
            name: "selection"
41
50
            backAction: Action {
46
55
                    tracklist.state = "normal"
47
56
                }
48
57
            }
 
58
            head: tracksPage.head
49
59
            actions: [
50
60
                Action {
51
61
                    iconName: "select"
94
104
                    }
95
105
                }
96
106
            ]
97
 
            PropertyChanges {
98
 
                target: mainpage.head
99
 
                backAction: selectionState.backAction
100
 
                actions: selectionState.actions
101
 
            }
 
107
        },
 
108
        SearchHeadState {
 
109
            id: searchHeader
 
110
            thisPage: tracksPage
102
111
        }
103
112
    ]
104
113
 
121
130
            sort.property: "title"
122
131
            sort.order: Qt.AscendingOrder
123
132
            sortCaseSensitivity: Qt.CaseInsensitive
 
133
            filter.property: "title"
 
134
            filter.pattern: new RegExp(searchHeader.query, "i")
 
135
            filterCaseSensitivity: Qt.CaseInsensitive
124
136
        }
125
137
 
126
138
        Component.onCompleted: {
143
155
            clearSelection()
144
156
            state = "normal"
145
157
        }
 
158
        onStateChanged: {
 
159
            if (state === "multiselectable") {
 
160
                tracksPage.state = "selection"
 
161
            } else {
 
162
                searchHeader.query = ""  // force query back to default
 
163
                tracksPage.state = "default"
 
164
            }
 
165
        }
 
166
 
146
167
        onSelectAll: {
147
168
            var tmp = selectedItems
148
169
 
178
199
                    }
179
200
                ]
180
201
 
181
 
                onItemClicked: trackClicked(tracklist.model, index)  // play track
 
202
                onItemClicked: {
 
203
                    if (tracksPage.state === "search") {  // only play single track when searching
 
204
                        trackQueue.clear()
 
205
                        trackQueue.append(songsModelFilter.get(index))
 
206
                        trackQueueClick(0)
 
207
                    } else {
 
208
                        trackClicked(songsModelFilter, index)  // play track
 
209
                    }
 
210
                }
182
211
 
183
212
                MusicRow {
184
213
                    id: musicRow