File indexing completed on 2025-01-05 04:25:43

0001 /****************************************************************************************
0002  * Copyright (c) 2009-2010 Joffrey Clavel <jclavel@clabert.info>                        *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef SIMILAR_ARTIST_H
0018 #define SIMILAR_ARTIST_H
0019 
0020 //Kde
0021 #include <KSharedPtr>
0022 #include <QUrl>
0023 
0024 //Qt
0025 #include <QSharedData>
0026 #include <QString>
0027 #include <QXmlStreamReader>
0028 
0029 class SimilarArtist;
0030 typedef KSharedPtr<SimilarArtist> SimilarArtistPtr;
0031 
0032 /**
0033  * Represents a similar artist to another
0034  * @author Joffrey Clavel
0035  * @version 0.1
0036  */
0037 class SimilarArtist : public QSharedData
0038 {
0039 public:
0040     typedef QList<SimilarArtistPtr> List;
0041 
0042     /**
0043      * Create an empty similar artist
0044      */
0045     SimilarArtist();
0046 
0047     /**
0048      * Create a similar artist with data
0049      * @param name  The name of this similar artist
0050      * @param match The match percent (between 0 and 100) of the similarity
0051      * between this artist and the artist similarTo
0052      * @param url   A url of this artist on the web, for example on last.fm
0053      * @param urlImage  A url of an image of this artist, for example on last.fm
0054      * @param similarTo The name of the artist similar to this artist
0055      */
0056     SimilarArtist( const QString &name, const int match, const QUrl &url,
0057                    const QUrl &urlImage, const QString &similarTo );
0058 
0059     SimilarArtist( const SimilarArtist &other );
0060 
0061     /**
0062      * @return The name of this artist
0063      */
0064     QString name() const;
0065 
0066     /**
0067      * @return the percent of match of this artist, between 0 and 100
0068      */
0069     int match() const;
0070 
0071     /**
0072      * @return a url on the web for this artist, for example on last.fm
0073      */
0074     QUrl url() const;
0075 
0076     /**
0077      * @return a url on the web for an image oh this artist, for example on last.fm
0078      */
0079     QUrl urlImage() const;
0080 
0081     /**
0082      * @return the artist this similar artist is related to
0083      */
0084     QString similarTo() const;
0085 
0086     /**
0087      * Set the artist this similar artist is related to
0088      * @param artist artist name
0089      */
0090     void setSimilarTo( const QString &artist );
0091 
0092     static SimilarArtist::List listFromXml( QXmlStreamReader &xml );
0093 
0094 private:
0095     /**
0096      * The name of this artist
0097      */
0098     QString m_name;
0099 
0100     /**
0101      * The match of this artist to the artist similarTo, between 0 and 100
0102      */
0103     int m_match;
0104 
0105     /**
0106      * A url of this artist on the web
0107      */
0108     QUrl m_url;
0109 
0110     /**
0111      * A image url of this artist on the web
0112      */
0113     QUrl m_urlImage;
0114 
0115     /**
0116      * The name of the artist similar to this artist
0117      */
0118     QString m_similarTo;
0119 };
0120 
0121 Q_DECLARE_METATYPE( SimilarArtist )
0122 Q_DECLARE_METATYPE( SimilarArtistPtr )
0123 Q_DECLARE_METATYPE( SimilarArtist::List )
0124 
0125 #endif // SIMILAR_ARTIST_H