File indexing completed on 2024-05-12 04:51:00
0001 /* 0002 SPDX-FileCopyrightText: 2003-2008 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-FileCopyrightText: 2009 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net> 0004 SPDX-FileCopyrightText: 2010 Michal Malek <michalm@jabster.pl> 0005 SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 0011 #ifndef K3BAUDIODOC_H 0012 #define K3BAUDIODOC_H 0013 0014 #include "k3bdoc.h" 0015 #include "k3bcdtext.h" 0016 #include "k3btoc.h" 0017 0018 #include "k3b_export.h" 0019 0020 class QDomElement; 0021 0022 namespace K3b { 0023 class AudioTrack; 0024 class AudioDataSource; 0025 class AudioDecoder; 0026 class AudioFile; 0027 0028 /** 0029 * Document class for an audio project. 0030 * @author Sebastian Trueg 0031 */ 0032 class LIBK3B_EXPORT AudioDoc : public Doc 0033 { 0034 Q_OBJECT 0035 0036 friend class MixedDoc; 0037 friend class AudioTrack; 0038 friend class AudioFile; 0039 0040 public: 0041 explicit AudioDoc( QObject* ); 0042 ~AudioDoc() override; 0043 0044 Type type() const override { return AudioProject; } 0045 QString typeString() const override { return QString::fromLatin1("audio"); } 0046 0047 QString name() const override; 0048 0049 bool newDocument() override; 0050 0051 void clear() override; 0052 0053 Device::MediaTypes supportedMediaTypes() const override; 0054 0055 bool hideFirstTrack() const; 0056 int numOfTracks() const override; 0057 0058 bool normalize() const; 0059 0060 AudioTrack* firstTrack() const; 0061 AudioTrack* lastTrack() const; 0062 0063 /** 0064 * Slow. 0065 * \return the AudioTrack with track number trackNum (starting at 1) or 0 if trackNum > numOfTracks() 0066 */ 0067 AudioTrack* getTrack( int trackNum ); 0068 0069 /** 0070 * Creates a new audiofile inside this doc which has no track yet. 0071 */ 0072 AudioFile* createAudioFile( const QUrl& url ); 0073 0074 /** get the current size of the project */ 0075 KIO::filesize_t size() const override; 0076 Msf length() const override; 0077 0078 // CD-Text 0079 bool cdText() const; 0080 QString title() const; 0081 QString artist() const; 0082 QString disc_id() const; 0083 QString arranger() const; 0084 QString songwriter() const; 0085 QString composer() const; 0086 QString upc_ean() const; 0087 QString cdTextMessage() const; 0088 0089 /** 0090 * Create complete CD-Text including the tracks' data. 0091 */ 0092 Device::CdText cdTextData() const; 0093 0094 int audioRippingParanoiaMode() const; 0095 int audioRippingRetries() const; 0096 bool audioRippingIgnoreReadErrors() const; 0097 0098 /** 0099 * Represent the structure of the doc as CD Table of Contents. 0100 */ 0101 Device::Toc toToc() const; 0102 0103 BurnJob* newBurnJob( JobHandler*, QObject* parent = 0 ) override; 0104 0105 /** 0106 * returns the new after track, ie. the last added track or null if 0107 * the import failed. 0108 * 0109 * This is a blocking method. 0110 * 0111 * \param cuefile The Cuefile to be imported 0112 * \param after The track after which the new tracks should be inserted 0113 * \param decoder The decoder to be used for the new tracks. If 0 a new one will be created. 0114 * 0115 * BE AWARE THAT THE DECODER HAS TO FIT THE AUDIO FILE IN THE CUE. 0116 */ 0117 AudioTrack* importCueFile( const QString& cuefile, AudioTrack* after, AudioDecoder* decoder = 0 ); 0118 0119 /** 0120 * Create a decoder for a specific url. If another AudioFileSource with this 0121 * url is already part of this project the associated decoder is returned. 0122 * 0123 * In the first case the decoder will not be initialized yet (AudioDecoder::analyseFile 0124 * is not called yet). 0125 * 0126 * \param url The url for which a decoder is requested. 0127 * \param reused If not null this variable is set to true if the decoder is already in 0128 * use and AudioDecoder::analyseFile() does not have to be called anymore. 0129 */ 0130 AudioDecoder* getDecoderForUrl( const QUrl& url, bool* reused = 0 ); 0131 0132 /** 0133 * Transforms given url list into flat file list. 0134 * Each directory and M3U playlist is expanded into the files. 0135 * Note: directories are not expanded recursively. 0136 */ 0137 static QList<QUrl> extractUrlList( const QList<QUrl>& urls ); 0138 0139 static bool readPlaylistFile( const QUrl& url, QList<QUrl>& playlist ); 0140 0141 public Q_SLOTS: 0142 void addUrls( const QList<QUrl>& ) override; 0143 void addTrack( const QUrl&, int ); 0144 void addTracks( const QList<QUrl>&, int ); 0145 /** 0146 * Adds a track without any testing 0147 * 0148 * Slow because it uses getTrack. 0149 */ 0150 void addTrack( AudioTrack* track, int position = 0 ); 0151 0152 void addSources( AudioTrack* parent, const QList<QUrl>& urls, AudioDataSource* sourceAfter = 0 ); 0153 0154 void removeTrack( AudioTrack* ); 0155 void moveTrack( AudioTrack* track, AudioTrack* after ); 0156 0157 void setHideFirstTrack( bool b ); 0158 void setNormalize( bool b ); 0159 0160 // CD-Text 0161 void writeCdText( bool b ); 0162 void setTitle( const QString& v ); 0163 void setArtist( const QString& v ); 0164 void setPerformer( const QString& v ); 0165 void setDisc_id( const QString& v ); 0166 void setArranger( const QString& v ); 0167 void setSongwriter( const QString& v ); 0168 void setComposer( const QString& v ); 0169 void setUpc_ean( const QString& v ); 0170 void setCdTextMessage( const QString& v ); 0171 0172 // Audio-CD Ripping 0173 void setAudioRippingParanoiaMode( int i ); 0174 void setAudioRippingRetries( int r ); 0175 void setAudioRippingIgnoreReadErrors( bool b ); 0176 0177 private Q_SLOTS: 0178 void slotTrackChanged( K3b::AudioTrack* track ); 0179 void slotTrackRemoved( int position ); 0180 0181 Q_SIGNALS: 0182 void trackChanged( K3b::AudioTrack* track ); 0183 0184 // signals for the model 0185 void trackAboutToBeAdded( int position ); 0186 void trackAdded( int position ); 0187 void trackAboutToBeRemoved( int position ); 0188 void trackRemoved( int position ); 0189 void sourceAboutToBeAdded( K3b::AudioTrack* parent, int position ); 0190 void sourceAdded( K3b::AudioTrack* parent, int position ); 0191 void sourceAboutToBeRemoved( K3b::AudioTrack* parent, int position ); 0192 void sourceRemoved( K3b::AudioTrack* parent, int position ); 0193 0194 protected: 0195 /** reimplemented from Doc */ 0196 bool loadDocumentData( QDomElement* ) override; 0197 /** reimplemented from Doc */ 0198 bool saveDocumentData( QDomElement* ) override; 0199 0200 private: 0201 // the stuff for adding files 0202 // --------------------------------------------------------- 0203 AudioTrack* createTrack( const QUrl& url ); 0204 0205 /** 0206 * Used by AudioTrack to update the track list 0207 */ 0208 void setFirstTrack( AudioTrack* track ); 0209 /** 0210 * Used by AudioTrack to update the track list 0211 */ 0212 void setLastTrack( AudioTrack* track ); 0213 0214 /** 0215 * Used by AudioFile to tell the doc that it does not need the decoder anymore. 0216 */ 0217 void decreaseDecoderUsage( AudioDecoder* ); 0218 void increaseDecoderUsage( AudioDecoder* ); 0219 0220 class Private; 0221 Private* d; 0222 }; 0223 } 0224 0225 #endif