digiKam
importdragdrop.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2012-09-07
7  * Description : Qt Model for ImportUI - drag and drop handling
8  *
9  * Copyright (C) 2012 by Islam Wazery <wazery at ubuntu dot com>
10  * Copyright (C) 2013-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_IMPORT_DRAG_DROP_H
26 #define DIGIKAM_IMPORT_DRAG_DROP_H
27 
28 // Qt includes
29 
30 #include <QMenu>
31 
32 // Local includes
33 
35 #include "importimagemodel.h"
36 #include "album.h"
37 #include "digikam_export.h"
38 
39 namespace Digikam
40 {
41 
42 class DIGIKAM_GUI_EXPORT ImportDragDropHandler : public AbstractItemDragDropHandler
43 {
44  Q_OBJECT
45 
46 public:
47 
48  explicit ImportDragDropHandler(ImportItemModel* const model);
49 
50  ImportItemModel* model() const;
51 
52  bool dropEvent(QAbstractItemView* view,
53  const QDropEvent* e,
54  const QModelIndex& droppedOn) override;
55 
56  Qt::DropAction accepts(const QDropEvent* e,
57  const QModelIndex& dropIndex) override;
58 
59  QStringList mimeTypes() const override;
60  QMimeData* createMimeData(const QList<QModelIndex>&) override;
61 
62 private:
63 
64  enum DropAction
65  {
66  NoAction,
67  CopyAction,
68  MoveAction,
71  };
72 
73 private:
74 
75  QAction* addGroupAction(QMenu* const menu);
76  QAction* addCancelAction(QMenu* const menu);
77  DropAction copyOrMove(const QDropEvent* e,
78  QWidget* const view,
79  bool allowMove = true,
80  bool askForGrouping = false);
81 };
82 
83 } // namespace Digikam
84 
85 #endif // DIGIKAM_IMPORT_DRAG_DROP_H
Definition: abstractitemdragdrophandler.h:42
Definition: importdragdrop.h:43
Definition: importimagemodel.h:43
Definition: datefolderview.cpp:43
DropAction
Definition: itemdragdrop.cpp:60
@ CopyAction
Definition: itemdragdrop.cpp:62
@ AssignTagAction
Definition: itemdragdrop.cpp:67
@ NoAction
Definition: itemdragdrop.cpp:61
@ MoveAction
Definition: itemdragdrop.cpp:63
GroupAction
Definition: fileactionmngr_p.h:47