# class KURLComboBox | A ComboBox showing a number of recent URLs/directories. More...
Definition | `#include <kurlcombobox.h>`
Inherits | KComboBox (kdeui) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum Mode { Files = -1, Directories = 1, Both = 0 }

#### Public Methods

- KURLComboBox ( Mode mode, QWidget *parent=0, const char *name=0 )
- KURLComboBox ( Mode mode, bool rw, QWidget *parent=0, const char *name=0 )
- ~KURLComboBox ()
- void setURL ( const KURL& url )
- void setURLs ( QStringList urls )
- QStringList urls () const
- void setMaxItems ( int )
- int maxItems () const
- void addDefaultURL ( const KURL& url, const QString& text = QString::null )
- void addDefaultURL ( const KURL& url, const QPixmap& pix, const QString& text = QString::null )
- void setDefaults ()
- void removeURL ( const KURL& url, bool checkDefaultURLs = true )

#### Signals

- void urlActivated ( const KURL& url )

#### Protected Types

- struct _KURLComboItem
- typedef _KURLComboItem KURLComboItem

#### Protected Methods

- void init ( Mode mode )
- void insertURLItem ( const KURLComboItem * )
- QPixmap getPixmap ( const KURL& url ) const
- void updateItem ( const KURLComboItem *item, int index, const QPixmap& pix)

#### Protected Slots

- void slotActivated ( int )

#### Protected Members

- QList<KURLComboItem> itemList
- QList<KURLComboItem> defaultList
- QMap<int,const KURLComboItem*> itemMapper
- QPixmap opendirPix
- int firstItemIndex

## 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().

enum Mode { Files = -1, Directories = 1, Both = 0 } | ### Mode

KURLComboBox ( Mode mode, QWidget *parent=0, const char *name=0 ) | ### KURLComboBox

Constructs a KURLComboBox.

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

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

KURLComboBox ( Mode mode, bool rw, QWidget *parent=0, const char *name=0 ) | ### KURLComboBox

~KURLComboBox () | ### ~KURLComboBox

void setURL ( const KURL& url ) | ### setURL

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.

void setURLs ( QStringList urls ) | ### setURLs

QStringList urls () | ### urls

[const]

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:/

void setMaxItems ( int ) | ### setMaxItems

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

See also: maxItems

int maxItems () | ### maxItems

[const]

Returns: the maximum of items the combobox handles.

See also: setMaxItems

void addDefaultURL ( const KURL& url, const QString& text = QString::null ) | ### addDefaultURL

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 want to specify a special pixmap, use the overloaded method with the pixmap parameter. Default URLs will be inserted into the combobox by setDefaults()

void addDefaultURL ( const KURL& url, const QPixmap& pix, const QString& text = QString::null ) | ### addDefaultURL

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

void setDefaults () | ### setDefaults

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

void removeURL ( const KURL& url, bool checkDefaultURLs = true ) | ### removeURL

Removes any occurence of `url`. If `checkDefaultURLs` is false default-urls won't be removed.

void urlActivated ( const KURL& url ) | ### urlActivated

[signal]

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.

void slotActivated ( int ) | ### slotActivated

[protected slots slot]

_KURLComboItem (struct) | ### _KURLComboItem

[protected]

typedef _KURLComboItem KURLComboItem | ### KURLComboItem

[protected]

QList<KURLComboItem> itemList | ### itemList

[protected]

QList<KURLComboItem> defaultList | ### defaultList

[protected]

QMap<int,const KURLComboItem*> itemMapper | ### itemMapper

[protected]

void init ( Mode mode ) | ### init

[protected]

void insertURLItem ( const KURLComboItem * ) | ### insertURLItem

[protected]

QPixmap getPixmap ( const KURL& url ) | ### getPixmap

[protected const]

Uses KMimeType::pixmapForURL() to return a proper pixmap for `url`. In directory mode, a folder icon is always returned.

void updateItem ( const KURLComboItem *item, int index, const QPixmap& pix) | ### updateItem

[protected]

Updates `item` with `pixmap` and sets the url instead of the text of the KURLComboItem. Also works around a Qt bug.

QPixmap opendirPix | ### opendirPix

[protected]

int firstItemIndex | ### firstItemIndex

[protected]

- Author: Carsten Pfeiffer <pfeiffer@kde.org>
- Generated: root@i386.ports.openbsd.org on Wed Apr 25 13:58:44 2001, using kdoc 2.0a53.