PageRenderTime 13ms CodeModel.GetById 2ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/thirdparty/liblastfm2/src/types/Artist.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 105 lines | 51 code | 23 blank | 31 comment | 2 complexity | 7c839e1c3ad299b195aa1b1aa2083473 MD5 | raw file
  1/*
  2   Copyright 2009-2010 Last.fm Ltd.
  3      - Primarily authored by Max Howell, Jono Cole, Doug Mansell and Michael Coffey
  4
  5   This file is part of liblastfm.
  6
  7   liblastfm is free software: you can redistribute it and/or modify
  8   it under the terms of the GNU General Public License as published by
  9   the Free Software Foundation, either version 3 of the License, or
 10   (at your option) any later version.
 11
 12   liblastfm is distributed in the hope that it will be useful,
 13   but WITHOUT ANY WARRANTY; without even the implied warranty of
 14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15   GNU General Public License for more details.
 16
 17   You should have received a copy of the GNU General Public License
 18   along with liblastfm.  If not, see <http://www.gnu.org/licenses/>.
 19*/
 20#ifndef LASTFM_ARTIST_H
 21#define LASTFM_ARTIST_H
 22
 23#include <QMap>
 24#include <QString>
 25#include <QUrl>
 26
 27#include <lastfm/AbstractType>
 28#include <lastfm/global.h>
 29
 30
 31namespace lastfm
 32{
 33    class LASTFM_DLLEXPORT Artist : public AbstractType
 34    {
 35    private:
 36        QString m_name;
 37        QList<QUrl> m_images;
 38
 39    public:
 40        Artist() : AbstractType()
 41        {}
 42
 43        Artist( const QString& name ) : AbstractType(), m_name( name )
 44        {}
 45
 46        Artist( const class XmlQuery& xml );
 47
 48        /** will be QUrl() unless you got this back from a getInfo or something call */
 49        QUrl imageUrl( ImageSize size = Large, bool square = false ) const;
 50
 51        bool isNull() const { return m_name.isEmpty(); }
 52
 53        /** the url for this artist's page at www.last.fm */
 54        QUrl www() const;
 55
 56        Artist& operator=( const Artist& that ) { m_name = that.name(); m_images = that.m_images; return *this; }
 57        bool operator==( const Artist& that ) const { return m_name == that.m_name; }
 58        bool operator!=( const Artist& that ) const { return m_name != that.m_name; }
 59        bool operator<( const Artist& that ) const { return m_name < that.m_name; }
 60
 61        operator QString() const
 62        {
 63            /** if no artist name is set, return the musicbrainz unknown identifier
 64              * in case some part of the GUI tries to display it anyway. Note isNull
 65              * returns false still. So you should have queried that! */
 66            return m_name.isEmpty() ? "[unknown]" : m_name;
 67        }
 68
 69        QString toString() const { return name(); }
 70        QString name() const { return QString(*this); }
 71
 72        QDomElement toDomElement( QDomDocument& ) const { return QDomElement(); }
 73
 74        QNetworkReply* share( const QStringList& recipients, const QString& message = "", bool isPublic = true ) const;
 75
 76        QNetworkReply* getEvents(int limit = 0) const;
 77        QNetworkReply* getInfo() const;
 78        static Artist getInfo( QNetworkReply* );
 79
 80        QNetworkReply* getSimilar( int limit = -1 ) const;
 81        /** The match percentage is returned from last.fm as a 4 significant
 82          * figure floating point value. So we multply it by 100 to make an
 83          * integer in the range of 0 to 10,000. This is possible confusing
 84          * for you, but I felt it best not to lose any precision, and floats
 85          * aren't much fun. */
 86        static QMap<int, QString> getSimilar( QNetworkReply* );
 87
 88        /** use Tag::list to get the tag list out of the finished reply */
 89        QNetworkReply* getTags() const;
 90        QNetworkReply* getTopTags() const;
 91
 92        QNetworkReply* getTopTracks() const;
 93        static QStringList getTopTracks( QNetworkReply* );
 94
 95        /** Last.fm dictates that you may submit at most 10 of these */
 96        QNetworkReply* addTags( const QStringList& ) const;
 97
 98        QNetworkReply* search( int limit = -1 ) const;
 99        static QList<Artist> list( QNetworkReply* );
100
101        QMap<QString, QString> params( const QString& method ) const;
102    };
103}
104
105#endif