KUrl::List

Search for usage in LXR

#include <KUrl>

Inheritance diagram for KUrl::List:

Public Types

enum  DecodeOptions { PreferLocalUrls, PreferKdeUrls }
 

Public Member Functions

 List ()
 
 List (const KUrl &url)
 
 List (const QList< KUrl > &list)
 
 List (const QList< QUrl > &list)
 
 List (const QStringList &list)
 
 operator QList< QUrl > () const
 
 operator QVariant () const
 
void populateMimeData (const KUrl::List &mostLocalUrls, QMimeData *mimeData, const KUrl::MetaDataMap &metaData=MetaDataMap(), MimeDataFlags flags=DefaultMimeDataFlags) const
 
void populateMimeData (QMimeData *mimeData, const KUrl::MetaDataMap &metaData=MetaDataMap(), MimeDataFlags flags=DefaultMimeDataFlags) const
 
QStringList toStringList () const
 
QStringList toStringList (KUrl::AdjustPathOption trailing) const
 
- Public Member Functions inherited from QList< KUrl >
 QList (const QList< KUrl > &other)
 
 QList (InputIterator first, InputIterator last)
 
 QList (QList< KUrl > &&other)
 
 QList (std::initializer_list< KUrl > args)
 
void append (const KUrl &value)
 
void append (const QList< KUrl > &value)
 
const KUrlat (int i) const const
 
KUrlback ()
 
const KUrlback () const const
 
QList::iterator begin ()
 
QList::const_iterator begin () const const
 
QList::const_iterator cbegin () const const
 
QList::const_iterator cend () const const
 
void clear ()
 
QList::const_iterator constBegin () const const
 
QList::const_iterator constEnd () const const
 
const KUrlconstFirst () const const
 
const KUrlconstLast () const const
 
bool contains (const KUrl &value) const const
 
int count () const const
 
int count (const KUrl &value) const const
 
QList::const_reverse_iterator crbegin () const const
 
QList::const_reverse_iterator crend () const const
 
bool empty () const const
 
QList::iterator end ()
 
QList::const_iterator end () const const
 
bool endsWith (const KUrl &value) const const
 
QList::iterator erase (QList::iterator begin, QList::iterator end)
 
QList::iterator erase (QList::iterator pos)
 
KUrlfirst ()
 
const KUrlfirst () const const
 
KUrlfront ()
 
const KUrlfront () const const
 
int indexOf (const KUrl &value, int from) const const
 
void insert (int i, const KUrl &value)
 
QList::iterator insert (QList::iterator before, const KUrl &value)
 
bool isEmpty () const const
 
KUrllast ()
 
const KUrllast () const const
 
int lastIndexOf (const KUrl &value, int from) const const
 
int length () const const
 
QList< KUrlmid (int pos, int length) const const
 
void move (int from, int to)
 
bool operator!= (const QList< KUrl > &other) const const
 
QList< KUrloperator+ (const QList< KUrl > &other) const const
 
QList< KUrl > & operator+= (const KUrl &value)
 
QList< KUrl > & operator+= (const QList< KUrl > &other)
 
bool operator< (const QList< KUrl > &lhs, const QList< KUrl > &rhs)
 
QList< KUrl > & operator<< (const KUrl &value)
 
QList< KUrl > & operator<< (const QList< KUrl > &other)
 
QDataStreamoperator<< (QDataStream &out, const QList< KUrl > &list)
 
bool operator<= (const QList< KUrl > &lhs, const QList< KUrl > &rhs)
 
QList< KUrl > & operator= (const QList< KUrl > &other)
 
QList< KUrl > & operator= (QList< KUrl > &&other)
 
bool operator== (const QList< KUrl > &other) const const
 
bool operator> (const QList< KUrl > &lhs, const QList< KUrl > &rhs)
 
bool operator>= (const QList< KUrl > &lhs, const QList< KUrl > &rhs)
 
QDataStreamoperator>> (QDataStream &in, QList< KUrl > &list)
 
KUrloperator[] (int i)
 
const KUrloperator[] (int i) const const
 
