File indexing completed on 2025-01-19 03:53:47
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2005-05-17 0007 * Description : low level files management interface. 0008 * 0009 * SPDX-FileCopyrightText: 2005 by Renchi Raju <renchi dot raju at gmail dot com> 0010 * SPDX-FileCopyrightText: 2012-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0011 * SPDX-FileCopyrightText: 2018 by Maik Qualmann <metzpinguin at gmail dot com> 0012 * 0013 * SPDX-License-Identifier: GPL-2.0-or-later 0014 * 0015 * ============================================================ */ 0016 0017 #ifndef DIGIKAM_DIO_H 0018 #define DIGIKAM_DIO_H 0019 0020 // Qt includes 0021 0022 #include <QObject> 0023 #include <QMutex> 0024 #include <QMap> 0025 0026 // Local includes 0027 0028 #include "digikam_export.h" 0029 #include "dtrashiteminfo.h" 0030 0031 class QUrl; 0032 0033 namespace Digikam 0034 { 0035 0036 class Album; 0037 class PAlbum; 0038 class ItemInfo; 0039 class IOJobData; 0040 class ProgressItem; 0041 0042 class DIGIKAM_GUI_EXPORT DIO : public QObject 0043 { 0044 Q_OBJECT 0045 0046 public: 0047 0048 static DIO* instance(); 0049 0050 static void cleanUp(); 0051 0052 static bool itemsUnderProcessing(); 0053 0054 /** 0055 * All DIO methods will take care for sidecar files, if they exist 0056 */ 0057 0058 /// Copy an album to another album 0059 static void copy(PAlbum* const src, PAlbum* const dest); 0060 0061 /// Copy items to another album 0062 static void copy(const QList<ItemInfo>& infos, PAlbum* const dest); 0063 0064 /// Copy an external file to another album 0065 static void copy(const QUrl& src, PAlbum* const dest); 0066 0067 /// Copy external files to another album 0068 static void copy(const QList<QUrl>& srcList, PAlbum* const dest); 0069 0070 /// Copy items to external folder 0071 static void copy(const QList<ItemInfo>& infos, const QUrl& dest); 0072 0073 /// Move an album into another album 0074 static void move(PAlbum* const src, PAlbum* const dest); 0075 0076 /// Move items to another album 0077 static void move(const QList<ItemInfo>& infos, PAlbum* const dest); 0078 0079 /// Move external files another album 0080 static void move(const QUrl& src, PAlbum* const dest); 0081 0082 /// Move external files into another album 0083 static void move(const QList<QUrl>& srcList, PAlbum* const dest); 0084 0085 static void del(const QList<ItemInfo>& infos, bool useTrash); 0086 static void del(const ItemInfo& info, bool useTrash); 0087 static void del(PAlbum* const album, bool useTrash); 0088 0089 /// Rename item to new name 0090 static void rename(const QUrl& src, const QString& newName, bool overwrite = false); 0091 0092 /// Trash operations 0093 static int getTrashCounter(const QString& albumRootPath); 0094 static void restoreTrash(const DTrashItemInfoList& infos); 0095 static void emptyTrash(const DTrashItemInfoList& infos); 0096 static void buildCollectionTrashCounters(); 0097 0098 Q_SIGNALS: 0099 0100 void signalTrashCounters(); 0101 void signalTrashFinished(); 0102 void signalRenameFinished(); 0103 void signalRenameFailed(const QUrl& url); 0104 0105 private: 0106 0107 void processJob(IOJobData* const data); 0108 void createJob(IOJobData* const data); 0109 0110 void updateAlbumDate(int albumID); 0111 QString getItemString(IOJobData* const data) const; 0112 ProgressItem* getProgressItem(IOJobData* const data) const; 0113 void addAlbumChildrenToList(QList<int>& list, Album* const album); 0114 0115 private Q_SLOTS: 0116 0117 void slotResult(); 0118 void slotCancel(ProgressItem* item); 0119 void slotOneProccessed(const QUrl& url); 0120 void slotTrashCounterMap(const QMap<QString, int>& counterMap); 0121 0122 private: 0123 0124 // Disable 0125 DIO(); 0126 explicit DIO(QObject*) = delete; 0127 ~DIO() override; 0128 0129 private: 0130 0131 int m_processingCount; 0132 QMap<QString, int> m_trashCounterMap; 0133 QMutex m_trashCounterMutex; 0134 0135 friend class DIOCreator; 0136 }; 0137 0138 } // namespace Digikam 0139 0140 #endif // DIGIKAM_DIO_H