KCDDB

cdinfo.h
1/*
2 SPDX-FileCopyrightText: 2002 Rik Hemsley (rikkus) <rik@kde.org>
3 SPDX-FileCopyrightText: 2002-2005 Benjamin Meyer <ben-devel@meyerhome.net>
4 SPDX-FileCopyrightText: 2002-2004 Nadeem Hasan <nhasan@nadmm.com>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KCDDB_CDINFO_H
10#define KCDDB_CDINFO_H
11
12#include "kcddb_export.h"
13#include <QStringList>
14#include <QVariant>
15
16namespace KCDDB
17{
18 /**
19 * The most common types
20 */
21 enum Type
22 {
23 Title, /**< The title of the track or CD */
24 Comment, /**< A comment for the track or CD */
25 Artist, /**< The artist of the track or CD */
26 Genre, /**< The genre of the track or CD */
27 Year, /**< The year the cd or track was produced
28 By default, the year of the track is the
29 same as for the whole cd
30 @todo Doesn't do that for tracks right now.*/
31 Length, /**< The length of a track or a full CD
32 @todo In what unit? */
33 Category /**< The freedb category of the entry.
34 Needs to be one of: blues, classical,
35 country, data, fold, jazz, misc, newage,
36 reggae, rock, soundtrack */
37 };
38
39 /**
40 * Information about a specific track in a cd.
41 */
42 class KCDDB_EXPORT TrackInfo
43 {
44 public:
45
46 TrackInfo();
47 virtual ~TrackInfo();
48 TrackInfo(const TrackInfo& clone);
49 TrackInfo& operator=(const TrackInfo& clone);
50
51 bool operator==(const TrackInfo&) const;
52 bool operator!=(const TrackInfo&) const;
53
54 /**
55 * Get data for type that has been assigned to this track.
56 * @p type is case insensitive.
57 * For example <code>get("title")</code>
58 */
59 QVariant get(const QString &type) const;
60 /**
61 * Helper function that calls type with the common name
62 */
63 QVariant get(Type type) const;
64
65 /**
66 * Set any data from this track.
67 * @p type is case insensitive.
68 * For example <code>set("title", "Rock this world")</code>
69 * Useful for attributes that other apps want to add.
70 * Data will be stored in the local cddb cache, but not sent to the cddb server
71 */
72 void set(const QString &type, const QVariant &data);
73 /**
74 * Helper function that calls type with the common name
75 */
76 void set(Type type, const QVariant &data);
77
78 /**
79 * @return a CDDB compatible string of all the data assigned to this track
80 * tracknumber must be assigned before calling this.
81 */
82 QString toString() const;
83
84 /**
85 * internal
86 */
87 void clear();
88
89 private:
90 class TrackInfoPrivate *d;
91
92 };
93
95
96 /**
97 * Information about a CD
98 *
99 * Typically CDInfo is obtained from the client such as:
100 * <code>KCDDB::Client *cddb = new KCDDB::Client();
101 * cddb->lookup(discSignature);
102 * CDInfo info = cddb->lookupResponse().first();</code>
103 */
104 class KCDDB_EXPORT CDInfo
105 {
106 public:
107 CDInfo();
108 virtual ~CDInfo();
109
110 CDInfo(const CDInfo& clone);
111 CDInfo& operator=(const CDInfo& clone);
112
113 bool operator==(const CDInfo&) const;
114 bool operator!=(const CDInfo&) const;
115
116 /**
117 * Load CDInfo from a string that is CDDB compatible
118 * @return true if successful
119 */
120 bool load(const QString &string);
121 /**
122 * Load CDInfo from a stringList that is CDDB compatible
123 * @return true if successful
124 */
125 bool load(const QStringList &stringList);
126
127 /**
128 * Clear all information, setting this to invalid
129 * internal
130 */
131 void clear();
132
133 /**
134 * @return true if the cd information is valid
135 */
136 bool isValid() const;
137
138 /**
139 * @param submit If submit is true only returns CDDB compatible information
140 * @return a string containing all of the CD's information.
141 */
142 QString toString(bool submit=false) const;
143
144 /**
145 * Get data for type that has been assigned to this disc.
146 * @p type is case insensitive.
147 * For example <code>get("title")</code>
148 */
149 QVariant get(const QString &type) const;
150 /**
151 * Helper function that calls type with the common name
152 */
153 QVariant get(Type type) const;
154
155 /**
156 * Set any data from this disc.
157 * @p type is case insensitive.
158 * For example <code>set("title", "Rock this world")</code>
159 * Useful for attributes that other apps want to add.
160 * Data will be stored in the local cddb cache, but not sent to the cddb server
161 */
162 void set(const QString &type, const QVariant &data);
163 /**
164 * Helper function that calls type with the common name
165 */
166 void set(Type type, const QVariant &data);
167
168 /**
169 * Returns track with nr @p trackNumber and adds it to
170 * the track list if it doesn't exist (first track is 0)
171 */
172 TrackInfo & track( int trackNumber );
173
174 /**
175 * Returns a const track with nr @p trackNumber
176 * or a new if it doesn't exist (first track is 0)
177 */
178 TrackInfo track( int trackNumber ) const;
179
180 /**
181 * Returns number of tracks on CD
182 */
183 int numberOfTracks() const;
184
185 protected:
186 /**
187 * Checks to make sure that trackNumber exists
188 */
189 void checkTrack( int trackNumber );
190
191 private:
192 class CDInfoPrivate * const d;
193 };
194
196}
197
198#endif // KCDDB_CDINFO_H
199// vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1
Information about a CD.
Definition cdinfo.h:105
Information about a specific track in a cd.
Definition cdinfo.h:43
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:58 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.