PageRenderTime 179ms CodeModel.GetById 96ms app.highlight 12ms RepoModel.GetById 69ms app.codeStats 0ms

/src/libtomahawk/Artist.h

http://github.com/tomahawk-player/tomahawk
C Header | 147 lines | 90 code | 39 blank | 18 comment | 0 complexity | 58f8a290a36a2ac99edb3e5696a279d8 MD5 | raw file
  1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2 *
  3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4 *   Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
  5 *
  6 *   Tomahawk is free software: you can redistribute it and/or modify
  7 *   it under the terms of the GNU General Public License as published by
  8 *   the Free Software Foundation, either version 3 of the License, or
  9 *   (at your option) any later version.
 10 *
 11 *   Tomahawk 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.
 15 *
 16 *   You should have received a copy of the GNU General Public License
 17 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 18 */
 19
 20#ifndef TOMAHAWKARTIST_H
 21#define TOMAHAWKARTIST_H
 22
 23#include <QFuture>
 24#include <QPixmap>
 25
 26#include "TrackData.h"
 27#include "Typedefs.h"
 28#include "DllMacro.h"
 29#include "Query.h"
 30
 31namespace Tomahawk
 32{
 33
 34class IdThreadWorker;
 35
 36class DLLEXPORT Artist : public QObject
 37{
 38Q_OBJECT
 39
 40public:
 41    static artist_ptr get( const QString& name, bool autoCreate = false );
 42    static artist_ptr get( unsigned int id, const QString& name );
 43
 44    Artist( unsigned int id, const QString& name );
 45    explicit Artist( const QString& name );
 46    virtual ~Artist();
 47
 48    unsigned int id() const;
 49    QString name() const { return m_name; }
 50    QString sortname() const { return m_sortname; }
 51
 52    QList<album_ptr> albums( ModelMode mode = Mixed, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() ) const;
 53    QList<artist_ptr> similarArtists() const;
 54
 55    QList<Tomahawk::query_ptr> tracks( ModelMode mode = Mixed, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
 56    Tomahawk::playlistinterface_ptr playlistInterface( ModelMode mode, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
 57
 58    void loadStats();
 59    QList< Tomahawk::PlaybackLog > playbackHistory( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() ) const;
 60    void setPlaybackHistory( const QList< Tomahawk::PlaybackLog >& playbackData );
 61    unsigned int playbackCount( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() ) const;
 62
 63    unsigned int chartPosition() const;
 64    unsigned int chartCount() const;
 65
 66    QString biography() const;
 67
 68    QPixmap cover( const QSize& size, bool forceLoad = true ) const;
 69    bool coverLoaded() const { return m_coverLoaded; }
 70
 71    Tomahawk::playlistinterface_ptr playlistInterface();
 72
 73    QWeakPointer< Tomahawk::Artist > weakRef() { return m_ownRef; }
 74    void setWeakRef( const QWeakPointer< Tomahawk::Artist >& weakRef ) { m_ownRef = weakRef; }
 75
 76    void loadId( bool autoCreate );
 77
 78public slots:
 79    void deleteLater();
 80
 81signals:
 82    void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
 83    void albumsAdded( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
 84
 85    void updated();
 86    void coverChanged();
 87    void similarArtistsLoaded();
 88    void biographyLoaded();
 89    void statsLoaded();
 90
 91private slots:
 92    void onArtistStatsLoaded( unsigned int plays, unsigned int chartPos, unsigned int chartCount );
 93    void onTracksLoaded( Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
 94    void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, const QVariant& collectionIsNull = QVariant( false ) );
 95
 96    void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
 97    void infoSystemFinished( QString target );
 98
 99private:
100    Artist();
101    QString infoid() const;
102
103    void setIdFuture( QFuture<unsigned int> idFuture );
104
105    mutable bool m_waitingForFuture;
106    mutable QFuture<unsigned int> m_idFuture;
107    mutable unsigned int m_id;
108
109    QString m_name;
110    QString m_sortname;
111
112    bool m_coverLoaded;
113    mutable bool m_coverLoading;
114    QHash<Tomahawk::ModelMode, bool> m_albumsLoaded;
115    bool m_simArtistsLoaded;
116    bool m_biographyLoaded;
117
118    mutable QString m_uuid;
119    mutable int m_infoJobs;
120
121    QList<Tomahawk::album_ptr> m_databaseAlbums;
122    QList<Tomahawk::album_ptr> m_officialAlbums;
123    QList<Tomahawk::artist_ptr> m_similarArtists;
124    QString m_biography;
125
126    QList< PlaybackLog > m_playbackHistory;
127    unsigned int m_chartPosition;
128    unsigned int m_chartCount;
129
130    mutable QByteArray m_coverBuffer;
131    mutable QPixmap* m_cover;
132
133    QHash< Tomahawk::ModelMode, QHash< Tomahawk::collection_ptr, Tomahawk::playlistinterface_ptr > > m_playlistInterface;
134
135    QWeakPointer< Tomahawk::Artist > m_ownRef;
136
137    static QHash< QString, artist_wptr > s_artistsByName;
138    static QHash< unsigned int, artist_wptr > s_artistsById;
139
140    friend class IdThreadWorker;
141};
142
143} // ns
144
145Q_DECLARE_METATYPE( Tomahawk::artist_ptr )
146
147#endif