KDE3Support
K3URLDrag Class Reference
#include <k3urldrag.h>

Detailed Description
This class is to be used instead of Q3UriDrag when using KUrl.The reason is: Q3UriDrag (and the XDND/W3C standards) expect URLs to be encoded in UTF-8 (unicode), but KUrl uses the current locale by default. The other reasons for using this class are:
- it exports text/plain (for dropping/pasting into lineedits, mails etc.)
- it has support for metadata, shipped as part of the dragobject This is important, for instance to set a correct HTTP referrer (some websites require it for downloading e.g. an image).
Definition at line 46 of file k3urldrag.h.
Public Member Functions | |
virtual QByteArray | encodedData (const char *mime) const |
virtual const char * | format (int i) const |
K3URLDrag (const KUrl::List &urls, const QMap< QString, QString > &metaData, QWidget *dragSource=0) | |
K3URLDrag (const KUrl::List &urls, QWidget *dragSource=0) | |
QMap< QString, QString > & | metaData () |
void | setExportAsText (bool exp) |
virtual | ~K3URLDrag () |
Static Public Member Functions | |
static bool | decode (const QMimeSource *e, KUrl::List &urls, QMap< QString, QString > &metaData) |
static bool | decode (const QMimeSource *e, KUrl::List &urls) |
static K3URLDrag * | newDrag (const KUrl::List &urls, const QMap< QString, QString > &metaData, QWidget *dragSource=0) |
static K3URLDrag * | newDrag (const KUrl::List &urls, QWidget *dragSource=0) |
static KUrl | stringToUrl (const QByteArray &s) |
static QString | urlToString (const KUrl &url) |
Protected Member Functions | |
K3URLDrag (const Q3StrList &urls, const QMap< QString, QString > &metaData, QWidget *dragSource) |
Constructor & Destructor Documentation
K3URLDrag::K3URLDrag | ( | const KUrl::List & | urls, | |
QWidget * | dragSource = 0 | |||
) |
Constructs an object to drag the list of URLs in urls
.
The dragSource
and name
arguments are passed on to Q3UriDrag, and the list of urls is converted to UTF-8 before being passed to Q3UriDrag.
- Parameters:
-
urls the list of URLs dragSource the parent of the QObject. Should be set when doing drag-n-drop, but should be 0 when copying to the clipboard
Definition at line 37 of file k3urldrag.cpp.
K3URLDrag::K3URLDrag | ( | const KUrl::List & | urls, | |
const QMap< QString, QString > & | metaData, | |||
QWidget * | dragSource = 0 | |||
) |
Constructs an object to drag the list of URLs in urls
.
This version also includes metadata.
- Parameters:
-
urls the list of URLs metaData a map containing meta data dragSource the parent of the QObject. Should be set when doing drag-n-drop, but should be 0 when copying to the clipboard
- See also:
- metaData()
Definition at line 43 of file k3urldrag.cpp.
K3URLDrag::~K3URLDrag | ( | ) | [virtual] |
Definition at line 51 of file k3urldrag.cpp.
K3URLDrag::K3URLDrag | ( | const Q3StrList & | urls, | |
const QMap< QString, QString > & | metaData, | |||
QWidget * | dragSource | |||
) | [protected] |
- Deprecated:
- Use a K3URLDrag constructor with a KUrl::List
Definition at line 281 of file k3urldrag.cpp.
Member Function Documentation
bool K3URLDrag::decode | ( | const QMimeSource * | e, | |
KUrl::List & | urls, | |||
QMap< QString, QString > & | metaData | |||
) | [static] |
Convenience method that decodes the contents of e
into a list of KUrls and a set of metadata.
Decoding will fail if at least one decoded value is not a valid KUrl. You should be using this one, if possible.
- Parameters:
-
e the mime source urls the list of urls will be written here metaData the metadata map will be written here
- Returns:
- true if successful, false otherwise
Definition at line 136 of file k3urldrag.cpp.
bool K3URLDrag::decode | ( | const QMimeSource * | e, | |
KUrl::List & | urls | |||
) | [static] |
Convenience method that decodes the contents of e
into a list of KUrls.
Decoding will fail if at least one decoded value is not a valid KUrl.
- Parameters:
-
e the mime source urls the list of urls will be written here
- Returns:
- true if successful, false otherwise
Definition at line 93 of file k3urldrag.cpp.
QByteArray K3URLDrag::encodedData | ( | const char * | mime | ) | const [virtual] |
const char * K3URLDrag::format | ( | int | i | ) | const [virtual] |
Meta-data to associate with those URLs.
This is an alternative way of setting the metadata: either use the constructor to pass it all at once, or use drag->metaData()["key"] = data;
- See also:
- KIO::TransferJob
Definition at line 88 of file k3urldrag.cpp.
K3URLDrag * K3URLDrag::newDrag | ( | const KUrl::List & | urls, | |
const QMap< QString, QString > & | metaData, | |||
QWidget * | dragSource = 0 | |||
) | [static] |
- Deprecated:
- Is equivalent with "new K3URLDrag(urls, metaData, dragSource, name)".
Definition at line 82 of file k3urldrag.cpp.
K3URLDrag * K3URLDrag::newDrag | ( | const KUrl::List & | urls, | |
QWidget * | dragSource = 0 | |||
) | [static] |
- Deprecated:
- Is equivalent with "new K3URLDrag(urls, dragSource, name)".
Definition at line 77 of file k3urldrag.cpp.
void K3URLDrag::setExportAsText | ( | bool | exp | ) |
By default, K3URLDrag also exports the URLs as plain text, for e.g.
dropping onto a text editor. But in some cases this might not be wanted, e.g. if using the K3URLDrag in a KMultipleDrag and another component of the multiple-drag provides better plain text data. In such a case, setExportAsText( false ) should be called.
Definition at line 69 of file k3urldrag.cpp.
KUrl K3URLDrag::stringToUrl | ( | const QByteArray & | s | ) | [static] |
Converts a URL to a string representation suitable for dragging.
Definition at line 251 of file k3urldrag.cpp.
The documentation for this class was generated from the following files: