~ps-jenkins/mediascanner2/trusty-proposed

« back to all changes in this revision

Viewing changes to src/qml/Ubuntu/MediaScanner/SongsModel.cc

  • Committer: CI bot
  • Author(s): James Henstridge
  • Date: 2014-03-07 17:40:02 UTC
  • mfrom: (211.1.7 megamerge)
  • Revision ID: ps-jenkins@lists.canonical.com-20140307174002-udfe610ez85ixbik
Merge  lp:~jamesh/mediascanner2/qml-plugin,  lp:~jamesh/mediascanner2/short-searches,  lp:~jpakkane/mediascanner2/errmsg, lp:~jpakkane/mediascanner2/cleanshutdown,  lp:~jpakkane/mediascanner2/threadness and lp:~jamesh/mediascanner2/glib-main-loop 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2014 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *    James Henstridge <james.henstridge@canonical.com>
 
6
 *
 
7
 * This program is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU Lesser General Public License version 3 as
 
9
 * published by the Free Software Foundation.
 
10
 *
 
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 Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include "SongsModel.hh"
 
21
 
 
22
using namespace mediascanner::qml;
 
23
 
 
24
SongsModel::SongsModel(QObject *parent)
 
25
    : MediaFileModelBase(parent),
 
26
      store(nullptr),
 
27
      artist(""),
 
28
      album(""),
 
29
      album_artist(""),
 
30
      limit(-1) {
 
31
}
 
32
 
 
33
MediaStoreWrapper *SongsModel::getStore() {
 
34
    return store;
 
35
}
 
36
 
 
37
void SongsModel::setStore(MediaStoreWrapper *store) {
 
38
    if (this->store != store) {
 
39
        this->store = store;
 
40
        update();
 
41
    }
 
42
}
 
43
 
 
44
QString SongsModel::getArtist() {
 
45
    return artist;
 
46
}
 
47
 
 
48
void SongsModel::setArtist(const QString artist) {
 
49
    if (this->artist != artist) {
 
50
        this->artist = artist;
 
51
        update();
 
52
    }
 
53
}
 
54
 
 
55
QString SongsModel::getAlbum() {
 
56
    return album;
 
57
}
 
58
 
 
59
void SongsModel::setAlbum(const QString album) {
 
60
    if (this->album != album) {
 
61
        this->album = album;
 
62
        update();
 
63
    }
 
64
}
 
65
 
 
66
QString SongsModel::getAlbumArtist() {
 
67
    return album_artist;
 
68
}
 
69
 
 
70
void SongsModel::setAlbumArtist(const QString album_artist) {
 
71
    if (this->album_artist != album_artist) {
 
72
        this->album_artist = album_artist;
 
73
        update();
 
74
    }
 
75
}
 
76
 
 
77
int SongsModel::getLimit() {
 
78
    return limit;
 
79
}
 
80
 
 
81
void SongsModel::setLimit(int limit) {
 
82
    if (this->limit != limit) {
 
83
        this->limit = limit;
 
84
        update();
 
85
    }
 
86
}
 
87
 
 
88
void SongsModel::update() {
 
89
    if (store == nullptr) {
 
90
        updateResults(std::vector<mediascanner::MediaFile>());
 
91
    } else {
 
92
        updateResults(store->store.listSongs(artist.toStdString(), album.toStdString(), album_artist.toStdString(), limit));
 
93
    }
 
94
}