kio Library API Documentation

KURLRequester Class Reference

This class is a widget showing a lineedit and a button, which invokes a filedialog. A widget to request a filename/url from the user. More...

#include <kurlrequester.h>

Inheritance diagram for KURLRequester:

QHBox List of all members.

Public Slots

void setURL (const QString &url)
virtual void setCaption (const QString &caption)
void clear ()

Signals

void textChanged (const QString &)
void returnPressed ()
void returnPressed (const QString &)
void openFileDialog (KURLRequester *)
void urlSelected (const QString &)

Public Member Functions

 KURLRequester (QWidget *parent=0, const char *name=0)
 KURLRequester (const QString &url, QWidget *parent=0, const char *name=0)
 KURLRequester (QWidget *editWidget, QWidget *parent, const char *name=0)
 ~KURLRequester ()
QString url () const
void setShowLocalProtocol (bool b)
void setMode (uint m)
uint mode () const
void setFilter (const QString &filter)
QString filter () const
bool showLocalProtocol () const
virtual KFileDialogfileDialog () const
KLineEditlineEdit () const
KComboBoxcomboBox () const
KPushButtonbutton () const
KURLCompletioncompletionObject () const
KEditListBox::CustomEditor customEditor ()

Protected Slots

void slotOpenDialog ()

Protected Member Functions

void init ()
virtual void virtual_hook (int id, void *data)

Protected Attributes

KURLCompletionmyCompletion

Properties

QString url
bool showLocalProtocol
QString filter
uint mode

Detailed Description

This class is a widget showing a lineedit and a button, which invokes a filedialog. A widget to request a filename/url from the user.

File name completion is available in the lineedit.

The defaults for the filedialog are to ask for one existing local file, i.e. KFileDialog::setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ) The default filter is "*", i.e. show all files, and the start directory is the current working directory, or the last directory where a file has been selected.

You can change this behavior by using setMode() or setFilter().

kurlrequester.png

KDE URL Requester

Author:
Carsten Pfeiffer <pfeiffer@kde.org>

Definition at line 56 of file kurlrequester.h.


Constructor & Destructor Documentation

KURLRequester::KURLRequester QWidget parent = 0,
const char *  name = 0
 

Constructs a KURLRequester widget.

Definition at line 172 of file kurlrequester.cpp.

KURLRequester::KURLRequester const QString url,
QWidget parent = 0,
const char *  name = 0
 

Constructs a KURLRequester widget with the initial URL url.

Definition at line 180 of file kurlrequester.cpp.

References setURL().

KURLRequester::KURLRequester QWidget editWidget,
QWidget parent,
const char *  name = 0
 

Special constructor, which creates a KURLRequester widget with a custom edit-widget.

The edit-widget can be either a KComboBox or a KLineEdit (or inherited thereof). Note: for geometry management reasons, the edit-widget is reparented to have the KURLRequester as parent.

Parameters:
modal specifies whether the filedialog should be opened as modal or not.
Definition at line 157 of file kurlrequester.cpp.

KURLRequester::~KURLRequester  ) 
 

Destructs the KURLRequester.

Definition at line 190 of file kurlrequester.cpp.


Member Function Documentation

QString KURLRequester::url  )  const
 

Returns:
the current url in the lineedit. May be malformed, if the user entered something weird. ~user or environment variables are substituted for local files.

Referenced by setShowLocalProtocol(), and slotOpenDialog().

void KURLRequester::setShowLocalProtocol bool  b  ) 
 

Enables/disables showing file:/ in the lineedit, when a local file has been selected in the filedialog or was set via setURL().

Default is false, not showing file:/

See also:
showLocalProtocol
Definition at line 326 of file kurlrequester.cpp.

References setURL(), and url().

void KURLRequester::setMode uint  m  ) 
 

Sets the mode of the file dialog.

Note: you can only select one file with the filedialog, so KFile::Files doesn't make much sense.

See also:
KFileDialog::setMode()

Referenced by KURLBarItemDialog::KURLBarItemDialog().

uint KURLRequester::mode  )  const
 

Returns the current mode.

See also:
KFileDialog::mode()
Since:
3.3

void KURLRequester::setFilter const QString filter  ) 
 

Sets the filter for the file dialog.

See also:
KFileDialog::setFilter()
Definition at line 297 of file kurlrequester.cpp.

References KFileDialog::setFilter().

QString KURLRequester::filter  )  const
 

Returns the current filter for the file dialog.

See also:
KFileDialog::filter()
Since:
3.3

bool KURLRequester::showLocalProtocol  )  const [inline]
 

Returns:
whether local files will be prefixed with file:/ in the lineedit
See also:
setShowLocalProtocol
Definition at line 137 of file kurlrequester.h.