void pop_back ()
 
void pop_front ()
 
void prepend (const KUrl &value)
 
void push_back (const KUrl &value)
 
void push_front (const KUrl &value)
 
uint qHash (const QList< KUrl > &key, uint seed)
 
QList::reverse_iterator rbegin ()
 
QList::const_reverse_iterator rbegin () const const
 
int removeAll (const KUrl &value)
 
void removeAt (int i)
 
void removeFirst ()
 
void removeLast ()
 
bool removeOne (const KUrl &value)
 
QList::reverse_iterator rend ()
 
QList::const_reverse_iterator rend () const const
 
void replace (int i, const KUrl &value)
 
void reserve (int alloc)
 
int size () const const
 
bool startsWith (const KUrl &value) const const
 
void swap (int i, int j)
 
void swap (QList< KUrl > &other)
 
void swapItemsAt (int i, int j)
 
KUrl takeAt (int i)
 
KUrl takeFirst ()
 
KUrl takeLast ()
 
QSet< KUrltoSet () const const
 
std::list< KUrltoStdList () const const
 
QVector< KUrltoVector () const const
 
KUrl value (int i) const const
 
KUrl value (int i, const KUrl &defaultValue) const const
 

Static Public Member Functions

static bool canDecode (const QMimeData *mimeData)
 
static KUrl::List fromMimeData (const QMimeData *mimeData, DecodeOptions decodeOptions=PreferKdeUrls, KUrl::MetaDataMap *metaData=nullptr)
 
static QStringList mimeDataTypes ()
 
- Static Public Member Functions inherited from QList< KUrl >
QList< KUrlfromSet (const QSet< KUrl > &set)
 
QList< KUrlfromStdList (const std::list< KUrl > &list)
 
QList< KUrlfromVector (const QVector< KUrl > &vector)
 

Additional Inherited Members

- Public Attributes inherited from QList< KUrl >
typedef const_pointer
 
typedef const_reference
 
typedef const_reverse_iterator
 
typedef ConstIterator
 
typedef difference_type
 
typedef Iterator
 
typedef pointer
 
typedef reference
 
typedef reverse_iterator
 
typedef size_type
 
typedef value_type
 

Detailed Description

KUrl::List is a QList that contains KUrls with a few convenience methods.

See also
KUrl
QList

Definition at line 143 of file kurl.h.

Member Enumeration Documentation

◆ DecodeOptions

Flags to be used in fromMimeData.

Since
4.2.3
Deprecated:
since 5.0, use KUrlMimeData
Enumerator
PreferLocalUrls 

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.

PreferKdeUrls 

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 288 of file kurl.h.

Constructor & Destructor Documentation

◆ List() [1/5]

KUrl::List::List ( )
inline

Creates an empty List.

Definition at line 149 of file kurl.h.

◆ List() [2/5]

KUrl::List::List ( const KUrl url)

Creates a list that contains the given URL as only item.

Parameters
urlthe url to add.

Definition at line 192 of file kurl.cpp.

◆ List() [3/5]

KUrl::List::List ( const QStringList list)

Creates a list that contains the URLs from the given list of strings.

Parameters
listthe list containing the URLs as strings

Definition at line 209 of file kurl.cpp.

◆ List() [4/5]

KUrl::List::List ( const QList< KUrl > &  list)

Creates a list that contains the URLs from the given QList<KUrl>.

Parameters
listthe list containing the URLs

Definition at line 197 of file kurl.cpp.

◆ List() [5/5]

KUrl::List::List ( const QList< QUrl > &  list)

Creates a list that contains the URLs from the given QList<KUrl>.

Parameters
listthe list containing the URLs
Since
4.7

Definition at line 202 of file kurl.cpp.

Member Function Documentation

◆ canDecode()

bool KUrl::List::canDecode ( const QMimeData mimeData)
static

Return true if mimeData contains URI data.

Deprecated:
since 5.0, use QMimeData::hasUrls

Definition at line 274 of file kurl.cpp.

◆ fromMimeData()

