~ps-jenkins/mediascanner2/trusty-proposed

« back to all changes in this revision

Viewing changes to src/qml/Ubuntu/MediaScanner/AlbumsModel.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 "AlbumsModel.hh"
 
21
 
 
22
using namespace mediascanner::qml;
 
23
 
 
24
AlbumsModel::AlbumsModel(QObject *parent)
 
25
    : AlbumModelBase(parent),
 
26
      store(nullptr),
 
27
      artist(""),
 
28
      album_artist(""),
 
29
      limit(-1) {
 
30
}
 
31
 
 
32
MediaStoreWrapper *AlbumsModel::getStore() {
 
33
    return store;
 
34
}
 
35
 
 
36
void AlbumsModel::setStore(MediaStoreWrapper *store) {
 
37
    if (this->store != store) {
 
38
        this->store = store;
 
39
        update();
 
40
    }
 
41
}
 
42
 
 
43
QString AlbumsModel::getArtist() {
 
44
    return artist;
 
45
}
 
46
 
 
47
void AlbumsModel::setArtist(const QString artist) {
 
48
    if (this->artist != artist) {
 
49
        this->artist = artist;
 
50
        update();
 
51
    }
 
52
}
 
53
 
 
54
QString AlbumsModel::getAlbumArtist() {
 
55
    return album_artist;
 
56
}
 
57
 
 
58
void AlbumsModel::setAlbumArtist(const QString album_artist) {
 
59
    if (this->album_artist != album_artist) {
 
60
        this->album_artist = album_artist;
 
61
        update();
 
62
    }
 
63
}
 
64
 
 
65
int AlbumsModel::getLimit() {
 
66
    return limit;
 
67
}
 
68
 
 
69
void AlbumsModel::setLimit(int limit) {
 
70
    if (this->limit != limit) {
 
71
        this->limit = limit;
 
72
        update();
 
73
    }
 
74
}
 
75
 
 
76
void AlbumsModel::update() {
 
77
    if (store == nullptr) {
 
78
        updateResults(std::vector<mediascanner::Album>());
 
79
    } else {
 
80
        updateResults(store->store.listAlbums(artist.toStdString(), album_artist.toStdString(), limit));
 
81
    }
 
82
}