1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* Copyright (C) 2013, 2014
* Andrew Hayzen <ahayzen@gmail.com>
* Daniel Holm <d.holmen@gmail.com>
* Victor Thompson <victor.thompson@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.3
import QtQuick.LocalStorage 2.0
import "meta-database.js" as Library
import "playlists.js" as Playlists
Item {
id: libraryListModelItem
property alias count: libraryModel.count
property ListModel model : ListModel {
id: libraryModel
property var linkLibraryListModel: libraryListModelItem
}
property var param: null
property var query: null
/* Pretent to be like a mediascanner2 listmodel */
property alias rowCount: libraryModel.count
property alias canLoad: worker.canLoad
property alias preLoadComplete: worker.preLoadComplete
property alias syncFactor: worker.syncFactor
property alias workerComplete: worker.completed
function get(index, role) {
return model.get(index);
}
WorkerModelLoader {
id: worker
model: libraryListModelItem.model
}
function indexOf(file)
{
file = file.toString();
if (file.indexOf("file://") == 0)
{
file = file.slice(7, file.length)
}
for (var i=0; i < model.count; i++)
{
if (model.get(i).file == file)
{
return i;
}
}
return -1;
}
function filterPlaylists() {
console.log("called LibraryListModel::filterPlaylist()")
// Save query for queue
query = Playlists.getPlaylists
param = null
worker.list = Playlists.getPlaylists();
}
function filterPlaylistTracks(playlist) {
console.log("called LibraryListModel::filterPlaylistTracks()")
// Save query for queue
query = Playlists.getPlaylistTracks
param = playlist
worker.list = Playlists.getPlaylistTracks(playlist);
}
function filterRecent() {
console.log("called LibraryListModel::filterRecent()")
// Save query for queue
query = Library.getRecent
param = null
worker.list = Library.getRecent();
}
}
|