# kdecore Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KURLDrag Class Reference

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

`#include <kurldrag.h>`

Inheritance diagram for KURLDrag:

[legend]
Collaboration diagram for KURLDrag:

[legend]
List of all members.

## Public Member Functions

| KURLDrag (const KURL::List &urls, QWidget *dragSource, const char *name)
| Constructs an object to drag the list of URLs in `urls`.
| KURLDrag (const KURL::List &urls, const QMap< QString, QString > &metaData, QWidget *dragSource, const char *name)
| Constructs an object to drag the list of URLs in `urls`.
QMap< QString, QString > & | metaData ()
| Meta-data to associate with those URLs (to be used after newDrag).

## Static Public Member Functions

KURLDrag * | newDrag (const KURL::List &urls, QWidget *dragSource=0, const char *name=0)
| This class or method is obsolete, it is provided for compatibility only. Is equivalent with "new KURLDrag(urls, dragSource, name)".
KURLDrag * | newDrag (const KURL::List &urls, const QMap< QString, QString > &metaData, QWidget *dragSource=0, const char *name=0)
| This class or method is obsolete, it is provided for compatibility only. Is equivalent with "new KURLDrag(urls, metaData, dragSource, name)".
bool | decode (const QMimeSource *e, KURL::List &urls)
| Convenience method that decodes the contents of `e` into a list of KURLs.
bool | decode (const QMimeSource *e, KURL::List &urls, QMap< QString, QString > &metaData)
| Convenience method that decodes the contents of `e` into a list of KURLs and a set of metadata.

## Protected Member Functions

| KURLDrag (const QStrList &urls, const QMap< QString, QString > &metaData, QWidget *dragSource, const char *name)
| Protected constructor - use newDrag.
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:

- 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).

To create a drag object, use KURLDrag::newDrag() with a list of KURLs. To decode a drop, use KURLDrag::decode() or QUriDrag::decodeLocalFiles().

Definition at line 43 of file kurldrag.h.

## Constructor & Destructor Documentation

KURLDrag::KURLDrag | ( | const KURL::List & | urls,
|  | QWidget * | dragSource,
|  | const char * | name
| ) |

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

Definition at line 25 of file kurldrag.cpp.

References KStdAction::name().

Referenced by newDrag().

KURLDrag::KURLDrag | ( | const KURL::List & | urls,
|  | const QMap< QString, QString > & | metaData,
|  | QWidget * | dragSource,
|  | const char * | name
| ) |

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

See also:
  metaData()

Definition at line 31 of file kurldrag.cpp.

References KStdAction::name().

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

| Protected constructor - use newDrag. Definition at line 122 of file kurldrag.h. References KStdAction::name().

## Member Function Documentation

KURLDrag * KURLDrag::newDrag | ( | const KURL::List & | urls,
|  | QWidget * | dragSource = 0,
|  | const char * | name = 0
| ) | `[static]`

| This class or method is obsolete, it is provided for compatibility only. Is equivalent with "new KURLDrag(urls, dragSource, name)". Definition at line 53 of file kurldrag.cpp. References KURLDrag(), and KStdAction::name().

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

| This class or method is obsolete, it is provided for compatibility only. Is equivalent with "new KURLDrag(urls, metaData, dragSource, name)". Definition at line 58 of file kurldrag.cpp. References KURLDrag(), and KStdAction::name().

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

Meta-data to associate with those URLs (to be used after newDrag).

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 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.

Parameters:

  e | the mime source
  urls | the list of urls will be written here

Returns:
  true if successful, false otherwise

Definition at line 64 of file kurldrag.cpp.

References QValueList< KURL >::append(), and QUriDrag::decode().

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.

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 73 of file kurldrag.cpp.

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

The documentation for this class was generated from the following files:

- kurldrag.h
- kurldrag.cpp

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:51:51 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001