6
6
* \author Urs Fleisch
9
* Copyright (C) 2005-2007 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/>.
10
27
#ifndef TAGGEDFILE_H
11
28
#define TAGGEDFILE_H
13
30
#include <qstring.h>
31
#include <qstringlist.h>
32
#include "qtcompatmac.h"
33
#if QT_VERSION >= 0x040000
36
#include <qvaluelist.h>
14
38
#include "standardtags.h"
19
43
/** Base class for tagged files. */
46
/** Abstract base class for pluggable file type resolution. */
57
virtual ~Resolver() {}
60
* Create a TaggedFile subclass depending on the file extension.
62
* @param di directory information
65
* @return tagged file, 0 if type not supported.
67
virtual TaggedFile* createFile(const DirInfo* di, const QString& fn) const = 0;
70
* Get a list with all extensions (e.g. ".mp3") supported by TaggedFile subclass.
72
* @return list of file extensions.
74
virtual QStringList getSupportedFileExtensions() const = 0;
144
200
virtual QString getGenreV1();
147
* Remove all ID3v1 tags.
203
* Remove ID3v1 frames.
149
* @param flt filter specifying which fields to remove
205
* @param flt filter specifying which frames to remove
151
virtual void removeTagsV1(const StandardTagsFilter& flt);
207
virtual void deleteFramesV1(const FrameFilter& flt);
154
210
* Set ID3v1 title.
269
325
virtual int getTrackNumV2() = 0;
272
* Remove all ID3v2 tags.
328
* Remove ID3v2 frames.
274
* @param flt filter specifying which fields to remove
330
* @param flt filter specifying which frames to remove
276
virtual void removeTagsV2(const StandardTagsFilter& flt) = 0;
332
virtual void deleteFramesV2(const FrameFilter& flt);
279
335
* Get ID3v2 genre as text.
367
423
virtual unsigned getDuration() const = 0;
370
* Get frame list for this type of tagged file.
372
* @return frame list.
374
virtual FrameList* getFrameList() const = 0;
377
426
* Get file extension including the dot.
379
428
* @return file extension, e.g. ".mp3".
399
448
virtual QString getTagFormatV2() const;
451
* Get a specific frame from the tags 1.
453
* @param type frame type
454
* @param frame the frame is returned here
456
* @return true if ok.
458
virtual bool getFrameV1(Frame::Type type, Frame& frame);
461
* Set a frame in the tags 1.
463
* @param frame frame to set.
465
* @return true if ok.
467
virtual bool setFrameV1(const Frame& frame);
470
* Get a specific frame from the tags 2.
472
* @param type frame type
473
* @param frame the frame is returned here
475
* @return true if ok.
477
virtual bool getFrameV2(Frame::Type type, Frame& frame);
480
* Set a frame in the tags 2.
482
* @param frame frame to set
484
* @return true if ok.
486
virtual bool setFrameV2(const Frame& frame);
489
* Add a frame in the tags 2.
491
* @param frame frame to add, a field list may be added by this method
493
* @return true if ok.
495
virtual bool addFrameV2(Frame& frame);
498
* Delete a frame in the tags 2.
500
* @param frame frame to delete.
502
* @return true if ok.
504
virtual bool deleteFrameV2(const Frame& frame);
507
* Get a list of frame IDs which can be added.
509
* @return list with frame IDs.
511
virtual QStringList getFrameIds() const;
514
* Get all frames in tag 1.
516
* @param frames frame collection to set.
518
virtual void getAllFramesV1(FrameCollection& frames);
521
* Get all frames in tag 2.
522
* This generic implementation only supports the standard tags and should
523
* be reimplemented in derived classes.
525
* @param frames frame collection to set.
527
virtual void getAllFramesV2(FrameCollection& frames);
530
* Set frames in tag 1.
532
* @param frames frame collection
533
* @param onlyChanged only frames with value marked as changed are set
535
void setFramesV1(const FrameCollection& frames, bool onlyChanged = true);
538
* Set frames in tag 2.
540
* @param frames frame collection
541
* @param onlyChanged only frames with value marked as changed are set
543
void setFramesV2(const FrameCollection& frames, bool onlyChanged = true);
402
546
* Get ID3v1 tags from file.
404
548
* @param st tags to put result
512
656
unsigned getTruncationFlags() const { return m_truncation; }
659
* Add the total number of tracks to the track number if enabled.
661
* @param value string containing track number,
662
* "/t" with t = total number of tracks will be appended
663
* if enabled and value contains a number
665
void addTotalNumberOfTracksIfEnabled(QString& value) const;
515
668
* Format a time string "h:mm:ss".
516
669
* If the time is less than an hour, the hour is not put into the
517
670
* string and the minute is not padded with zeroes.
523
676
static QString formatTime(unsigned seconds);
679
* Add a file type resolver to the end of a list of resolvers.
681
* @param resolver file type resolver to add
683
static void addResolver(const Resolver* resolver);
686
* Create a TaggedFile subclass using the first successful resolver.
689
* @param di directory information
692
* @return tagged file, 0 if type not supported.
694
static TaggedFile* createFile(const DirInfo* di, const QString& fn);
697
* Get a list with all extensions (e.g. ".mp3") supported by the resolvers.
700
* @return list of file extensions.
702
static QStringList getSupportedFileExtensions();
705
* Free static resources.
707
static void staticCleanup();
550
734
int getTotalNumberOfTracksIfEnabled() const;
553
* Remove the standard ID3v1 tags.
555
* @param flt filter specifying which fields to remove
557
void removeStandardTagsV1(const StandardTagsFilter& flt);
560
* Remove the standard ID3v2 tags.
562
* @param flt filter specifying which fields to remove
564
void removeStandardTagsV2(const StandardTagsFilter& flt);
567
737
* Get current filename.
568
738
* @return existing name.