summaryrefslogtreecommitdiffstats
path: root/kio/kio/paste.h
blob: 66975d772a7cb91a77ff6c0185ff0dce0853571d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* This file is part of the KDE libraries
   Copyright (C) 2000-2005 David Faure <faure@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef __kio_paste_h__
#define __kio_paste_h__

#include <tqstring.h>
#include <tqmemarray.h>
#include <kurl.h>
class QWidget;
class QMimeSource;

// KDE4 TODO pass a parent widget to all methods that will display a message box

namespace KIO {
  class Job;
  class CopyJob;

  /**
   * Pastes the content of the clipboard to the given destination URL.
   * URLs are treated separately (performing a file copy)
   * from other data (which is saved into a file after asking the user
   * to choose a filename and the preferred data format)
   *
   * @param destURL the URL to receive the data
   * @param move true to move the data, false to copy
   * @return the job that handles the operation
   * @see pasteData()
   */
  KIO_EXPORT Job *pasteClipboard( const KURL& destURL, bool move = false );

  /**
   * Pastes the given @p data to the given destination URL.
   * NOTE: This method is blocking (uses NetAccess for saving the data).
   * Please consider using pasteDataAsync instead.
   *
   * @param destURL the URL of the directory where the data will be pasted.
   * The filename to use in that directory is prompted by this method.
   * @param data the data to copy
   * @see pasteClipboard()
   */
  KIO_EXPORT void pasteData( const KURL& destURL, const TQByteArray& data );

  /**
   * Pastes the given @p data to the given destination URL.
   * Note that this method requires the caller to have chosen the QByteArray
   * to paste before hand, unlike pasteClipboard and pasteMimeSource.
   *
   * @param destURL the URL of the directory where the data will be pasted.
   * The filename to use in that directory is prompted by this method.
   * @param data the data to copy
   * @see pasteClipboard()
   */
  KIO_EXPORT CopyJob *pasteDataAsync( const KURL& destURL, const TQByteArray& data );

  /**
   * Pastes the given @p data to the given destination URL.
   * Note that this method requires the caller to have chosen the QByteArray
   * to paste before hand, unlike pasteClipboard and pasteMimeSource.
   *
   * @param destURL the URL of the directory where the data will be pasted.
   * The filename to use in that directory is prompted by this method.
   * @param data the data to copy
   * @param dialogText the text to show in the dialog
   * @see pasteClipboard()
   */
  KIO_EXPORT CopyJob *pasteDataAsync( const KURL& destURL, const TQByteArray& data, const TQString& dialogText ); // KDE4: merge with above


  /**
   * Save the given mimesource @p data to the given destination URL
   * after offering the user to choose a data format.
   * This is the method used when handling drops (of anything else than URLs)
   * onto kdesktop and konqueror.
   *
   * @param data the TQMimeSource (e.g. a TQDropEvent)
   * @param destURL the URL of the directory where the data will be pasted.
   * The filename to use in that directory is prompted by this method.
   * @param dialogText the text to show in the dialog
   * @param widget parent widget to use for dialogs
   * @param clipboard whether the TQMimeSource comes from QClipboard. If you
   * use pasteClipboard for that case, you never have to worry about this parameter.
   *
   * @see pasteClipboard()
   *
   * @since 3.5
   */
  KIO_EXPORT CopyJob* pasteMimeSource( TQMimeSource* data, const KURL& destURL,
                                       const TQString& dialogText, TQWidget* widget,
                                       bool clipboard = false );

  /**
   * Checks whether the clipboard contains any URLs.
   * @return true if not
   * Not used anymore, wrong method name, so it will disappear in KDE4.
   */
  KIO_EXPORT_DEPRECATED bool isClipboardEmpty();

  /**
   * Returns the text to use for the Paste action, when the application supports
   * pasting files, urls, and clipboard data, using pasteClipboard().
   * @return a string suitable for KAction::setText, or an empty string if pasting
   * isn't possible right now.
   *
   * @since 3.5
   */
  KIO_EXPORT TQString pasteActionText();
}

#endif