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

KDE3Support

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
K3URLDrag Class Reference

#include <k3urldrag.h>

Inheritance diagram for K3URLDrag:
Inheritance graph
[legend]

Public Member Functions

 K3URLDrag (const KUrl::List &urls, QWidget *dragSource=0)
 
 K3URLDrag (const KUrl::List &urls, const QMap< QString, QString > &metaData, QWidget *dragSource=0)
 
virtual ~K3URLDrag ()
 
virtual QByteArray encodedData (const char *mime) const
 
virtual const char * format (int i) const
 
QMap< QString, QString > & metaData ()
 
void setExportAsText (bool exp)
 

Static Public Member Functions

static bool decode (const QMimeSource *e, KUrl::List &urls)
 
static bool decode (const QMimeSource *e, KUrl::List &urls, QMap< QString, QString > &metaData)
 
static bool decode (QStringList const &e, KUrl::List &uris)
 
static K3URLDrag * newDrag (const KUrl::List &urls, QWidget *dragSource=0)
 
static K3URLDrag * newDrag (const KUrl::List &urls, const QMap< QString, QString > &metaData, 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
urlsthe list of URLs
dragSourcethe 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
urlsthe list of URLs
metaDataa map containing meta data
dragSourcethe 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 
)
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
ethe mime source
urlsthe list of urls will be written here
Returns
true if successful, false otherwise

Definition at line 93 of file k3urldrag.cpp.

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
ethe mime source
urlsthe list of urls will be written here
metaDatathe metadata map will be written here
Returns
true if successful, false otherwise

Definition at line 136 of file k3urldrag.cpp.

static bool K3URLDrag::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.

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,
QWidget *  dragSource = 0 
)
static
Deprecated:
Is equivalent with "new K3URLDrag(urls, dragSource, name)".

Definition at line 77 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.

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
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal