2
* Copyright (C) 2013, 2014
3
* Andrew Hayzen <ahayzen@gmail.com>
4
* Daniel Holm <d.holmen@gmail.com>
5
* Victor Thompson <victor.thompson@gmail.com>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; version 3.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
import QtMultimedia 5.0
22
import Ubuntu.Components 1.1
23
import Ubuntu.Components.ListItems 1.0 as ListItem
24
import Ubuntu.Components.Popups 1.0
25
import Ubuntu.MediaScanner 0.1
26
import Ubuntu.Thumbnailer 0.1
27
import QtQuick.LocalStorage 2.0
28
import "playlists.js" as Playlists
30
import "common/ListItemActions"
35
property alias sheet: sheetComponent
36
property bool sheetVisible: false
41
// Sheet to search for music tracks
44
title: i18n.tr("Search")
45
contentsHeight: units.gu(80)
47
onDoneClicked: PopupUtils.close(searchTrack)
49
Component.onCompleted: {
50
searchField.forceActiveFocus()
55
musicToolbar.setSheet(searchTrack)
59
musicToolbar.removeSheet(searchTrack)
68
leftMargin: units.gu(2);
71
rightMargin: units.gu(2);
74
width: parent.width/1.5
75
placeholderText: i18n.tr("Search")
79
inputMethodHints: Qt.ImhNoPredictiveText
80
//canPaste: true // why work, you do not, hrm?
84
height: parent.height*0.5
85
width: parent.height*0.5
86
anchors.verticalCenter: parent.verticalCenter
87
anchors.verticalCenterOffset: -units.gu(0.2)
88
source: Qt.resolvedUrl("images/search.svg")
92
searchTimer.start() // start the countdown, baby!
95
// Provide a small pause before search
101
songsSearchModel.query = searchField.text;
102
searchActivity.running = true // start the activity indicator
104
indicatorTimer.start()
107
// and onother one for the indicator
113
searchActivity.running = false
117
// Indicator to show search activity
121
verticalCenter: searchField.verticalCenter;
122
right: searchField.right;
123
rightMargin: units.gu(1)
131
height: parent.height
133
visible: searchField.text
136
top: searchField.bottom
137
bottom: parent.bottom
142
// show each playlist and make them chosable
145
objectName: "searchtrackview"
148
model: SongsSearchModel {
154
searchTrackView.forceActiveFocus()
157
// Requirements for ListItemWithActions
158
property var selectedItems: []
160
signal clearSelection(bool closeSelection)
166
if (closeSelection || closeSelection === undefined) {
171
for (var i=0; i < model.count; i++) {
172
if (selectedItems.indexOf(i) === -1) {
173
selectedItems.push(i)
182
delegate: ListItemWithActions {
185
objectName: "playlist"
187
height: styleMusic.common.itemHeight
199
console.debug("Debug: "+title+" added to queue")
200
// now play this track, but keep current queue
201
trackQueue.append(model)
202
trackQueueClick(trackQueue.model.count - 1);
203
onDoneClicked: PopupUtils.close(searchTrack)
207
covers: [{art: model.art}]
212
color: styleMusic.common.subtitle
218
color: styleMusic.common.music
220
objectName: "tracktitle"
225
color: styleMusic.common.subtitle