KFileDialog * KURLRequester::fileDialog  )  const [virtual]
 

Returns:
a pointer to the filedialog You can use this to customize the dialog, e.g. to specify a filter. Never returns 0L.
Remove in KDE4? KURLRequester should use KDirSelectDialog for (mode & KFile::Directory) && !(mode & KFile::File) Definition at line 310 of file kurlrequester.cpp.

References KDialog::setCaption(), KFileDialog::setFilter(), and KFileDialog::setMode().

Referenced by KURLRequesterDlg::fileDialog(), and slotOpenDialog().

KLineEdit * KURLRequester::lineEdit  )  const
 

Returns:
a pointer to the lineedit, either the default one, or the special one, if you used the special constructor.
It is provided so that you can e.g. set an own completion object (e.g. KShellCompletion) into it. Definition at line 340 of file kurlrequester.cpp.

Referenced by KOpenWithDlg::init(), and KURLBarItemDialog::KURLBarItemDialog().

KComboBox * KURLRequester::comboBox  )  const
 

Returns:
a pointer to the combobox, in case you have set one using the special constructor. Returns 0L otherwise.
Definition at line 345 of file kurlrequester.cpp.

Referenced by KOpenWithDlg::accept(), and KOpenWithDlg::init().

KPushButton * KURLRequester::button  )  const
 

Returns:
a pointer to the pushbutton. It is provided so that you can specify an own pixmap or a text, if you really need to.
Definition at line 358 of file kurlrequester.cpp.

Referenced by KOpenWithDlg::init().

KURLCompletion* KURLRequester::completionObject  )  const [inline]
 

Returns:
the KURLCompletion object used in the lineedit/combobox.
Definition at line 173 of file kurlrequester.h.

KEditListBox::CustomEditor KURLRequester::customEditor  ) 
 

Returns:
an object, suitable for use with KEditListBox. It allows you to put this KURLRequester into a KEditListBox. Basically, do it like this:
 KURLRequester *req = new KURLRequester( someWidget );
 [...]
 KEditListBox *editListBox = new KEditListBox( i18n("Some Title"), req->customEditor(), someWidget );
Since:
3.1
Definition at line 363 of file kurlrequester.cpp.

References kdWarning().

void KURLRequester::setURL const QString url  )  [slot]
 

Sets the url in the lineedit to url.

Depending on the state of showLocalProtocol(), file:/ on local files will be shown or not.

Since:
3.1
Definition at line 232 of file kurlrequester.cpp.

Referenced by KOpenWithDlg::init(), KURLPropsPlugin::KURLPropsPlugin(), KURLRequester(), setShowLocalProtocol(), KOpenWithDlg::slotClear(), and slotOpenDialog().

void KURLRequester::setCaption const QString caption  )  [virtual, slot]
 

Sets the caption of the file dialog.

Since:
3.1
Definition at line 242 of file kurlrequester.cpp.

References KDialog::setCaption().

void KURLRequester::clear  )  [slot]
 

Clears the lineedit/combobox.

Definition at line 335 of file kurlrequester.cpp.

void KURLRequester::textChanged const QString  )  [signal]
 

Emitted when the text in the lineedit changes.

The parameter contains the contents of the lineedit.

Since:
3.1

void KURLRequester::returnPressed  )  [signal]
 

Emitted when return or enter was pressed in the lineedit.

void KURLRequester::returnPressed const QString  )  [signal]
 

Emitted when return or enter was pressed in the lineedit.

The parameter contains the contents of the lineedit.

void KURLRequester::openFileDialog KURLRequester  )  [signal]
 

Emitted before the filedialog is going to open.

Connect to this signal to "configure" the filedialog, e.g. set the filefilter, the mode, a preview-widget, etc. It's usually not necessary to set a URL for the filedialog, as it will get set properly from the editfield contents.

If you use multiple KURLRequesters, you can connect all of them to the same slot and use the given KURLRequester pointer to know which one is going to open.

Referenced by slotOpenDialog().

void KURLRequester::urlSelected const QString  )  [signal]
 

Emitted when the user changed the URL via the file dialog.

The parameter contains the contents of the lineedit.

Referenced by slotOpenDialog().

void KURLRequester::slotOpenDialog  )  [protected, slot]
 

Called when the button is pressed to open the filedialog.

Also called when KStdAccel::Open (default is Ctrl-O) is pressed. Definition at line 255 of file kurlrequester.cpp.

References fileDialog(), KURL::isLocalFile(), openFileDialog(), KURL::path(), KURL::prettyURL(), KFileDialog::selectedURL(), KFileDialog::setSelection(), setURL(), KProtocolInfo::supportsListing(), KURL::url(), url(), and urlSelected().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kio Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:43:59 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003