2
* Copyright (C) 2014 Canonical, Ltd.
5
* James Henstridge <james.henstridge@canonical.com>
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.
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.
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/>.
20
#include "ArtistsModel.hh"
22
using namespace mediascanner::qml;
24
ArtistsModel::ArtistsModel(QObject *parent)
25
: QAbstractListModel(parent),
29
roles[Roles::RoleArtist] = "artist";
32
int ArtistsModel::rowCount(const QModelIndex &) const {
33
return results.size();
36
QVariant ArtistsModel::data(const QModelIndex &index, int role) const {
37
if (index.row() < 0 || index.row() >= (ptrdiff_t)results.size()) {
42
return QString::fromStdString(results[index.row()]);
48
QHash<int, QByteArray> ArtistsModel::roleNames() const {
52
MediaStoreWrapper *ArtistsModel::getStore() {
56
void ArtistsModel::setStore(MediaStoreWrapper *store) {
57
if (this->store != store) {
63
bool ArtistsModel::getAlbumArtists() {
67
void ArtistsModel::setAlbumArtists(bool album_artists) {
68
if (this->album_artists != album_artists) {
69
this->album_artists = album_artists;
74
int ArtistsModel::getLimit() {
78
void ArtistsModel::setLimit(int limit) {
79
if (this->limit != limit) {
85
void ArtistsModel::update() {
87
if (store == nullptr) {
88
this->results.clear();
90
this->results = store->store.listArtists(album_artists, limit);
92
this->results = results;