File indexing completed on 2023-11-26 07:34:17
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2000-2005 David Faure <faure@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef KIO_PASTE_H 0009 #define KIO_PASTE_H 0010 0011 #include "kiowidgets_export.h" 0012 #include <QString> 0013 class QWidget; 0014 class QUrl; 0015 class QMimeData; 0016 class KFileItem; 0017 0018 namespace KIO 0019 { 0020 class Job; 0021 class CopyJob; 0022 0023 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 4) 0024 /** 0025 * Pastes the content of the clipboard to the given destination URL. 0026 * URLs are treated separately (performing a file copy) 0027 * from other data (which is saved into a file after asking the user 0028 * to choose a filename and the preferred data format) 0029 * 0030 * @param destURL the URL to receive the data 0031 * @param widget parent widget to use for dialogs 0032 * @param move true to move the data, false to copy -- now ignored and handled automatically 0033 * @return the job that handles the operation 0034 * @deprecated since 5.4, use KIO::paste() from <KIO/PasteJob> (which takes care of undo/redo too) 0035 */ 0036 KIOWIDGETS_EXPORT 0037 KIOWIDGETS_DEPRECATED_VERSION(5, 4, "Use KIO::paste(...) from <KIO/PasteJob>") 0038 Job *pasteClipboard(const QUrl &destURL, QWidget *widget, bool move = false); 0039 #endif 0040 0041 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 4) 0042 /** 0043 * Save the given mime @p data to the given destination URL 0044 * after offering the user to choose a data format. 0045 * This is the method used when handling drops (of anything else than URLs) 0046 * onto dolphin and konqueror. 0047 * 0048 * @param data the QMimeData, usually from a QDropEvent 0049 * @param destUrl the URL of the directory where the data will be pasted. 0050 * The filename to use in that directory is prompted by this method. 0051 * @param dialogText the text to show in the dialog 0052 * @param widget parent widget to use for dialogs 0053 * 0054 * @see pasteClipboard() 0055 * @deprecated since 5.4, use KIO::paste() from <KIO/PasteJob> (which takes care of undo/redo too) 0056 */ 0057 KIOWIDGETS_EXPORT 0058 KIOWIDGETS_DEPRECATED_VERSION(5, 4, "Use KIO::paste(...) from <KIO/PasteJob>") 0059 Job *pasteMimeData(const QMimeData *data, const QUrl &destUrl, const QString &dialogText, QWidget *widget); 0060 #endif 0061 0062 /** 0063 * Returns true if pasteMimeData will find any interesting format in @p data. 0064 * You can use this method to enable/disable the paste action appropriately. 0065 * @since 5.0 (was called canPasteMimeSource before) 0066 */ 0067 KIOWIDGETS_EXPORT bool canPasteMimeData(const QMimeData *data); 0068 0069 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 4) 0070 /** 0071 * Returns the text to use for the Paste action, when the application supports 0072 * pasting files, urls, and clipboard data, using pasteClipboard(). 0073 * @return a string suitable for QAction::setText, or an empty string if pasting 0074 * isn't possible right now. 0075 * @deprecated since 5.4, use pasteActionText(const QMimeData *, bool*, const KFileItem &) 0076 */ 0077 KIOWIDGETS_EXPORT 0078 KIOWIDGETS_DEPRECATED_VERSION(5, 4, "Use KIO::pasteActionText(const QMimeData *, bool*, const KFileItem &)") 0079 QString pasteActionText(); 0080 #endif 0081 0082 /** 0083 * Returns the text to use for the Paste action, when the application supports 0084 * pasting files, urls, and clipboard data, using pasteClipboard(). 0085 * @param mimeData the mime data, usually QApplication::clipboard()->mimeData(). 0086 * @param enable output parameter, to be passed to QAction::setEnabled. 0087 * The pointer must be non-null, and in return the function will always set its value. 0088 * @param destItem item representing the directory into which the clipboard data 0089 * or items would be pasted. Used to find out about permissions in that directory. 0090 * @return a string suitable for QAction::setText 0091 * @since 5.4 0092 */ 0093 KIOWIDGETS_EXPORT QString pasteActionText(const QMimeData *mimeData, bool *enable, const KFileItem &destItem); 0094 0095 /** 0096 * Add the information whether the files were cut, into the mimedata. 0097 * @param mimeData pointer to the mimeData object to be populated. Must not be null. 0098 * @param cut if true, the user selected "cut" (saved as application/x-kde-cutselection in the mimedata). 0099 * @since 5.2 0100 */ 0101 KIOWIDGETS_EXPORT void setClipboardDataCut(QMimeData *mimeData, bool cut); 0102 0103 /** 0104 * Returns true if the URLs in @p mimeData were cut by the user. 0105 * This should be called when pasting, to choose between moving and copying. 0106 * @since 5.2 0107 */ 0108 KIOWIDGETS_EXPORT bool isClipboardDataCut(const QMimeData *mimeData); 0109 0110 } 0111 0112 #endif