• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDE3Support

K3URLDrag Class Reference

This class is to be used instead of Q3UriDrag when using KUrl. More...

#include <k3urldrag.h>

Inheritance diagram for K3URLDrag:

Inheritance graph
[legend]

List of all members.


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)

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).
To create a drag object, use the K3URLDrag constructor. To handle drops, use Q3UriDrag::canDecode() and K3URLDrag::decode()

Definition at line 46 of file k3urldrag.h.


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 282 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]

Reimplemented from superclass.

Definition at line 181 of file k3urldrag.cpp.

const char * K3URLDrag::format ( int  i  )  const [virtual]

Reimplemented from superclass.

Definition at line 164 of file k3urldrag.cpp.

QMap< QString, QString > & K3URLDrag::metaData (  ) 

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 string used for dragging to a URL.

Definition at line 243 of file k3urldrag.cpp.

QString K3URLDrag::urlToString ( const KUrl &  url  )  [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:
  • k3urldrag.h
  • k3urldrag.cpp

KDE3Support

Skip menu "KDE3Support"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal