2
* \file importtrackdata.h
3
* Track data used for import.
9
* Copyright (C) 2005-2009 Urs Fleisch
11
* This file is part of Kid3.
13
* Kid3 is free software; you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation; either version 2 of the License, or
16
* (at your option) any later version.
18
* Kid3 is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
23
* You should have received a copy of the GNU General Public License
24
* along with this program. If not, see <http://www.gnu.org/licenses/>.
27
#ifndef IMPORTTRACKDATA_H
28
#define IMPORTTRACKDATA_H
31
#include "taggedfile.h"
33
#include "qtcompatmac.h"
34
#if QT_VERSION >= 0x040000
37
#include <qvaluevector.h>
41
* Track data used for import.
43
class ImportTrackData : public FrameCollection {
47
* @param absFilename absolute filename
48
* @param fileDuration duration in seconds
50
explicit ImportTrackData(const QString& absFilename = QString::null,
51
int fileDuration = 0) :
52
m_fileDuration(fileDuration), m_importDuration(0),
53
m_absFilename(absFilename) {}
57
* All fields except the import duration are set from the tagged file,
58
* which should be read using readTags() before. The frames are merged
59
* from tag 2 and tag 1 (where tag 2 is not set).
61
* @param taggedFile tagged file providing track data
63
ImportTrackData(TaggedFile& taggedFile);
71
* Get duration of file.
72
* @return duration of file.
74
int getFileDuration() const { return m_fileDuration; }
77
* Set duration of file.
78
* @param duration duration of file
80
void setFileDuration(int duration) { m_fileDuration = duration; }
83
* Get duration of import.
84
* @return duration of import.
86
int getImportDuration() const { return m_importDuration; }
89
* Set duration of import.
90
* @param duration duration of import
92
void setImportDuration(int duration) { m_importDuration = duration; }
95
* Get absolute filename.
97
* @return absolute file path.
99
QString getAbsFilename() const { return m_absFilename; }
102
* Set absolute filename.
104
* @param absFilename absolute file path
106
void setAbsFilename(const QString& absFilename) {
107
m_absFilename = absFilename;
111
* Get file extension including the dot.
113
* @return file extension, e.g. ".mp3".
115
QString getFileExtension() const;
118
* Set file extension.
119
* @param fileExtension file extension
121
void setFileExtension(const QString& fileExtension) {
122
m_fileExtension = fileExtension;
126
* Get the format of tag 1.
128
* @return string describing format of tag 1,
129
* e.g. "ID3v1.1", "ID3v2.3", "Vorbis", "APE",
130
* QString::null if unknown.
132
QString getTagFormatV1() const { return m_tagFormatV1; }
135
* Set the format of tag 1.
136
* @param tagFormatV1 string describing format of tag 1
138
void setTagFormatV1(const QString& tagFormatV1) { m_tagFormatV1 = tagFormatV1; }
141
* Get the format of tag 2.
143
* @return string describing format of tag 2,
144
* e.g. "ID3v2.3", "Vorbis", "APE",
145
* QString::null if unknown.
147
QString getTagFormatV2() const { return m_tagFormatV2; }
150
* Set the format of tag 2.
151
* @param tagFormatV2 string describing format of tag 2
153
void setTagFormatV2(const QString& tagFormatV2) { m_tagFormatV2 = tagFormatV2; }
157
* @return detail info.
159
const TaggedFile::DetailInfo& getDetailInfo() const { return m_detailInfo; }
163
* @param detailInfo detail info
165
void setDetailInfo(const TaggedFile::DetailInfo& detailInfo) { m_detailInfo = detailInfo; }
168
* Format a string from track data.
169
* Supported format fields:
170
* Those supported by TrackDataFormatReplacer::getReplacement()
172
* @param format format specification
173
* @param numTracks number of tracks in album
175
* @return formatted string.
177
QString formatString(const QString& format, unsigned numTracks = 0) const;
183
FrameCollection& getFrameCollection() {
184
return *(static_cast<FrameCollection*>(this));
189
* @param frames frames
191
void setFrameCollection(const FrameCollection& frames) {
192
*(static_cast<FrameCollection*>(this)) = frames;
196
* Get help text for format codes supported by formatString().
198
* @param onlyRows if true only the tr elements are returned,
199
* not the surrounding table
203
static QString getFormatToolTip(bool onlyRows = false);
207
int m_importDuration;
208
QString m_absFilename;
209
QString m_fileExtension;
210
QString m_tagFormatV1;
211
QString m_tagFormatV2;
212
TaggedFile::DetailInfo m_detailInfo;
216
* Vector containing tracks to import and artist, album names.
218
class ImportTrackDataVector : public
219
#if QT_VERSION >= 0x040000
220
QVector<ImportTrackData>
222
QValueVector<ImportTrackData>
227
* Clear vector and associated data.
231
m_artist = QString();
233
m_coverArtUrl = QString();
238
* @return album artist.
240
QString getArtist() const { return m_artist; }
244
* @param artist artist
246
void setArtist(const QString& artist) { m_artist = artist; }
250
* @return album title.
252
QString getAlbum() const { return m_album; }
258
void setAlbum(const QString& album) { m_album = album; }
262
* @return cover art URL.
264
QString getCoverArtUrl() const { return m_coverArtUrl; }
268
* @param coverArtUrl cover art URL
270
void setCoverArtUrl(const QString& coverArtUrl) { m_coverArtUrl = coverArtUrl; }
275
QString m_coverArtUrl;
280
* Replaces track data format codes in a string.
282
class TrackDataFormatReplacer : public FrameFormatReplacer {
287
* @param trackData track data
288
* @param numTracks number of tracks in album
289
* @param str string with format codes
291
explicit TrackDataFormatReplacer(
292
const ImportTrackData& trackData, unsigned numTracks = 0,
293
const QString& str = QString());
298
virtual ~TrackDataFormatReplacer();
301
* Get help text for supported format codes.
303
* @param onlyRows if true only the tr elements are returned,
304
* not the surrounding table
308
static QString getToolTip(bool onlyRows = false);
312
* Replace a format code (one character %c or multiple characters %{chars}).
313
* Supported format fields:
314
* Those supported by FrameFormatReplacer::getReplacement()
318
* %d duration in minutes:seconds
319
* %D duration in seconds
320
* %n number of tracks
322
* @param code format code
324
* @return replacement string,
325
* QString::null if code not found.
327
virtual QString getReplacement(const QString& code) const;
330
const ImportTrackData& m_trackData;
331
const unsigned m_numTracks;
334
#endif // IMPORTTRACKDATA_H