File indexing completed on 2024-05-12 04:51:09
0001 /* 0002 SPDX-FileCopyrightText: 2003-2004 Christian Kvasny <chris@k3b.org> 0003 SPDX-FileCopyrightText: 2010 Michal Malek <michalm@jabster.pl> 0004 SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef K3BVCDDOC_H 0010 #define K3BVCDDOC_H 0011 0012 #include "k3bdoc.h" 0013 #include "k3bvcdoptions.h" 0014 #include "mpeginfo/k3bmpeginfo.h" 0015 0016 #include "k3b_export.h" 0017 0018 #include <QStringList> 0019 #include <QQueue> 0020 0021 class QTimer; 0022 class QDomElement; 0023 0024 namespace K3b { 0025 class VcdTrack; 0026 0027 class LIBK3B_EXPORT VcdDoc : public Doc 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 explicit VcdDoc( QObject* ); 0033 ~VcdDoc() override; 0034 0035 Type type() const override { return VcdProject; } 0036 QString typeString() const override { return QString::fromLatin1("vcd"); } 0037 0038 Device::MediaTypes supportedMediaTypes() const override; 0039 0040 QString name() const override; 0041 0042 enum vcdTypes { VCD11, VCD20, SVCD10, HQVCD, NONE}; 0043 0044 bool newDocument() override; 0045 void clear() override; 0046 0047 int numOfTracks() const override 0048 { 0049 return m_tracks->count(); 0050 } 0051 0052 const QString& vcdImage() const 0053 { 0054 return m_vcdImage; 0055 } 0056 void setVcdImage( const QString& s ) 0057 { 0058 m_vcdImage = s; 0059 } 0060 0061 VcdTrack* at( uint i ) 0062 { 0063 return m_tracks->at( i ); 0064 } 0065 0066 const QList<VcdTrack*>* tracks() const 0067 { 0068 return m_tracks; 0069 } 0070 0071 /** get the current size of the project */ 0072 KIO::filesize_t size() const override; 0073 Msf length() const override; 0074 0075 BurnJob* newBurnJob( JobHandler* hdl, QObject* parent ) override; 0076 VcdOptions* vcdOptions() const 0077 { 0078 return m_vcdOptions; 0079 } 0080 0081 int vcdType() const 0082 { 0083 return m_vcdType; 0084 } 0085 void setVcdType( int type ); 0086 void setPbcTracks(); 0087 0088 public Q_SLOTS: 0089 /** 0090 * will test the file and add it to the project. 0091 * connect to at least result() to know when 0092 * the process is finished and check error() 0093 * to know about the result. 0094 **/ 0095 void addUrls( const QList<QUrl>& ) override; 0096 void addTrack( const QUrl&, uint ); 0097 void addTracks( const QList<QUrl>&, uint ); 0098 /** adds a track without any testing */ 0099 void addTrack( K3b::VcdTrack* track, uint position = 0 ); 0100 0101 // --- TODO: this should read: removeTrack( VcdTrack* ) 0102 void removeTrack( K3b::VcdTrack* track ); 0103 0104 /** 0105 * @arg track - track about to be moved 0106 * @arg before - place where track is to be moved. 0107 * If before=0 the track will be moved to the end 0108 */ 0109 void moveTrack( K3b::VcdTrack* track, K3b::VcdTrack* before ); 0110 0111 protected Q_SLOTS: 0112 /** processes queue "urlsToAdd" **/ 0113 void slotWorkUrlQueue(); 0114 0115 Q_SIGNALS: 0116 void aboutToAddVCDTracks( int pos, int count ); 0117 void addedVCDTracks(); 0118 void aboutToRemoveVCDTracks( int pos, int count ); 0119 void removedVCDTracks(); 0120 0121 void newTracks(); 0122 0123 void trackRemoved( K3b::VcdTrack* ); 0124 0125 protected: 0126 /** reimplemented from Doc */ 0127 bool loadDocumentData( QDomElement* root ) override; 0128 /** reimplemented from Doc */ 0129 bool saveDocumentData( QDomElement* ) override; 0130 0131 private: 0132 VcdTrack* createTrack( const QUrl& url ); 0133 void informAboutNotFoundFiles(); 0134 0135 QStringList m_notFoundFiles; 0136 QString m_vcdImage; 0137 0138 class PrivateUrlToAdd 0139 { 0140 public: 0141 PrivateUrlToAdd( const QUrl& u, int _pos ) 0142 : url( u ), position( _pos ) 0143 {} 0144 QUrl url; 0145 int position; 0146 }; 0147 0148 /** Holds all the urls that have to be added to the list of tracks. **/ 0149 QQueue<PrivateUrlToAdd*> urlsToAdd; 0150 QTimer* m_urlAddingTimer; 0151 0152 QList<VcdTrack*>* m_tracks; 0153 KIO::filesize_t calcTotalSize() const; 0154 KIO::filesize_t ISOsize() const; 0155 0156 bool isImage( const QUrl& url ); 0157 0158 VcdTrack* m_lastAddedTrack; 0159 VcdOptions* m_vcdOptions; 0160 0161 int m_vcdType; 0162 int lastAddedPosition; 0163 }; 0164 } 0165 0166 #endif