]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/draganddrophelper.h
Fix uninitialised value
[dolphin.git] / src / views / draganddrophelper.h
1 /*
2 * SPDX-FileCopyrightText: 2007-2011 Peter Penz <peter.penz19@gmail.com>
3 * SPDX-FileCopyrightText: 2007 David Faure <faure@kde.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #ifndef DRAGANDDROPHELPER_H
9 #define DRAGANDDROPHELPER_H
10
11 #include "dolphin_export.h"
12
13 #include <QList>
14 #include <QString>
15 #include <QUrl>
16
17 class QDropEvent;
18 class QMimeData;
19 class QWidget;
20 namespace KIO
21 {
22 class DropJob;
23 }
24
25 class DOLPHIN_EXPORT DragAndDropHelper
26 {
27 public:
28 /**
29 * Handles the dropping of URLs to the given destination. A context menu
30 * with the options 'Move Here', 'Copy Here', 'Link Here' and 'Cancel' is
31 * offered to the user. The drag destination must represent a directory or
32 * a desktop-file, otherwise the dropping gets ignored.
33 *
34 * @param destUrl URL of the item destination. Is used only if destItem::isNull()
35 * is true.
36 * @param event Drop event.
37 * @param window Widget where the drop happened, will be used as parent of the drop menu.
38 * @return KIO::DropJob pointer or null in case the destUrl is contained
39 * in the mimeData url list.
40 */
41 static KIO::DropJob *dropUrls(const QUrl &destUrl, QDropEvent *event, QWidget *window);
42
43 /**
44 * @return True if destUrl is contained in the urls parameter.
45 */
46 static bool urlListMatchesUrl(const QList<QUrl> &urls, const QUrl &destUrl);
47
48 /**
49 * @return True if mimeData contains Ark's drag and drop mime types.
50 */
51 static bool isArkDndMimeType(const QMimeData *mimeData);
52 static QString arkDndServiceMimeType()
53 {
54 return QStringLiteral("application/x-kde-ark-dndextract-service");
55 }
56 static QString arkDndPathMimeType()
57 {
58 return QStringLiteral("application/x-kde-ark-dndextract-path");
59 }
60
61 /**
62 * clear the internal cache.
63 */
64 static void clearUrlListMatchesUrlCache();
65
66 private:
67 /**
68 * Stores the results of the expensive checks made in urlListMatchesUrl.
69 */
70 static QHash<QUrl, bool> m_urlListMatchesUrlCache;
71 };
72
73 #endif