KUrl::List KUrl::List::fromMimeData ( const QMimeData mimeData,
DecodeOptions  decodeOptions = PreferKdeUrls,
KUrl::MetaDataMap metaData = nullptr 
)
static

Extract a list of KUrls from the contents of mimeData.

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

Parameters
mimeDatathe mime data to extract from; cannot be 0
decodeOptionsoptions for decoding
metaDataoptional pointer to a map holding the metadata
Returns
the list of urls
Since
4.2.3
Deprecated:
since 5.0, use KUrlMimeData::urlsFromMimeData

Definition at line 284 of file kurl.cpp.

◆ mimeDataTypes()

QStringList KUrl::List::mimeDataTypes ( )
static

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

Deprecated:
since 5.0, use KUrlMimeData::mimeDataTypes

Definition at line 279 of file kurl.cpp.

◆ operator QList< QUrl >()

KUrl::List::operator QList< QUrl > ( ) const

Converts this KUrl::List into a list of QUrl instances.

Since
4.7

Definition at line 300 of file kurl.cpp.

◆ operator QVariant()

KUrl::List::operator QVariant ( ) const

Converts this KUrl::List to a QVariant, this allows to use KUrl::List in QVariant() constructor.

Definition at line 295 of file kurl.cpp.

◆ populateMimeData() [1/2]

void KUrl::List::populateMimeData ( const KUrl::List mostLocalUrls,
QMimeData mimeData,
const KUrl::MetaDataMap metaData = MetaDataMap(),
MimeDataFlags  flags = DefaultMimeDataFlags 
) const

Adds URLs into the given QMimeData.

This should add both the KDE-style URLs (eg: desktop:/foo) and the "most local" version of the URLs (eg: file:///home/jbloggs/Desktop/foo) to the mimedata.

This method should be called on the KDE-style URLs.

QMimeData* mimeData = new QMimeData();
KUrl::List kdeUrls;
kdeUrls << "desktop:/foo";
kdeUrls << "desktop:/bar";
KUrl::List normalUrls;
normalUrls << "file:///home/jbloggs/Desktop/foo";
normalUrls << "file:///home/jbloggs/Desktop/bar";
kdeUrls.populateMimeData(normalUrls, mimeData);
Parameters
mostLocalUrlsthe "most local" urls
mimeDatathe mime data object to populate
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)
flagsset NoTextExport to prevent setting plain/text data into mimeData.
Since
4.2
Deprecated:
since 5.0, use KUrlMimeData::setUrls, followed by KUrlMimeData::setMetaData if you have metadata.

Definition at line 257 of file kurl.cpp.

◆ populateMimeData() [2/2]

void KUrl::List::populateMimeData ( QMimeData mimeData,
const KUrl::MetaDataMap metaData = MetaDataMap(),
MimeDataFlags  flags = DefaultMimeDataFlags 
) const

Adds URLs data into the given QMimeData.

By default, populateMimeData 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 adding other mime data which provides better plain text data.

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

Parameters
mimeDatathe QMimeData instance used to drag or copy this URL
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)
flagsset NoTextExport to prevent setting plain/text data into mimeData
Deprecated:
since 5.0, use QMimeData::setUrls, followed by KUrlMimeData::setMetaData if you have metadata.

Definition at line 250 of file kurl.cpp.

◆ toStringList() [1/2]

QStringList KUrl::List::toStringList ( ) const

Converts the URLs of this list to a list of strings.

Returns
the list of strings

Definition at line 218 of file kurl.cpp.

◆ toStringList() [2/2]

QStringList KUrl::List::toStringList ( KUrl::AdjustPathOption  trailing) const

Converts the URLs of this list to a list of strings.

Parameters
trailinguse to add or remove a trailing slash to/from the path.
Returns
the list of strings
Since
4.6

Definition at line 223 of file kurl.cpp.


The documentation for this class was generated from the following files:
void populateMimeData(QMimeData *mimeData, const KUrl::MetaDataMap &metaData=MetaDataMap(), MimeDataFlags flags=DefaultMimeDataFlags) const
Adds URLs data into the given QMimeData.
Definition: kurl.cpp:250
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:56:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.