KBookmark Class

A class representing a bookmark. More...

Header: #include <KBookmark>
CMake: find_package(KF6 REQUIRED COMPONENTS Bookmarks)
target_link_libraries(mytarget PRIVATE KF6::Bookmarks)
Inherited By:

KBookmarkGroup

Public Types

class List
enum MetaDataOverwriteMode { OverwriteMetaData, DontOverwriteMetaData }

Public Functions

KBookmark()
KBookmark(const QDomElement &elem)
QString address() const
(since 4.4) QString description() const
QString fullText() const
bool hasParent() const
QString icon() const
bool isGroup() const
bool isNull() const
bool isSeparator() const
(since 4.1) QDomNode metaData(const QString &owner, bool create) const
QString metaDataItem(const QString &key) const
(since 4.1) QString mimeType() const
KBookmarkGroup parentGroup() const
void populateMimeData(QMimeData *mimeData) const
int positionInParent() const
(since 4.4) void setDescription(const QString &description)
void setFullText(const QString &fullText)
void setIcon(const QString &icon)
void setMetaDataItem(const QString &key, const QString &value, KBookmark::MetaDataOverwriteMode mode = OverwriteMetaData)
(since 4.1) void setMimeType(const QString &mimeType)
void setShowInToolbar(bool show)
void setUrl(const QUrl &url)
bool showInToolbar() const
QString text() const
KBookmarkGroup toGroup() const
void updateAccessMetadata()
QUrl url() const
bool operator==(const KBookmark &rhs) const

Static Public Members

QString commonParent(const QString &A, const QString &B)
QString nextAddress(const QString &address)
QString parentAddress(const QString &address)
uint positionInParent(const QString &address)
QString previousAddress(const QString &address)
KBookmark standaloneBookmark(const QString &text, const QUrl &url, const QString &icon)

Detailed Description

Member Type Documentation

enum KBookmark::MetaDataOverwriteMode

ConstantValue
KBookmark::OverwriteMetaData0
KBookmark::DontOverwriteMetaData1

Member Function Documentation

KBookmark::KBookmark()

Constructs a null bookmark, i.e. a bookmark for which isNull() returns true If you want to create a new bookmark use eitehr KBookmarkGroup.addBookmark or if you want an interactive dialog use KBookmarkDialog.

[explicit] KBookmark::KBookmark(const QDomElement &elem)

Creates the KBookmark wrapper for elem Mostly for internal usage.

QString KBookmark::address() const

Return the "address" of this bookmark in the whole tree. This is used when telling other processes about a change in a given bookmark. The encoding of the address is "/4/2", for instance, to designate the 2nd child inside the 4th child of the root bookmark.

[static] QString KBookmark::commonParent(const QString &A, const QString &B)

Returns the common parent of both addresses which has the greatest depth

[since 4.4] QString KBookmark::description() const

Returns Description of the bookmark

This function was introduced in 4.4.

See also setDescription().

QString KBookmark::fullText() const

Text shown for the bookmark, not truncated. You should not use this - this is mainly for keditbookmarks.

See also setFullText().

bool KBookmark::hasParent() const

Returns true if bookmark is contained by a QDomDocument, if not it is most likely that it has become separated and is thus invalid and/or has been deleted from the bookmarks.

QString KBookmark::icon() const

Returns the pixmap file for this bookmark (i.e. the name of the icon)

See also setIcon().

bool KBookmark::isGroup() const

Whether the bookmark is a group or a normal bookmark

bool KBookmark::isNull() const

Returns true if this is a null bookmark. This will never be the case for a real bookmark (in a menu), but it's used for instance as the end condition for KBookmarkGroup::next()

bool KBookmark::isSeparator() const

Whether the bookmark is a separator

[since 4.1] QDomNode KBookmark::metaData(const QString &owner, bool create) const

Returns the metadata container node for a certain metadata owner

This function was introduced in 4.1.

QString KBookmark::metaDataItem(const QString &key) const

Get the value of a specific metadata item (owner = "http://www.kde.org"). a key Name of the metadata item

Returns Value of the metadata item. QString() is returned in case the specified key does not exist.

See also setMetaDataItem().

[since 4.1] QString KBookmark::mimeType() const

Returns Mime-Type of this item

This function was introduced in 4.1.

See also setMimeType().

[static] QString KBookmark::nextAddress(const QString &address)

Returns address of next sibling (e.g. /4/5/2 -> /4/5/3) This doesn't check whether it actually exists

[static] QString KBookmark::parentAddress(const QString &address)

Returns address of parent

KBookmarkGroup KBookmark::parentGroup() const

Returns the group containing this bookmark

void KBookmark::populateMimeData(QMimeData *mimeData) const

Adds this bookmark into the given QMimeData.

Warning: do not call this method multiple times, use KBookmark::List::populateMimeData instead.

mimeData the QMimeData instance used to drag or copy this bookmark

int KBookmark::positionInParent() const

Return the position in the parent, i.e. the last number in the address

[static] uint KBookmark::positionInParent(const QString &address)

Returns position in parent (e.g. /4/5/2 -> 2)

[static] QString KBookmark::previousAddress(const QString &address)

Returns address of previous sibling (e.g. /4/5/2 -> /4/5/1) Returns QString() for a first child

[since 4.4] void KBookmark::setDescription(const QString &description)

Set the description of the bookmark

description

This function was introduced in 4.4.

See also description().

void KBookmark::setFullText(const QString &fullText)

Set the text shown for the bookmark.

fullText the new bookmark title

See also fullText().

void KBookmark::setIcon(const QString &icon)

Set the icon name of the bookmark

icon the new icon name for this bookmark

See also icon().

void KBookmark::setMetaDataItem(const QString &key, const QString &value, KBookmark::MetaDataOverwriteMode mode = OverwriteMetaData)

Change the value of a specific metadata item, or create the given item if it doesn't exist already (owner = "http://www.kde.org").

key Name of the metadata item to change

value Value to use for the specified metadata item

mode Whether to overwrite the item's value if it exists already or not.

See also metaDataItem().

[since 4.1] void KBookmark::setMimeType(const QString &mimeType)

Set the Mime-Type of this item

This function was introduced in 4.1.

See also mimeType().

void KBookmark::setShowInToolbar(bool show)

Set whether this bookmark is show in a filterd toolbar

See also showInToolbar().

void KBookmark::setUrl(const QUrl &url)

Set the URL of the bookmark

url the new bookmark URL

See also url().

bool KBookmark::showInToolbar() const

Returns if the bookmark should be shown in the toolbar (used by the filtered toolbar)

See also setShowInToolbar().

[static] KBookmark KBookmark::standaloneBookmark(const QString &text, const QUrl &url, const QString &icon)

Creates a stand alone bookmark. This is fairly expensive since a new QDom Tree is build.

QString KBookmark::text() const

Text shown for the bookmark If bigger than 40, the text is shortened by replacing middle characters with "..." (see KStringHandler::csqueeze)

KBookmarkGroup KBookmark::toGroup() const

Convert this to a group - do this only if isGroup() returns true.

void KBookmark::updateAccessMetadata()

Updates the bookmarks access metadata Call when a user accesses the bookmark

QUrl KBookmark::url() const

URL contained by the bookmark

See also setUrl().

bool KBookmark::operator==(const KBookmark &rhs) const

Comparison operator