/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. #ifndef TOMAHAWKARTIST_H
  20. #define TOMAHAWKARTIST_H
  21. #include <QFuture>
  22. #include <QPixmap>
  23. #include "TrackData.h"
  24. #include "Typedefs.h"
  25. #include "DllMacro.h"
  26. #include "Query.h"
  27. namespace Tomahawk
  28. {
  29. class IdThreadWorker;
  30. class DLLEXPORT Artist : public QObject
  31. {
  32. Q_OBJECT
  33. public:
  34. static artist_ptr get( const QString& name, bool autoCreate = false );
  35. static artist_ptr get( unsigned int id, const QString& name );
  36. Artist( unsigned int id, const QString& name );
  37. explicit Artist( const QString& name );
  38. virtual ~Artist();
  39. unsigned int id() const;
  40. QString name() const { return m_name; }
  41. QString sortname() const { return m_sortname; }
  42. QList<album_ptr> albums( ModelMode mode = Mixed, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() ) const;
  43. QList<artist_ptr> similarArtists() const;
  44. QList<Tomahawk::query_ptr> tracks( ModelMode mode = Mixed, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
  45. Tomahawk::playlistinterface_ptr playlistInterface( ModelMode mode, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
  46. void loadStats();
  47. QList< Tomahawk::PlaybackLog > playbackHistory( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() ) const;
  48. void setPlaybackHistory( const QList< Tomahawk::PlaybackLog >& playbackData );
  49. unsigned int playbackCount( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() ) const;
  50. unsigned int chartPosition() const;
  51. unsigned int chartCount() const;
  52. QString biography() const;
  53. QPixmap cover( const QSize& size, bool forceLoad = true ) const;
  54. bool coverLoaded() const { return m_coverLoaded; }
  55. Tomahawk::playlistinterface_ptr playlistInterface();
  56. QWeakPointer< Tomahawk::Artist > weakRef() { return m_ownRef; }
  57. void setWeakRef( const QWeakPointer< Tomahawk::Artist >& weakRef ) { m_ownRef = weakRef; }
  58. void loadId( bool autoCreate );
  59. public slots:
  60. void deleteLater();
  61. signals:
  62. void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
  63. void albumsAdded( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
  64. void updated();
  65. void coverChanged();
  66. void similarArtistsLoaded();
  67. void biographyLoaded();
  68. void statsLoaded();
  69. private slots:
  70. void onArtistStatsLoaded( unsigned int plays, unsigned int chartPos, unsigned int chartCount );
  71. void onTracksLoaded( Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
  72. void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, const QVariant& collectionIsNull = QVariant( false ) );
  73. void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
  74. void infoSystemFinished( QString target );
  75. private:
  76. Artist();
  77. QString infoid() const;
  78. void setIdFuture( QFuture<unsigned int> idFuture );
  79. mutable bool m_waitingForFuture;
  80. mutable QFuture<unsigned int> m_idFuture;
  81. mutable unsigned int m_id;
  82. QString m_name;
  83. QString m_sortname;
  84. bool m_coverLoaded;
  85. mutable bool m_coverLoading;
  86. QHash<Tomahawk::ModelMode, bool> m_albumsLoaded;
  87. bool m_simArtistsLoaded;
  88. bool m_biographyLoaded;
  89. mutable QString m_uuid;
  90. mutable int m_infoJobs;
  91. QList<Tomahawk::album_ptr> m_databaseAlbums;
  92. QList<Tomahawk::album_ptr> m_officialAlbums;
  93. QList<Tomahawk::artist_ptr> m_similarArtists;
  94. QString m_biography;
  95. QList< PlaybackLog > m_playbackHistory;
  96. unsigned int m_chartPosition;
  97. unsigned int m_chartCount;
  98. mutable QByteArray m_coverBuffer;
  99. mutable QPixmap* m_cover;
  100. QHash< Tomahawk::ModelMode, QHash< Tomahawk::collection_ptr, Tomahawk::playlistinterface_ptr > > m_playlistInterface;
  101. QWeakPointer< Tomahawk::Artist > m_ownRef;
  102. static QHash< QString, artist_wptr > s_artistsByName;
  103. static QHash< unsigned int, artist_wptr > s_artistsById;
  104. friend class IdThreadWorker;
  105. };
  106. } // ns
  107. Q_DECLARE_METATYPE( Tomahawk::artist_ptr )
  108. #endif