KDE 4.7 PyKDE API Reference

- KDE's Python API

# KBookmark Class Reference

`from PyKDE4.kio import *`

## Detailed Description

## Enumerations

MetaDataOverwriteMode | { OverwriteMetaData, DontOverwriteMetaData }

## Methods

| __init__ (self)
| __init__ (self, QDomElement elem)
QString | address (self)
QString | description (self)
QString | fullText (self)
bool | hasParent (self)
QString | icon (self)
QDomElement | internalElement (self)
bool | isGroup (self)
bool | isNull (self)
bool | isSeparator (self)
QDomNode | metaData (self, QString owner, bool create)
QString | metaDataItem (self, QString key)
QString | mimeType (self)
bool | operator == (self, KBookmark rhs)
KBookmarkGroup | parentGroup (self)
| populateMimeData (self, QMimeData mimeData)
int | positionInParent (self)
| setDescription (self, QString description)
| setFullText (self, QString fullText)
| setIcon (self, QString icon)
| setMetaDataItem (self, QString key, QString value, KBookmark.MetaDataOverwriteMode mode=KBookmark.OverwriteMetaData)
| setMimeType (self, QString mimeType)
| setShowInToolbar (self, bool show)
| setUrl (self, KUrl url)
bool | showInToolbar (self)
QString | text (self)
KBookmarkGroup | toGroup (self)
| updateAccessMetadata (self)
KUrl | url (self)

## Static Methods

QString | commonParent (QString A, QString B)
QString | nextAddress (QString address)
QString | parentAddress (QString address)
long | positionInParent (QString address)
QString | previousAddress (QString address)
KBookmark | standaloneBookmark (QString text, KUrl url, QString icon=QString())

## Method Documentation

__init__ | ( |  | self ) |

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.

__init__ | ( | self, |
|  | QDomElement | elem
| ) |  |  |

Creates the KBookmark wrapper for

Parameters:

  | elem | Mostly for internal usage.

QString address | ( |  | self ) |

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.

QString description | ( |  | self ) |

Returns:
  Description of the bookmark

Since:
  4.4

QString fullText | ( |  | self ) |

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

bool hasParent | ( |  | self ) |

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 icon | ( |  | self ) |

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

QDomElement internalElement | ( |  | self ) |

Internal:
  for KEditBookmarks

bool isGroup | ( |  | self ) |

Whether the bookmark is a group or a normal bookmark

bool isNull | ( |  | self ) |

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 isSeparator | ( |  | self ) |

Whether the bookmark is a separator

QDomNode metaData | ( | self, |
|  | QString | owner,
|  | bool | create
| ) |  |  |

Returns:
  the metadata container node for a certain matadata owner

Since:
  4.1

QString metaDataItem | ( | self, |
|  | QString | key
| ) |  |  |

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

Parameters:

  | key | Name of the metadata item

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

QString mimeType | ( |  | self ) |

Returns:
  Mime-Type of this item

Since:
  4.1

bool operator == | ( | self, |
|  | KBookmark | rhs
| ) |  |  |

Comparison operator

KBookmarkGroup parentGroup | ( |  | self ) |

Returns:
  the group containing this bookmark

populateMimeData | ( | self, |
|  | QMimeData | mimeData
| ) |  |  |

Adds this bookmark into the given QMimeData.

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

Parameters:

  | mimeData | the QMimeData instance used to drag or copy this bookmark

int positionInParent | ( |  | self ) |

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

setDescription | ( | self, |
|  | QString | description
| ) |  |  |

Set the description of the bookmark

Parameters:

  | description |

Since:
  4.4

setFullText | ( | self, |
|  | QString | fullText
| ) |  |  |

Set the text shown for the bookmark.

Parameters:

  | fullText | the new bookmark title

setIcon | ( | self, |
|  | QString | icon
| ) |  |  |

Set the icon name of the bookmark

Parameters:

  | icon | the new icon name for this bookmark

setMetaDataItem | ( | self, |
|  | QString | key,
|  | QString | value,
|  | KBookmark.MetaDataOverwriteMode | mode=KBookmark.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").

Parameters:

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

setMimeType | ( | self, |
|  | QString | mimeType
| ) |  |  |

Set the Mime-Type of this item

Parameters:

  | Mime-Type |

Since:
  4.1

setShowInToolbar | ( | self, |
|  | bool | show
| ) |  |  |

Set whether this bookmark is show in a filterd toolbar

setUrl | ( | self, |
|  | KUrl | url
| ) |  |  |

Set the URL of the bookmark

Parameters:

  | url | the new bookmark URL

bool showInToolbar | ( |  | self ) |

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

QString text | ( |  | self ) |

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

KBookmarkGroup toGroup | ( |  | self ) |

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

updateAccessMetadata | ( |  | self ) |

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

KUrl url | ( |  | self ) |

URL contained by the bookmark

## Static Method Documentation

QString commonParent | ( | QString | A,
|  | QString | B
| ) |  |  |

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

QString nextAddress | ( | QString | address
| ) |  |  |

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

QString parentAddress | ( | QString | address
| ) |  |  |

Returns:
  address of parent

long positionInParent | ( | QString | address
| ) |  |  |

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

QString previousAddress | ( | QString | address
| ) |  |  |

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

KBookmark standaloneBookmark | ( | QString | text,
|  | KUrl | url,
|  | QString | icon=QString()
| ) |  |  |

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

## Enumeration Documentation

MetaDataOverwriteMode

Enumerator:

  OverwriteMetaData |
  DontOverwriteMetaData |