KUrlComboBox

KDE 4.7 PyKDE API Reference

- KDE's Python API

# KUrlComboBox Class Reference

`from PyKDE4.kio import *`

Inherits: KComboBox → QComboBox → QWidget → QObject

## Detailed Description

This combobox shows a number of recent URLs/directories, as well as some default directories. It will manage the default dirs root-directory, home-directory and Desktop-directory, as well as a number of URLs set via setUrls() and one additional entry to be set via setUrl().

This widget forces the layout direction to be Qt.LeftToRight instead of inheriting the layout direction like a normal widget. This means that even in RTL desktops the widget will be displayed in LTR mode, as generally URLs are LTR by nature.

A combo box showing a number of recent URLs/directories

Author:
  Carsten Pfeiffer <pfeiffer@kde.org>

## Enumerations
Mode | { Files, Directories, Both }
OverLoadResolving | { RemoveTop, RemoveBottom }
## Signals
| urlActivated (KUrl url)
## Methods
| __init__ (self, KUrlComboBox.Mode mode, QWidget parent=0)
| __init__ (self, KUrlComboBox.Mode mode, bool rw, QWidget parent=0)
| __init__ (self, KUrlComboBox a0)
| addDefaultUrl (self, KUrl url, QString text=QString())
| addDefaultUrl (self, KUrl url, QIcon icon, QString text=QString())
int | maxItems (self)
| mouseMoveEvent (self, QMouseEvent event)
| mousePressEvent (self, QMouseEvent event)
| removeUrl (self, KUrl url, bool checkDefaultURLs=1)
| setCompletionObject (self, KCompletion compObj, bool hsig=1)
| setDefaults (self)
| setMaxItems (self, int a0)
| setUrl (self, KUrl url)
| setUrls (self, QStringList urls)
| setUrls (self, QStringList urls, KUrlComboBox.OverLoadResolving remove)
QStringList | urls (self)

## Signal Documentation

urlActivated | ( | KUrl | url
| ) |  |  |

Emitted when an item was clicked at.

Parameters:

  | url | is the url of the now current item. If it is a local url, it won't have a protocol (file:/), otherwise it will.

Signal syntax:
  `QObject.connect(source, SIGNAL("urlActivated(const KUrl&)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | KUrlComboBox.Mode | mode,
|  | QWidget | parent=0
| ) |  |  |

Constructs a KUrlComboBox.

Parameters:

  | mode | is either Files, Directories or Both and controls the following behavior:

- Files all inserted URLs will be treated as files, therefore the
url shown in the combo will never show a trailing / the icon will be the one associated with the file's mimetype.
- Directories all inserted URLs will be treated as directories, will
have a trailing slash in the combobox. The current directory will show the "open folder" icon, other directories the "folder" icon.
- Both Don't mess with anything, just show the url as given.

Parameters:

  | parent | The parent object of this widget.

__init__ | ( | self, |
|  | KUrlComboBox.Mode | mode,
|  | bool | rw,
|  | QWidget | parent=0
| ) |  |  |

__init__ | ( | self, |
|  | KUrlComboBox | a0
| ) |  |  |

addDefaultUrl | ( | self, |
|  | KUrl | url,
|  | QString | text=QString()
| ) |  |  |

Adds a url that will always be shown in the combobox, it can't be "rotated away". Default urls won't be returned in urls() and don't have to be set via setUrls(). If you don't need to specify a pixmap, use the overloaded method without the pixmap parameter. Default URLs will be inserted into the combobox by setDefaults()

addDefaultUrl | ( | self, |
|  | KUrl | url,
|  | QIcon | icon,
|  | QString | text=QString()
| ) |  |  |

Adds a url that will always be shown in the combobox, it can't be "rotated away". Default urls won't be returned in urls() and don't have to be set via setUrls(). If you don't need to specify a pixmap, use the overloaded method without the pixmap parameter. Default URLs will be inserted into the combobox by setDefaults()

int maxItems | ( |  | self ) |

Returns:
  the maximum of items the combobox handles.

See also:
  setMaxItems

mouseMoveEvent | ( | self, |
|  | QMouseEvent | event
| ) |  |  |

mousePressEvent | ( | self, |
|  | QMouseEvent | event
| ) |  |  |

removeUrl | ( | self, |
|  | KUrl | url,
|  | bool | checkDefaultURLs=1
| ) |  |  |

Removes any occurrence of url. If checkDefaultUrls is false default-urls won't be removed.

setCompletionObject | ( | self, |
|  | KCompletion | compObj,
|  | bool | hsig=1
| ) |  |  |

Reimplemented from KComboBox (from KCompletion)

Internal:

setDefaults | ( |  | self ) |

Clears all items and inserts the default urls into the combo. Will be called implicitly upon the first call to setUrls() or setUrl()

See also:
  addDefaultUrl

setMaxItems | ( | self, |
|  | int | a0
| ) |  |  |

Sets how many items should be handled and displayed by the combobox.

See also:
  maxItems

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

Sets the current url. This combo handles exactly one url additionally to the default items and those set via setUrls(). So you can call setUrl() as often as you want, it will always replace the previous one set via setUrl(). If url is already in the combo, the last item will stay there and the existing item becomes the current item. The current item will always have the open-directory-pixmap as icon.

Note that you won't receive any signals, e.g. textChanged(), returnPressed() or activated() upon calling this method.

setUrls | ( | self, |
|  | QStringList | urls
| ) |  |  |

Inserts urls into the combobox below the "default urls" (see addDefaultUrl).

If the list of urls contains more items than maxItems, the remove parameter determines whether the first or last items will be stripped.

setUrls | ( | self, |
|  | QStringList | urls,
|  | KUrlComboBox.OverLoadResolving | remove
| ) |  |  |

Inserts urls into the combobox below the "default urls" (see addDefaultUrl).

If the list of urls contains more items than maxItems, the remove parameter determines whether the first or last items will be stripped.

QStringList urls | ( |  | self ) |

Returns:
  a list of all urls currently handled. The list contains at most maxItems() items. Use this to save the list of urls in a config-file and reinsert them via setUrls() next time. Note that all default urls set via addDefaultUrl() are not returned, they will automatically be set via setUrls() or setUrl(). You will always get fully qualified urls, i.e. with protocol like file:/

## Enumeration Documentation

Mode

This enum describes which kind of items is shown in the combo box.

Enumerator:

  Reading |
  Writing |

OverLoadResolving

This Enumeration is used in setUrl() to determine which items will be removed when the given list is larger than maxItems().

- RemoveTop means that items will be removed from top
- RemoveBottom means, that items will be removed from the bottom

Enumerator:

  RemoveTop |
  RemoveBottom |