File indexing completed on 2025-01-19 04:24:37
0001 /**************************************************************************************** 0002 * Copyright (c) 2011 Bart Cerneels <bart.cerneels@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef UMSCOLLECTIONLOCATION_H 0018 #define UMSCOLLECTIONLOCATION_H 0019 0020 #include "core/collections/CollectionLocation.h" 0021 #include "UmsCollection.h" 0022 0023 #include <KJob> 0024 #include <KCompositeJob> 0025 0026 #include <QList> 0027 #include <QPair> 0028 0029 class UmsTransferJob; 0030 0031 class UmsCollectionLocation : public Collections::CollectionLocation 0032 { 0033 Q_OBJECT 0034 public: 0035 explicit UmsCollectionLocation( UmsCollection *umsCollection ); 0036 ~UmsCollectionLocation() override; 0037 0038 /* CollectionLocation methods */ 0039 QString prettyLocation() const override; 0040 QStringList actualLocation() const override; 0041 bool isWritable() const override; 0042 bool isOrganizable() const override; 0043 0044 void copyUrlsToCollection( const QMap<Meta::TrackPtr, QUrl> &sources, 0045 const Transcoding::Configuration &configuration ) override; 0046 void removeUrlsFromCollection( const Meta::TrackList &sources ) override; 0047 0048 protected Q_SLOTS: 0049 void slotRemoveOperationFinished(); // hides intentionally parent methods 0050 0051 private Q_SLOTS: 0052 /** 0053 * Needed for removal of source tracks during move operation 0054 */ 0055 void slotTrackTransferred( const QUrl &sourceTrackUrl ); 0056 0057 private: 0058 UmsCollection *m_umsCollection; 0059 QHash<QUrl, Meta::TrackPtr> m_sourceUrlToTrackMap; 0060 }; 0061 0062 class UmsTransferJob : public KCompositeJob 0063 { 0064 Q_OBJECT 0065 public: 0066 UmsTransferJob( UmsCollectionLocation *location, const Transcoding::Configuration &configuration ); 0067 0068 void addCopy( const QUrl &from, const QUrl &to ); 0069 void addTranscode( const QUrl &from, const QUrl &to ); 0070 void start() override; 0071 0072 Q_SIGNALS: 0073 void sourceFileTransferDone( const QUrl &source ); 0074 void fileTransferDone( const QUrl &destination ); 0075 0076 public Q_SLOTS: 0077 void slotCancel(); 0078 0079 private Q_SLOTS: 0080 void startNextJob(); 0081 void slotChildJobPercent( KJob *job, unsigned long percentage ); 0082 0083 //reimplemented from KCompositeJob 0084 void slotResult( KJob *job ) override; 0085 0086 private: 0087 UmsCollectionLocation *m_location; 0088 Transcoding::Configuration m_transcodingConfiguration; 0089 bool m_abort; 0090 0091 typedef QPair<QUrl,QUrl> KUrlPair; 0092 QList<KUrlPair> m_copyList; 0093 QList<KUrlPair> m_transcodeList; 0094 int m_totalTracks; // total number of tracks in whole transfer 0095 }; 0096 0097 #endif // UMSCOLLECTIONLOCATION_H