KUrlMimeData Namespace Reference


typedef QMap< QString, QStringMetaDataMap


enum  DecodeOptions { PreferLocalUrls, PreferKdeUrls }


KCOREADDONS_EXPORT QStringList mimeDataTypes ()
KCOREADDONS_EXPORT void setMetaData (const MetaDataMap &metaData, QMimeData *mimeData)
KCOREADDONS_EXPORT void setUrls (const QList< QUrl > &urls, const QList< QUrl > &mostLocalUrls, QMimeData *mimeData)
KCOREADDONS_EXPORT QList< QUrlurlsFromMimeData (const QMimeData *mimeData, DecodeOptions decodeOptions=PreferKdeUrls, MetaDataMap *metaData=nullptr)

Detailed Description

Utility functions for using URLs in QMimeData.

In addition to QMimeData::setUrls() and QMimeData::urls(), these functions allow to:

  • Store two sets of URLs, the KDE-specific URLs and the equivalent local-file URLs for compatibility with non-KDE applications
  • Store KIO metadata, such as the HTTP referrer for a given URL (some websites require it for downloading e.g. an image)

Enumeration Type Documentation

Flags to be used in urlsFromMimeData.


When the mimedata contains both KDE-style URLs (eg: desktop:/foo) and the "most local" version of the URLs (eg: file:///home/dfaure/Desktop/foo), decode it as local urls.

Useful in paste/drop operations that end up calling KIO, so that urls from other users work as well.


When the mimedata contains both KDE-style URLs (eg: desktop:/foo) and the "most local" version of the URLs (eg: file:///home/dfaure/Desktop/foo), decode it as the KDE-style URL.

Useful in DnD code e.g. when moving icons, and the kde-style url is used as identifier for the icons.

Definition at line 57 of file kurlmimedata.h.

Function Documentation

QStringList KUrlMimeData::mimeDataTypes ( )

Return the list of mimeTypes that can be decoded by urlsFromMimeData.

Definition at line 50 of file kurlmimedata.cpp.

void KUrlMimeData::setMetaData ( const MetaDataMap metaData,
QMimeData mimeData 
metaDataKIO metadata shipped in the mime data, which is used for instance to set a correct HTTP referrer (some websites require it for downloading e.g. an image)

Definition at line 38 of file kurlmimedata.cpp.

void KUrlMimeData::setUrls ( const QList< QUrl > &  urls,
const QList< QUrl > &  mostLocalUrls,
QMimeData mimeData 

Adds URLs and KIO metadata into the given QMimeData.

WARNING: do not call this method multiple times on the same mimedata object, you can add urls only once. But you can add other things, e.g. images, XML...

mimeDatathe QMimeData instance used to drag or copy this URL

Definition at line 29 of file kurlmimedata.cpp.

QList< QUrl > KUrlMimeData::urlsFromMimeData ( const QMimeData mimeData,
DecodeOptions  decodeOptions = PreferKdeUrls,
MetaDataMap metaData = nullptr 

Extract a list of urls from the contents of mimeData.

Compared to QMimeData::urls(), this method has support for retrieving KDE-specific URLs when urls() would retrieve "most local URLs" instead.

Decoding will fail if mimeData does not contain any URLs, or if at least one extracted URL is not valid.

mimeDatathe mime data to extract from; cannot be 0
decodeOptionsoptions for decoding
metaDataoptional pointer to a map which will hold the metadata after this call
the list of urls

Definition at line 71 of file kurlmimedata.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 22:53:58 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.