~ubuntu-branches/ubuntu/saucy/liblastfm/saucy-proposed

« back to all changes in this revision

Viewing changes to src/types/Artist.h

  • Committer: Bazaar Package Importer
  • Author(s): John Stamp
  • Date: 2009-07-14 11:14:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090714111408-3fonzjm83fx8618o
Tags: upstream-0.4.0~git20090710
ImportĀ upstreamĀ versionĀ 0.4.0~git20090710

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   Copyright 2009 Last.fm Ltd. 
 
3
      - Primarily authored by Max Howell, Jono Cole and Doug Mansell
 
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 <lastfm/global.h>
 
24
#include <QMap>
 
25
#include <QString>
 
26
#include <QUrl>
 
27
 
 
28
namespace lastfm
 
29
{
 
30
    class LASTFM_DLLEXPORT Artist
 
31
    {
 
32
        QString m_name;
 
33
        QList<QUrl> m_images;
 
34
 
 
35
    public:
 
36
        Artist()
 
37
        {}
 
38
 
 
39
        Artist( const QString& name ) : m_name( name )
 
40
        {}
 
41
 
 
42
        /** will be QUrl() unless you got this back from a getInfo or something call */
 
43
        QUrl imageUrl( ImageSize size = Large ) const { return m_images.value( size ); }
 
44
 
 
45
        bool isNull() const { return m_name.isEmpty(); }
 
46
        
 
47
        /** the url for this artist's page at www.last.fm */
 
48
        QUrl www() const;
 
49
    
 
50
        bool operator==( const Artist& that ) const { return m_name == that.m_name; }
 
51
        bool operator!=( const Artist& that ) const { return m_name != that.m_name; }
 
52
    
 
53
        operator QString() const 
 
54
        {
 
55
            /** if no artist name is set, return the musicbrainz unknown identifier
 
56
              * in case some part of the GUI tries to display it anyway. Note isNull
 
57
              * returns false still. So you should have queried that! */
 
58
            return m_name.isEmpty() ? "[unknown]" : m_name;
 
59
        }
 
60
        QString name() const { return QString(*this); } 
 
61
    
 
62
        QNetworkReply* share( const class User& recipient, const QString& message = "" );
 
63
 
 
64
        QNetworkReply* getInfo() const;
 
65
        static Artist getInfo( QNetworkReply* );
 
66
    
 
67
        QNetworkReply* getSimilar() const;
 
68
        /** The match percentage is returned from last.fm as a 4 significant 
 
69
          * figure floating point value. So we multply it by 100 to make an 
 
70
          * integer in the range of 0 to 10,000. This is possible confusing 
 
71
          * for you, but I felt it best not to lose any precision, and floats 
 
72
          * aren't much fun. */
 
73
        static QMap<int, QString> getSimilar( QNetworkReply* );
 
74
    
 
75
        /** use Tag::list to get the tag list out of the finished reply */
 
76
        QNetworkReply* getTags() const;
 
77
        QNetworkReply* getTopTags() const;
 
78
    
 
79
        /** Last.fm dictates that you may submit at most 10 of these */
 
80
        QNetworkReply* addTags( const QStringList& ) const;
 
81
    
 
82
        QNetworkReply* search( int limit = -1 ) const;
 
83
        static QList<Artist> list( QNetworkReply* );
 
84
        
 
85
        QMap<QString, QString> params( const QString& method ) const;
 
86
    };
 
87
}
 
88
 
 
89
#endif