File indexing completed on 2024-04-28 16:08:20
0001 /* 0002 SPDX-FileCopyrightText: 2002 Rik Hemsley (rikkus) <rik@kde.org> 0003 SPDX-FileCopyrightText: 2002-2005 Benjamin Meyer <ben-devel@meyerhome.net> 0004 SPDX-FileCopyrightText: 2002-2004 Nadeem Hasan <nhasan@nadmm.com> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KCDDB_CDINFO_H 0010 #define KCDDB_CDINFO_H 0011 0012 #include "kcddb_export.h" 0013 #include <QStringList> 0014 #include <QVariant> 0015 0016 namespace KCDDB 0017 { 0018 /** 0019 * The most common types 0020 */ 0021 enum Type 0022 { 0023 Title, /**< The title of the track or CD */ 0024 Comment, /**< A comment for the track or CD */ 0025 Artist, /**< The artist of the track or CD */ 0026 Genre, /**< The genre of the track or CD */ 0027 Year, /**< The year the cd or track was produced 0028 By default, the year of the track is the 0029 same as for the whole cd 0030 @todo Doesn't do that for tracks right now.*/ 0031 Length, /**< The length of a track or a full CD 0032 @todo In what unit? */ 0033 Category /**< The freedb category of the entry. 0034 Needs to be one of: blues, classical, 0035 country, data, fold, jazz, misc, newage, 0036 reggae, rock, soundtrack */ 0037 }; 0038 0039 /** 0040 * Information about a sepecific track in a cd. 0041 */ 0042 class KCDDB_EXPORT TrackInfo 0043 { 0044 public: 0045 0046 TrackInfo(); 0047 virtual ~TrackInfo(); 0048 TrackInfo(const TrackInfo& clone); 0049 TrackInfo& operator=(const TrackInfo& clone); 0050 0051 bool operator==(const TrackInfo&) const; 0052 bool operator!=(const TrackInfo&) const; 0053 0054 /** 0055 * Get data for type that has been assigned to this track. 0056 * @p type is case insensitive. 0057 * For example <code>get("title")</code> 0058 */ 0059 QVariant get(const QString &type) const; 0060 /** 0061 * Helper function that calls type with the common name 0062 */ 0063 QVariant get(Type type) const; 0064 0065 /** 0066 * Set any data from this track. 0067 * @p type is case insensitive. 0068 * For example <code>set("title", "Rock this world")</code> 0069 * Useful for atributes that other apps want to add. 0070 * Data will be stored in the local cddb cache, but not sent to the cddb server 0071 */ 0072 void set(const QString &type, const QVariant &data); 0073 /** 0074 * Helper function that calls type with the common name 0075 */ 0076 void set(Type type, const QVariant &data); 0077 0078 /** 0079 * @return a CDDB compatible string of all the data assigned to this track 0080 * tracknumber must be assigned before calling this. 0081 */ 0082 QString toString() const; 0083 0084 /** 0085 * internal 0086 */ 0087 void clear(); 0088 0089 private: 0090 class TrackInfoPrivate *d; 0091 0092 }; 0093 0094 typedef QList<TrackInfo> TrackInfoList; 0095 0096 /** 0097 * Information about a CD 0098 * 0099 * Typically CDInfo is obtained from the client such as: 0100 * <code>KCDDB::Client *cddb = new KCDDB::Client(); 0101 * cddb->lookup(discSignature); 0102 * CDInfo info = cddb->lookupResponse().first();</code> 0103 */ 0104 class KCDDB_EXPORT CDInfo 0105 { 0106 public: 0107 CDInfo(); 0108 virtual ~CDInfo(); 0109 0110 CDInfo(const CDInfo& clone); 0111 CDInfo& operator=(const CDInfo& clone); 0112 0113 bool operator==(const CDInfo&) const; 0114 bool operator!=(const CDInfo&) const; 0115 0116 /** 0117 * Load CDInfo from a string that is CDDB compatible 0118 * @return true if successful 0119 */ 0120 bool load(const QString &string); 0121 /** 0122 * Load CDInfo from a stringList that is CDDB compatible 0123 * @return true if successful 0124 */ 0125 bool load(const QStringList &stringList); 0126 0127 /** 0128 * Clear all information, setting this to invalid 0129 * internal 0130 */ 0131 void clear(); 0132 0133 /** 0134 * @return true if the cd information is valid 0135 */ 0136 bool isValid() const; 0137 0138 /** 0139 * @param submit If submit is true only returns CDDB compatible information 0140 * @return a string containing all of the CD's information. 0141 */ 0142 QString toString(bool submit=false) const; 0143 0144 /** 0145 * Get data for type that has been assigned to this disc. 0146 * @p type is case insensitive. 0147 * For example <code>get("title")</code> 0148 */ 0149 QVariant get(const QString &type) const; 0150 /** 0151 * Helper function that calls type with the common name 0152 */ 0153 QVariant get(Type type) const; 0154 0155 /** 0156 * Set any data from this disc. 0157 * @p type is case insensitive. 0158 * For example <code>set("title", "Rock this world")</code> 0159 * Useful for atributes that other apps want to add. 0160 * Data will be stored in the local cddb cache, but not sent to the cddb server 0161 */ 0162 void set(const QString &type, const QVariant &data); 0163 /** 0164 * Helper function that calls type with the common name 0165 */ 0166 void set(Type type, const QVariant &data); 0167 0168 /** 0169 * Returns track with nr @p trackNumber and adds it to 0170 * the track list if it doesn't exist (first track is 0) 0171 */ 0172 TrackInfo & track( int trackNumber ); 0173 0174 /** 0175 * Returns a const track with nr @p trackNumber 0176 * or a new if it doesn't exist (first track is 0) 0177 */ 0178 TrackInfo track( int trackNumber ) const; 0179 0180 /** 0181 * Returns number of tracks on CD 0182 */ 0183 int numberOfTracks() const; 0184 0185 protected: 0186 /** 0187 * Checks to make sure that trackNumber exists 0188 */ 0189 void checkTrack( int trackNumber ); 0190 0191 private: 0192 class CDInfoPrivate * const d; 0193 }; 0194 0195 typedef QList<CDInfo> CDInfoList; 0196 } 0197 0198 #endif // KCDDB_CDINFO_H 0199 // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1