File indexing completed on 2025-01-19 03:50:35

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2012-09-07
0007  * Description : Qt Model for ImportUI - drag and drop handling
0008  *
0009  * SPDX-FileCopyrightText: 2012      by Islam Wazery <wazery at ubuntu dot com>
0010  * SPDX-FileCopyrightText: 2013-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_IMPORT_DRAG_DROP_H
0017 #define DIGIKAM_IMPORT_DRAG_DROP_H
0018 
0019 // Qt includes
0020 
0021 #include <QMenu>
0022 
0023 // Local includes
0024 
0025 #include "abstractitemdragdrophandler.h"
0026 #include "importimagemodel.h"
0027 #include "album.h"
0028 #include "digikam_export.h"
0029 
0030 namespace Digikam
0031 {
0032 
0033 class DIGIKAM_GUI_EXPORT ImportDragDropHandler : public AbstractItemDragDropHandler
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038 
0039     explicit ImportDragDropHandler(ImportItemModel* const model);
0040 
0041     ImportItemModel* model()   const;
0042 
0043     bool           dropEvent(QAbstractItemView* view,
0044                              const QDropEvent* e,
0045                              const QModelIndex& droppedOn)      override;
0046 
0047     Qt::DropAction accepts(const QDropEvent* e,
0048                            const QModelIndex& dropIndex)        override;
0049 
0050     QStringList    mimeTypes() const                            override;
0051     QMimeData*     createMimeData(const QList<QModelIndex>&)    override;
0052 
0053 private:
0054 
0055     enum DropAction
0056     {
0057         NoAction,
0058         CopyAction,
0059         MoveAction,
0060         GroupAction,
0061         AssignTagAction
0062     };
0063 
0064 private:
0065 
0066     QAction*   addGroupAction(QMenu* const menu);
0067     QAction*   addCancelAction(QMenu* const menu);
0068     DropAction copyOrMove(const QDropEvent* e,
0069                           QWidget* const view,
0070                           bool allowMove = true,
0071                           bool askForGrouping = false);
0072 };
0073 
0074 } // namespace Digikam
0075 
0076 #endif // DIGIKAM_IMPORT_DRAG_DROP_H