File indexing completed on 2024-06-02 04:08:36

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2008-02-29
0007  * Description : Drag object info containers.
0008  *
0009  * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_DDRAG_OBJECTS_H
0016 #define DIGIKAM_DDRAG_OBJECTS_H
0017 
0018 // Qt includes
0019 
0020 #include <QMimeData>
0021 #include <QList>
0022 #include <QStringList>
0023 #include <QUrl>
0024 
0025 // Local includes
0026 
0027 #include "cameratype.h"
0028 
0029 class QWidget;
0030 
0031 namespace Digikam
0032 {
0033 
0034 /**
0035  * Provides a drag object with additional information for internal drag&drop
0036  *
0037  * Images can be moved through ItemDrag. It is possible to move them on
0038  * another application which is supported through QT to e.g. copy the images.
0039  * digiKam can use the IDs, if ItemDrag is dropped on digikam itself.
0040  * The urls set via setUrls() are used for external drops (k3b, gimp, ...)
0041  */
0042 class DItemDrag : public QMimeData
0043 {
0044     Q_OBJECT
0045 
0046 public:
0047 
0048     DItemDrag(const QList<QUrl>& urls,
0049               const QList<int>& albumIDs,
0050               const QList<qlonglong>& imageIDs);
0051 
0052     static bool canDecode(const QMimeData* e);
0053     static QStringList mimeTypes();
0054     static bool decode(const QMimeData* e,
0055                        QList<QUrl>& urls,
0056                        QList<int>& albumIDs,
0057                        QList<qlonglong>& imageIDs);
0058 
0059 private:
0060 
0061     // Disable
0062     explicit DItemDrag(QObject*) = delete;
0063 };
0064 
0065 // ------------------------------------------------------------------------
0066 
0067 /**
0068  * Provides a drag object for an album
0069  *
0070  * When an album is moved through drag'n'drop an object of this class
0071  * is created.
0072  */
0073 class DAlbumDrag : public QMimeData
0074 {
0075     Q_OBJECT
0076 
0077 public:
0078 
0079     DAlbumDrag(const QUrl& databaseUrl, int albumid, const QUrl& fileUrl = QUrl());
0080     static QStringList mimeTypes();
0081     static bool canDecode(const QMimeData* e);
0082     static bool decode(const QMimeData* e, QList<QUrl>& urls, int& albumID);
0083 
0084 private:
0085 
0086     // Disable
0087     explicit DAlbumDrag(QObject*) = delete;
0088 };
0089 
0090 // ------------------------------------------------------------------------
0091 
0092 /**
0093  * Provides a drag object for a list of tags
0094  *
0095  * When a tag is moved through drag'n'drop an object of this class
0096  * is created.
0097  */
0098 class DTagListDrag : public QMimeData
0099 {
0100     Q_OBJECT
0101 
0102 public:
0103 
0104     explicit DTagListDrag(const QList<int>& tagIDs);
0105     static QStringList mimeTypes();
0106     static bool canDecode(const QMimeData* e);
0107     static bool decode(const QMimeData* e, QList<int>& tagIDs);
0108 
0109 private:
0110 
0111     // Disable
0112     explicit DTagListDrag(QObject*) = delete;
0113 };
0114 
0115 // ------------------------------------------------------------------------
0116 
0117 /**
0118  * Provides a drag object for a list of camera items
0119  *
0120  * When a camera item is moved through drag'n'drop an object of this class
0121  * is created.
0122  */
0123 class DCameraItemListDrag : public QMimeData
0124 {
0125     Q_OBJECT
0126 
0127 public:
0128 
0129     explicit DCameraItemListDrag(const QStringList& cameraItemPaths);
0130     static QStringList mimeTypes();
0131     static bool canDecode(const QMimeData* e);
0132     static bool decode(const QMimeData* e, QStringList& cameraItemPaths);
0133 
0134 private:
0135 
0136     // Disable
0137     explicit DCameraItemListDrag(QObject*) = delete;
0138 };
0139 
0140 // ------------------------------------------------------------------------
0141 
0142 /**
0143  * Provides a drag object for a camera object
0144  *
0145  * When a camera object is moved through drag'n'drop an object of this class
0146  * is created.
0147  */
0148 class DCameraDragObject : public QMimeData
0149 {
0150     Q_OBJECT
0151 
0152 public:
0153 
0154     explicit DCameraDragObject(const CameraType& ctype);
0155     static QStringList mimeTypes();
0156     static bool canDecode(const QMimeData* e);
0157     static bool decode(const QMimeData* e, CameraType& ctype);
0158 
0159 private:
0160 
0161     // Disable
0162     explicit DCameraDragObject(QObject*) = delete;
0163 };
0164 
0165 } // namespace Digikam
0166 
0167 #endif // DIGIKAM_DDRAG_OBJECTS_H