kdecore Library API Documentation

KURLDrag Class Reference

This class is to be used instead of QUriDrag when using KURL. More...

#include <kurldrag.h>

Inheritance diagram for KURLDrag:

QUriDrag List of all members.

Public Member Functions

 KURLDrag (const KURL::List &urls, QWidget *dragSource=0, const char *name=0)
 KURLDrag (const KURL::List &urls, const QMap< QString, QString > &metaData, QWidget *dragSource=0, const char *name=0)
virtual ~KURLDrag ()
void setExportAsText (bool exp)
QMap< QString, QString > & metaData ()

Static Public Member Functions

static KURLDragnewDrag (const KURL::List &urls, QWidget *dragSource=0, const char *name=0) KDE_DEPRECATED
static KURLDragnewDrag (const KURL::List &urls, const QMap< QString, QString > &metaData, QWidget *dragSource=0, const char *name=0) KDE_DEPRECATED
static bool decode (const QMimeSource *e, KURL::List &urls)
static bool decode (const QMimeSource *e, KURL::List &urls, QMap< QString, QString > &metaData)
static QString urlToString (const KURL &url)
static KURL stringToUrl (const QCString &s)
static bool decode (QStringList const &e, KURL::List &uris)

Protected Member Functions

 KURLDrag (const QStrList &urls, const QMap< QString, QString > &metaData, QWidget *dragSource, const char *name) KDE_DEPRECATED
virtual const char * format (int i) const
virtual QByteArray encodedData (const char *mime) const

Detailed Description

This class is to be used instead of QUriDrag when using KURL.

The reason is: QUriDrag (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:

To create a drag object, use the KURLDrag constructor. To handle drops, use QUriDrag::canDecode() and KURLDrag::decode()

Definition at line 44 of file kurldrag.h.


Constructor & Destructor Documentation

KURLDrag::KURLDrag const KURL::List urls,
QWidget dragSource = 0,
const char *  name = 0
 

Constructs an object to drag the list of URLs in urls.

The dragSource and name arguments are passed on to QUriDrag, and the list of urls is converted to UTF-8 before being passed to QUriDrag.

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
name the name of the QObject

Definition at line 37 of file kurldrag.cpp.

Referenced by newDrag().

KURLDrag::KURLDrag const KURL::List urls,
const QMap< QString, QString > &  metaData,
QWidget dragSource = 0,
const char *  name = 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
name the name of the QObject
See also:
metaData()

Definition at line 43 of file kurldrag.cpp.

KURLDrag::KURLDrag const QStrList urls,
const QMap< QString, QString > &  metaData,
QWidget dragSource,
const char *  name
[protected]
 

Deprecated:
Use a KURLDrag constructor with a KURL::List

Definition at line 268 of file kurldrag.cpp.


Member Function Documentation

void KURLDrag::setExportAsText bool  exp  ) 
 

By default, KURLDrag 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 KURLDrag in a KMultipleDrag and another component of the multiple-drag provides better plain text data. In such a case, setExportAsText( false ) should be called.

Since:
3.4

Definition at line 68 of file kurldrag.cpp.

KURLDrag * KURLDrag::newDrag const KURL::List urls,
QWidget dragSource = 0,
const char *  name = 0
[static]
 

Deprecated:
Is equivalent with "new KURLDrag(urls, dragSource, name)".

Definition at line 76 of file kurldrag.cpp.

References KURLDrag().

KURLDrag * KURLDrag::newDrag const KURL::List urls,
const QMap< QString, QString > &  metaData,
QWidget dragSource = 0,
const char *  name = 0
[static]
 

Deprecated:
Is equivalent with "new KURLDrag(urls, metaData, dragSource, name)".

Definition at line 81 of file kurldrag.cpp.

References KURLDrag().

QMap<QString, QString>& KURLDrag::metaData  )  [inline]
 

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 100 of file kurldrag.h.

bool KURLDrag::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 87 of file kurldrag.cpp.

References QValueList::append(), QValueList::clear(), QUriDrag::decode(), QValueList::isEmpty(), KURL::isValid(), and stringToUrl().

Referenced by decode().

bool KURLDrag::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 104 of file kurldrag.cpp.

References decode(), QMimeSource::encodedData(), QMap::replace(), and QStringList::split().

QString KURLDrag::urlToString const KURL url  )  [static]
 

Converts a URL to a string representation suitable for dragging.

Since:
3.2

Definition at line 237 of file kurldrag.cpp.

References KURL::isLocalFile(), KGlobal::locale(), QString::mid(), KURL::path(), KURL::protocol(), QString::startsWith(), and KURL::url().

KURL KURLDrag::stringToUrl const QCString s  )  [static]
 

Converts a string used for dragging to a URL.

Since:
3.2

Definition at line 229 of file kurldrag.cpp.

References KGlobal::locale().

Referenced by decode(), and encodedData().

bool KURLDrag::decode QStringList const &  e,
KURL::List uris
[static]
 

Convenience method that decodes the contents of e into a list of KURLs for Qt versions without a MIME clipboard.

Decoding will fail if at least one value in the list is not a valid KURL.

Definition at line 131 of file kurldrag.cpp.

References QValueList::append(), QValueList::clear(), QValueList::isEmpty(), and KURL::isValid().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Jan 23 19:32:17 2006 by doxygen 1.4.3 written by Dimitri van Heesch, © 1997-2003