]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/draganddrophelper.h
Merge branch 'release/22.04'
[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 <QUrl>
15
16 class QDropEvent;
17 class QWidget;
18 namespace KIO { class DropJob; }
19
20 class DOLPHIN_EXPORT DragAndDropHelper
21 {
22 public:
23 /**
24 * Handles the dropping of URLs to the given destination. A context menu
25 * with the options 'Move Here', 'Copy Here', 'Link Here' and 'Cancel' is
26 * offered to the user. The drag destination must represent a directory or
27 * a desktop-file, otherwise the dropping gets ignored.
28 *
29 * @param destUrl URL of the item destination. Is used only if destItem::isNull()
30 * is true.
31 * @param event Drop event.
32 * @param window Widget where the drop happened, will be used as parent of the drop menu.
33 * @return KIO::DropJob pointer or null in case the destUrl is contained
34 * in the mimeData url list.
35 */
36 static KIO::DropJob* dropUrls(const QUrl& destUrl,
37 QDropEvent* event,
38 QWidget *window);
39
40 /**
41 * @return True if destUrl is contained in the urls parameter.
42 */
43 static bool urlListMatchesUrl(const QList<QUrl>& urls, const QUrl& destUrl);
44
45 /**
46 * clear the internal cache.
47 */
48 static void clearUrlListMatchesUrlCache();
49 private:
50 /**
51 * Stores the results of the expensive checks made in urlListMatchesUrl.
52 */
53 static QHash<QUrl, bool> m_urlListMatchesUrlCache;
54 };
55
56 #endif