File indexing completed on 2025-01-19 03:55:48

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-05-05
0007  * Description : file action manager
0008  *
0009  * SPDX-FileCopyrightText: 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  * SPDX-FileCopyrightText: 2011-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_FILE_ACTION_MNGR_H
0017 #define DIGIKAM_FILE_ACTION_MNGR_H
0018 
0019 // Local includes
0020 
0021 #include "iteminfo.h"
0022 #include "metaengine_rotation.h"
0023 #include "digikam_export.h"
0024 
0025 namespace Digikam
0026 {
0027 
0028 class MetadataHub;
0029 class MetadataHubOnTheRoad;
0030 class DisjointMetadata;
0031 
0032 class DIGIKAM_GUI_EXPORT FileActionMngr : public QObject
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037 
0038     enum GroupAction
0039     {
0040         AddToGroup,
0041         RemoveFromGroup,
0042         SplitGroup
0043     };
0044 
0045 public:
0046 
0047     static FileActionMngr* instance();
0048 
0049     bool requestShutDown();
0050     void shutDown();
0051     bool isActive();
0052 
0053 Q_SIGNALS:
0054 
0055     void signalImageChangeFailed(const QString& message, const QStringList& fileNames);
0056 
0057 public Q_SLOTS:
0058 
0059     void assignTag(const ItemInfo& info, int tagID);
0060     void assignTag(const QList<ItemInfo>& infos, int tagID);
0061     void assignTags(const ItemInfo& info, const QList<int>& tagIDs);
0062     void assignTags(const QList<ItemInfo>& infos, const QList<int>& tagIDs);
0063     void assignTags(const QList<qlonglong>& imageIds, const QList<int>& tagIDs);
0064 
0065     void removeTag(const ItemInfo& info, int tagID);
0066     void removeTag(const QList<ItemInfo>& infos, int tagID);
0067     void removeTags(const ItemInfo& info, const QList<int>& tagIDs);
0068     void removeTags(const QList<ItemInfo>& infos, const QList<int>& tagIDs);
0069 
0070     void assignPickLabel(const ItemInfo& info, int pickId);
0071     void assignPickLabel(const QList<ItemInfo>& infos, int pickId);
0072 
0073     void assignColorLabel(const ItemInfo& info, int colorId);
0074     void assignColorLabel(const QList<ItemInfo>& infos, int colorId);
0075 
0076     void assignRating(const ItemInfo& info, int rating);
0077     void assignRating(const QList<ItemInfo>& infos, int rating);
0078 
0079     void addToGroup(const ItemInfo& pick, const QList<ItemInfo>& infos);
0080     void removeFromGroup(const ItemInfo& info);
0081     void removeFromGroup(const QList<ItemInfo>& infos);
0082     void ungroup(const ItemInfo& info);
0083     void ungroup(const QList<ItemInfo>& infos);
0084 
0085     void setExifOrientation(const QList<ItemInfo>& infos, int orientation);
0086 /*
0087     void applyMetadata(const QList<ItemInfo>& infos, const MetadataHub& hub);
0088 */
0089     void applyMetadata(const QList<ItemInfo>& infos, const DisjointMetadata& hub);
0090 
0091     // ownership of the hub is passed, hub must be created without QObject parent
0092     void applyMetadata(const QList<ItemInfo>& infos, DisjointMetadata* hub);
0093 
0094     /**
0095      * Flip or rotate. Note: The NoTransformation action is interpreted as Exif auto-rotate
0096      */
0097     void transform(const QList<ItemInfo>& infos, MetaEngineRotation::TransformationAction action);
0098 
0099     void copyAttributes(const ItemInfo& source, const QStringList& derivedPaths);
0100     void copyAttributes(const ItemInfo& source, const QString& derivedPath);
0101 
0102 public:
0103 
0104     // Declared public due to use by FileActionMngrWorker, FileActionMngrDatabaseWorker, and FileActionMngrFileWorker
0105     class Private;
0106 
0107 private:
0108 
0109     // Disable
0110     FileActionMngr();
0111     explicit FileActionMngr(QObject*);
0112     ~FileActionMngr() override;
0113 
0114     Private* const d;
0115 
0116     friend class FileActionMngrCreator;
0117 };
0118 
0119 } // namespace Digikam
0120 
0121 #endif // DIGIKAM_FILE_ACTION_MNGR_H