• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdefile
 

tdeio/tdefile

Public Types | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Static Protected Attributes

KFileDialog Class Reference

Provides a user (and developer) friendly way to select files and directories. More...

#include <tdefiledialog.h>

Inheritance diagram for KFileDialog:
KEncodingFileDialog

List of all members.

Public Types

enum  OperationMode { Other = 0, Opening, Saving }

Signals

void fileSelected (const TQString &)
void fileHighlighted (const TQString &)
void selectionChanged ()
void filterChanged (const TQString &filter)

Public Member Functions

 KFileDialog (const TQString &startDir, const TQString &filter, TQWidget *parent, const char *name, bool modal)
 KFileDialog (const TQString &startDir, const TQString &filter, TQWidget *parent, const char *name, bool modal, TQWidget *widget)
 ~KFileDialog ()
KURL selectedURL () const
KURL::List selectedURLs () const
KURL baseURL () const
TQString selectedFile () const
TQStringList selectedFiles () const
void setURL (const KURL &url, bool clearforward=true)
void setSelection (const TQString &name)
void setOperationMode (KFileDialog::OperationMode)
OperationMode operationMode () const
void setKeepLocation (bool keep)
bool keepsLocation () const
void setFilter (const TQString &filter)
TQString currentFilter () const
void setFilterMimeType (const TQString &label, const KMimeType::List &types, const KMimeType::Ptr &defaultType) KDE_DEPRECATED
KMimeType::Ptr currentFilterMimeType ()
void setMimeFilter (const TQStringList &types, const TQString &defaultType=TQString::null)
TQString currentMimeFilter () const
void clearFilter ()
void setPreviewWidget (const TQWidget *w) KDE_DEPRECATED
void setPreviewWidget (const KPreviewWidgetBase *w)
virtual void show ()
void setMode (KFile::Mode m)
void setMode (unsigned int m)
KFile::Mode mode () const
void setLocationLabel (const TQString &text)
TDEToolBar * toolBar () const
KPushButton * okButton () const
KPushButton * cancelButton () const
KURLBar * speedBar ()
TDEActionCollection * actionCollection () const
int pathComboIndex ()

Static Public Member Functions

static TQString getOpenFileName (const TQString &startDir=TQString::null, const TQString &filter=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
static TQString getOpenFileNameWId (const TQString &startDir, const TQString &filter, WId parent_id, const TQString &caption)
static TQStringList getOpenFileNames (const TQString &startDir=TQString::null, const TQString &filter=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
static KURL getOpenURL (const TQString &startDir=TQString::null, const TQString &filter=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
static KURL::List getOpenURLs (const TQString &startDir=TQString::null, const TQString &filter=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
static TQString getSaveFileName (const TQString &startDir=TQString::null, const TQString &filter=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
static TQString getSaveFileNameWId (const TQString &dir, const TQString &filter, WId parent_id, const TQString &caption)
static KURL getSaveURL (const TQString &startDir=TQString::null, const TQString &filter=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
static TQString getExistingDirectory (const TQString &startDir=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
static KURL getExistingURL (const TQString &startDir=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
static KURL getImageOpenURL (const TQString &startDir=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
static KURL getStartURL (const TQString &startDir, TQString &recentDirClass)
static void setStartDir (const KURL &directory)

Protected Slots

void urlEntered (const KURL &)
void enterURL (const KURL &url)
void enterURL (const TQString &url)
void locationActivated (const TQString &url)
void toolbarCallback (int)
void pathComboChanged (const TQString &)
void dirCompletion (const TQString &)
void slotFilterChanged ()
void fileHighlighted (const KFileItem *i)
void fileSelected (const KFileItem *i)
void slotStatResult (TDEIO::Job *job)
void slotLoadingFinished ()
void fileCompletion (const TQString &)
void toggleSpeedbar (bool)
void toggleBookmarks (bool show)
virtual void updateStatusLine (int dirs, int files)
virtual void slotOk ()
virtual void accept ()
virtual void slotCancel ()
void slotAutoSelectExtClicked ()
void addToRecentDocuments ()
void initSpeedbar ()

Protected Member Functions

virtual void keyPressEvent (TQKeyEvent *e)
void init (const TQString &startDir, const TQString &filter, TQWidget *widget)
virtual void initGUI ()
void multiSelectionChanged ()
virtual void readConfig (TDEConfig *, const TQString &group=TQString::null)
virtual void writeConfig (TDEConfig *, const TQString &group=TQString::null)
virtual void readRecentFiles (TDEConfig *)
virtual void saveRecentFiles (TDEConfig *)
KURL::List tokenize (const TQString &line) const
KURL getCompleteURL (const TQString &)
TQString currentFilterExtension ()
void updateAutoSelectExtension ()
KURL::List & parseSelectedURLs () const
virtual void virtual_hook (int id, void *data)

Protected Attributes

TDEToolBar * toolbar
KURLComboBox * locationEdit
KFileFilterCombo * filterWidget
KDirOperator * ops
bool autoDirectoryFollowing

Static Protected Attributes

static KURL * lastDirectory

Detailed Description

Provides a user (and developer) friendly way to select files and directories.

The widget can be used as a drop in replacement for the TQFileDialog widget, but has greater functionality and a nicer GUI.

You will usually want to use one of the static methods getOpenFileName(), getSaveFileName(), getOpenURL() or for multiple files getOpenFileNames() or getOpenURLs().

The dialog has been designed to allow applications to customise it by subclassing. It uses geometry management to ensure that subclasses can easily add children that will be incorporated into the layout.

tdefiledialog.png

KDE File Dialog

A file selection dialog.

Author:
Richard J. Moore <rich@kde.org>, Carsten Pfeiffer <pfeiffer@kde.org>

Definition at line 77 of file tdefiledialog.h.


Member Enumeration Documentation

enum KFileDialog::OperationMode

Defines some default behavior of the filedialog.

E.g. in mode Opening and Saving, the selected files/urls will be added to the "recent documents" list. The Saving mode also implies setKeepLocation() being set.

Other means that no default actions are performed.

See also:
setOperationMode
operationMode

Definition at line 94 of file tdefiledialog.h.


Constructor & Destructor Documentation

KFileDialog::KFileDialog ( const TQString &  startDir,
const TQString &  filter,
TQWidget *  parent,
const char *  name,
bool  modal 
)

Constructs a file dialog.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter A shell glob or a mime-type-filter that specifies which files to display.
parent The parent widget of this dialog
name The name of this object
modal Whether to create a modal dialog or not See setFilter() for details on how to use this argument.

Definition at line 169 of file tdefiledialog.cpp.

KFileDialog::KFileDialog ( const TQString &  startDir,
const TQString &  filter,
TQWidget *  parent,
const char *  name,
bool  modal,
TQWidget *  widget 
)

Constructs a file dialog.

The parameters here are identical to the first constructor except for the addition of a TQWidget parameter.

Historical note: The original version of KFileDialog did not have this extra parameter. It was added later, and, in order to maintain binary compatibility, it was placed in a new constructor instead of added to the original one.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter A shell glob or a mime-type-filter that specifies which files to display. See setFilter() for details on how to use this argument.
widget A widget, or a widget of widgets, for displaying custom data in the dialog. This can be used, for example, to display a check box with the caption "Open as read-only". When creating this widget, you don't need to specify a parent, since the widget's parent will be set automatically by KFileDialog.
parent The parent widget of this dialog
name The name of this object
modal Whether to create a modal dialog or not
Since:
3.1

Definition at line 176 of file tdefiledialog.cpp.

KFileDialog::~KFileDialog (  ) 

Destructs the file dialog.

Definition at line 184 of file tdefiledialog.cpp.


Member Function Documentation

TDEActionCollection * KFileDialog::actionCollection (  )  const
Returns:
a pointer to the action collection, holding all the used TDEActions.

Definition at line 2211 of file tdefiledialog.cpp.

KURL KFileDialog::baseURL (  )  const
Returns:
the currently shown directory.

Definition at line 1597 of file tdefiledialog.cpp.

KPushButton * KFileDialog::cancelButton (  )  const
Returns:
a pointer to the Cancel-Button in the filedialog. You may use it e.g. to set a custom text to it.

Definition at line 1810 of file tdefiledialog.cpp.

void KFileDialog::clearFilter (  ) 

Clears any mime- or namefilter.

Does not reload the directory.

Definition at line 271 of file tdefiledialog.cpp.

TQString KFileDialog::currentFilter (  )  const

Returns the current filter as entered by the user or one of the predefined set via setFilter().

See also:
setFilter()
filterChanged()

Definition at line 234 of file tdefiledialog.cpp.

TQString KFileDialog::currentFilterExtension ( void   )  [protected]

Returns the filename extension associated with the currentFilter().

TQString::null is returned if an extension is not available or if operationMode() != Saving.

Since:
3.2

Definition at line 1917 of file tdefiledialog.cpp.

KMimeType::Ptr KFileDialog::currentFilterMimeType (  ) 

Returns the mimetype for the desired output format.

This is only valid if setFilterMimeType() has been called previously.

See also:
setFilterMimeType()

Definition at line 293 of file tdefiledialog.cpp.

TQString KFileDialog::currentMimeFilter (  )  const

The mimetype for the desired output format.

This is only valid if setMimeFilter() has been called previously.

See also:
setMimeFilter()

Definition at line 282 of file tdefiledialog.cpp.

void KFileDialog::dirCompletion ( const TQString &   )  [protected, slot]
Deprecated:

Definition at line 1302 of file tdefiledialog.cpp.

void KFileDialog::fileHighlighted ( const TQString &   )  [signal]

Emitted when the user highlights a file.

void KFileDialog::fileSelected ( const TQString &   )  [signal]

Emitted when the user selects a file.

It is only emitted in single- selection mode. The best way to get notified about selected file(s) is to connect to the okClicked() signal inherited from KDialogBase and call selectedFile(), selectedFiles(), selectedURL() or selectedURLs().

void KFileDialog::filterChanged ( const TQString &  filter  )  [signal]

Emitted when the filter changed, i.e.

the user entered an own filter or chose one of the predefined set via setFilter().

Parameters:
filter contains the new filter (only the extension part, not the explanation), i.e. "*.cpp" or "*.cpp *.cc".
See also:
setFilter()
currentFilter()
KURL KFileDialog::getCompleteURL ( const TQString &  _url  )  [protected]

Returns the absolute version of the URL specified in locationEdit.

Since:
3.2

Definition at line 310 of file tdefiledialog.cpp.

TQString KFileDialog::getExistingDirectory ( const TQString &  startDir = TQString::null,
TQWidget *  parent = 0,
const TQString &  caption = TQString::null 
) [static]

Creates a modal file dialog and returns the selected directory or an empty string if none was chosen.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1419 of file tdefiledialog.cpp.

KURL KFileDialog::getExistingURL ( const TQString &  startDir = TQString::null,
TQWidget *  parent = 0,
const TQString &  caption = TQString::null 
) [static]

Creates a modal file dialog and returns the selected directory or an empty string if none was chosen.

Contrary to getExistingDirectory(), this method allows the selection of a remote directory.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.
Since:
3.1

Definition at line 1412 of file tdefiledialog.cpp.

KURL KFileDialog::getImageOpenURL ( const TQString &  startDir = TQString::null,
TQWidget *  parent = 0,
const TQString &  caption = TQString::null 
) [static]

Creates a modal file dialog with an image previewer and returns the selected url or an empty string if none was chosen.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1436 of file tdefiledialog.cpp.

TQString KFileDialog::getOpenFileName ( const TQString &  startDir = TQString::null,
const TQString &  filter = TQString::null,
TQWidget *  parent = 0,
const TQString &  caption = TQString::null 
) [static]

Creates a modal file dialog and return the selected filename or an empty string if none was chosen.

Note that with this method the user must select an existing filename.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1326 of file tdefiledialog.cpp.

TQStringList KFileDialog::getOpenFileNames ( const TQString &  startDir = TQString::null,
const TQString &  filter = TQString::null,
TQWidget *  parent = 0,
const TQString &  caption = TQString::null 
) [static]

Creates a modal file dialog and returns the selected filenames or an empty list if none was chosen.

Note that with this method the user must select an existing filename.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1366 of file tdefiledialog.cpp.

TQString KFileDialog::getOpenFileNameWId ( const TQString &  startDir,
const TQString &  filter,
WId  parent_id,
const TQString &  caption 
) [static]

Use this version only if you have no TQWidget available as parent widget.

This can be the case if the parent widget is a widget in another process or if the parent widget is a non-Qt widget. For example, in a GTK program.

Since:
3.4

Definition at line 1342 of file tdefiledialog.cpp.

KURL KFileDialog::getOpenURL ( const TQString &  startDir = TQString::null,
const TQString &  filter = TQString::null,
TQWidget *  parent = 0,
const TQString &  caption = TQString::null 
) [static]

Creates a modal file dialog and returns the selected URL or an empty string if none was chosen.

Note that with this method the user must select an existing URL.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1382 of file tdefiledialog.cpp.

KURL::List KFileDialog::getOpenURLs ( const TQString &  startDir = TQString::null,
const TQString &  filter = TQString::null,
TQWidget *  parent = 0,
const TQString &  caption = TQString::null 
) [static]

Creates a modal file dialog and returns the selected URLs or an empty list if none was chosen.

Note that with this method the user must select an existing filename.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1396 of file tdefiledialog.cpp.

TQString KFileDialog::getSaveFileName ( const TQString &  startDir = TQString::null,
const TQString &  filter = TQString::null,
TQWidget *  parent = 0,
const TQString &  caption = TQString::null 
) [static]

Creates a modal file dialog and returns the selected filename or an empty string if none was chosen.

Note that with this method the user need not select an existing filename.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • a relative path or a filename determining the directory to start in and the file to be selected.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1602 of file tdefiledialog.cpp.

TQString KFileDialog::getSaveFileNameWId ( const TQString &  dir,
const TQString &  filter,
WId  parent_id,
const TQString &  caption 
) [static]

This function accepts the window id of the parent window, instead of TQWidget*.

It should be used only when necessary.

Since:
3.4

Definition at line 1623 of file tdefiledialog.cpp.

KURL KFileDialog::getSaveURL ( const TQString &  startDir = TQString::null,
const TQString &  filter = TQString::null,
TQWidget *  parent = 0,
const TQString &  caption = TQString::null 
) [static]

Creates a modal file dialog and returns the selected filename or an empty string if none was chosen.

Note that with this method the user need not select an existing filename.

Parameters:
startDir This can either be

  • The URL of the directory to start in.
  • a relative path or a filename determining the directory to start in and the file to be selected.
  • TQString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1652 of file tdefiledialog.cpp.

KURL KFileDialog::getStartURL ( const TQString &  startDir,
TQString &  recentDirClass 
) [static]

This method implements the logic to determine the user's default directory to be listed.

E.g. the documents direcory, home directory or a recently used directory.

Parameters:
startDir A url/directory, to be used. May use the ':' and '::' syntax as documented in the KFileDialog() constructor.
recentDirClass If the ':' or '::' syntax is used, recentDirClass will contain the string to be used later for TDERecentDir::dir()
Returns:
The URL that should be listed by default (e.g. by KFileDialog or KDirSelectDialog).
Since:
3.1

Definition at line 2313 of file tdefiledialog.cpp.

void KFileDialog::init ( const TQString &  startDir,
const TQString &  filter,
TQWidget *  widget 
) [protected]

Perform basic initialization tasks.

Called by constructors.

Since:
3.1

Definition at line 815 of file tdefiledialog.cpp.

void KFileDialog::initGUI (  )  [protected, virtual]

rebuild geometry management.

Definition at line 1072 of file tdefiledialog.cpp.

bool KFileDialog::keepsLocation (  )  const
Returns:
whether the contents of the location edit are kept when changing directories.

Definition at line 1836 of file tdefiledialog.cpp.

void KFileDialog::keyPressEvent ( TQKeyEvent *  e  )  [protected, virtual]

Reimplemented to animate the cancel button.

Definition at line 2216 of file tdefiledialog.cpp.

KFile::Mode KFileDialog::mode (  )  const

Returns the mode of the filedialog.

See also:
setMode()

Definition at line 1701 of file tdefiledialog.cpp.

void KFileDialog::multiSelectionChanged (  )  [protected]

called when an item is highlighted/selected in multiselection mode.

handles setting the locationEdit.

Definition at line 745 of file tdefiledialog.cpp.

KPushButton * KFileDialog::okButton (  )  const
Returns:
a pointer to the OK-Button in the filedialog. You may use it e.g. to set a custom text to it.

Definition at line 1805 of file tdefiledialog.cpp.

KFileDialog::OperationMode KFileDialog::operationMode (  )  const
Returns:
the current operation mode, Opening, Saving or Other. Default is Other.
See also:
operationMode
KFileDialog::OperationMode

Definition at line 1858 of file tdefiledialog.cpp.

void KFileDialog::pathComboChanged ( const TQString &   )  [protected, slot]
Deprecated:

Definition at line 1299 of file tdefiledialog.cpp.

int KFileDialog::pathComboIndex (  ) 
Returns:
the index of the path combobox so when inserting widgets into the dialog (e.g. subclasses) they can do so without hardcoding in an index

Definition at line 2298 of file tdefiledialog.cpp.

void KFileDialog::readConfig ( TDEConfig *  kc,
const TQString &  group = TQString::null 
) [protected, virtual]

Reads configuration and applies it (size, recent directories, ...).

Definition at line 1707 of file tdefiledialog.cpp.

void KFileDialog::readRecentFiles ( TDEConfig *  kc  )  [protected, virtual]

Reads the recent used files and inserts them into the location combobox.

Definition at line 1780 of file tdefiledialog.cpp.

void KFileDialog::saveRecentFiles ( TDEConfig *  kc  )  [protected, virtual]

Saves the entries from the location combobox.

Definition at line 1795 of file tdefiledialog.cpp.

TQString KFileDialog::selectedFile (  )  const

Returns the full path of the selected file in the local filesystem.

(Local files only)

Definition at line 1555 of file tdefiledialog.cpp.

TQStringList KFileDialog::selectedFiles (  )  const

Returns a list of all selected local files.

Definition at line 1571 of file tdefiledialog.cpp.

KURL KFileDialog::selectedURL (  )  const
Returns:
The selected fully qualified filename.

Definition at line 1454 of file tdefiledialog.cpp.

KURL::List KFileDialog::selectedURLs (  )  const
Returns:
The list of selected URLs.

Definition at line 1462 of file tdefiledialog.cpp.

void KFileDialog::selectionChanged (  )  [signal]

Emitted when the user hilights one or more files in multiselection mode.

Note: fileHighlighted() or fileSelected() are not emitted in multiselection mode. You may use selectedItems() to ask for the current highlighted items.

See also:
fileSelected
void KFileDialog::setFilter ( const TQString &  filter  ) 

Sets the filter to be used to filter.

You can set more filters for the user to select separated by '
'. Every filter entry is defined through namefilter|text to diplay. If no | is found in the expression, just the namefilter is shown. Examples:

 tdefile->setFilter("*.cpp|C++ Source Files\n*.h|Header files");
 tdefile->setFilter("*.cpp");
 tdefile->setFilter("*.cpp|Sources (*.cpp)");
 tdefile->setFilter("*.cpp|" + i18n("Sources (*.cpp)"));
 tdefile->setFilter("*.cpp *.cc *.C|C++ Source Files\n*.h *.H|Header files");

Note: The text to display is not parsed in any way. So, if you want to show the suffix to select by a specific filter, you must repeat it.

If the filter contains an unescaped '/', a mimetype-filter is assumed. If you would like a '/' visible in your filter it can be escaped with a '\'. You can specify multiple mimetypes like this (separated with space):

 tdefile->setFilter( "image/png text/html text/plain" );
 tdefile->setFilter( "*.cue|CUE\\/BIN Files (*.cue)" );
See also:
filterChanged
setMimeFilter

Definition at line 205 of file tdefiledialog.cpp.

void KFileDialog::setFilterMimeType ( const TQString &  label,
const KMimeType::List &  types,
const KMimeType::Ptr &  defaultType 
)

Sets the filter up to specify the output type.

Parameters:
label the label to use instead of "Filter:"
types a list of mimetypes that can be used as output format
defaultType the default mimetype to use as output format.

Do not use in conjunction with setFilter()

Deprecated:

Definition at line 240 of file tdefiledialog.cpp.

void KFileDialog::setKeepLocation ( bool  keep  ) 

Sets whether the filename/url should be kept when changing directories.

This is for example useful when having a predefined filename where the full path for that file is searched.

This is implicitly set when operationMode() is KFileDialog::Saving

getSaveFileName() and getSaveURL() set this to true by default, so that you can type in the filename and change the directory without having to type the name again.

Definition at line 1831 of file tdefiledialog.cpp.

void KFileDialog::setLocationLabel ( const TQString &  text  ) 

Sets the text to be displayed in front of the selection.

The default is "Location". Most useful if you want to make clear what the location is used for.

Definition at line 200 of file tdefiledialog.cpp.

void KFileDialog::setMimeFilter ( const TQStringList &  types,
const TQString &  defaultType = TQString::null 
)

Sets the filter up to specify the output type.

Parameters:
types a list of mimetypes that can be used as output format
defaultType the default mimetype to use as output format, if any. If defaultType is set, it will be set as the current item. Otherwise, a first item showing all the mimetypes will be created. Typically, defaultType should be empty for loading and set for saving.

Do not use in conjunction with setFilter()

Definition at line 254 of file tdefiledialog.cpp.

void KFileDialog::setMode ( KFile::Mode  m  ) 

Convenient overload of the other setMode(unsigned int) method.

Definition at line 1683 of file tdefiledialog.cpp.

void KFileDialog::setMode ( unsigned int  m  ) 

Sets the mode of the dialog.

The mode is defined as (in tdefile.h):

    enum Mode {
         File         = 1,
         Directory    = 2,
         Files        = 4,
         ExistingOnly = 8,
         LocalOnly    = 16
    };

You can OR the values, e.g.

 KFile::Mode mode = static_cast<KFile::Mode>( KFile::Files |
                                              KFile::ExistingOnly |
                                              KFile::LocalOnly );
 setMode( mode );

Definition at line 1696 of file tdefiledialog.cpp.

void KFileDialog::setOperationMode ( KFileDialog::OperationMode  mode  ) 

Sets the operational mode of the filedialog to Saving, Opening or Other.

This will set some flags that are specific to loading or saving files. E.g. setKeepLocation() makes mostly sense for a save-as dialog. So setOperationMode( KFileDialog::Saving ); sets setKeepLocation for example.

The mode Saving, together with a default filter set via setMimeFilter() will make the filter combobox read-only.

The default mode is Opening.

Call this method right after instantiating KFileDialog.

See also:
operationMode
KFileDialog::OperationMode

Definition at line 1841 of file tdefiledialog.cpp.

void KFileDialog::setPreviewWidget ( const TQWidget *  w  ) 
Deprecated:
Add a preview widget and enter the preview mode.

In this mode the dialog is split and the right part contains your widget. This widget has to inherit TQWidget and it has to implement a slot showPreview(const KURL &); which is called every time the file changes. You may want to look at koffice/lib/kofficecore/koFilterManager.cc for some hints :)

Ownership is transferred to KFileDialog. You need to create the preview-widget with "new", i.e. on the heap.

Definition at line 298 of file tdefiledialog.cpp.

void KFileDialog::setPreviewWidget ( const KPreviewWidgetBase *  w  ) 

Adds a preview widget and enters the preview mode.

In this mode the dialog is split and the right part contains your preview widget.

Ownership is transferred to KFileDialog. You need to create the preview-widget with "new", i.e. on the heap.

Parameters:
w The widget to be used for the preview.

Definition at line 304 of file tdefiledialog.cpp.

void KFileDialog::setSelection ( const TQString &  name  ) 

Sets the file name to preselect to name.

This takes absolute URLs and relative file names.

Definition at line 1227 of file tdefiledialog.cpp.

void KFileDialog::setURL ( const KURL &  url,
bool  clearforward = true 
)

Sets the directory to view.

Parameters:
url URL to show.
clearforward Indicates whether the forward queue should be cleared.

Definition at line 1160 of file tdefiledialog.cpp.

KURLBar * KFileDialog::speedBar (  ) 
Returns:
the KURLBar object used as the "speed bar". You can add custom entries to it like that:
 KURLBar *urlBar = fileDialog->speedBar();
 if ( urlBar )
     urlBar->insertDynamicItem( someURL, i18n("The URL's description") );

Note that this method may return a null-pointer if the user configured to not use the speed-bar.

See also:
KURLBar
KURLBar::insertDynamicItem
Since:
3.2

Definition at line 1815 of file tdefiledialog.cpp.

void KFileDialog::toggleBookmarks ( bool  show  )  [protected, slot]
Since:
3.4

Definition at line 2263 of file tdefiledialog.cpp.

void KFileDialog::toggleSpeedbar ( bool  show  )  [protected, slot]
Since:
3.1

Definition at line 2227 of file tdefiledialog.cpp.

KURL::List KFileDialog::tokenize ( const TQString &  line  )  const [protected]

Parses the string "line" for files.

If line doesn't contain any ", the whole line will be interpreted as one file. If the number of " is odd, an empty list will be returned. Otherwise, all items enclosed in " " will be returned as correct urls.

Definition at line 1509 of file tdefiledialog.cpp.

TDEToolBar* KFileDialog::toolBar (  )  const [inline]

Returns a pointer to the toolbar.

You can use this to insert custom items into it, e.g.:

      yourAction = new TDEAction( i18n("Your Action"), 0,
                                this, TQT_SLOT( yourSlot() ),
                                this, "action name" );
      yourAction->plug( tdefileDialog->toolBar() );

Definition at line 722 of file tdefiledialog.h.

void KFileDialog::toolbarCallback ( int   )  [protected, slot]
Deprecated:
,

Definition at line 1218 of file tdefiledialog.cpp.

void KFileDialog::updateAutoSelectExtension ( void   )  [protected]

Updates the currentFilterExtension and the availability of the Automatically Select Extension Checkbox (visible if operationMode() == Saving and enabled if an extension _will_ be associated with the currentFilter(), _after_ this call).

You should call this after filterWidget->setCurrentItem().

Since:
3.2

Definition at line 1922 of file tdefiledialog.cpp.

void KFileDialog::updateStatusLine ( int  dirs,
int  files 
) [protected, virtual, slot]
Deprecated:

Definition at line 1321 of file tdefiledialog.cpp.

void KFileDialog::writeConfig ( TDEConfig *  kc,
const TQString &  group = TQString::null 
) [protected, virtual]

Saves the current configuration.

Definition at line 1758 of file tdefiledialog.cpp.


The documentation for this class was generated from the following files:
  • tdefiledialog.h
  • tdefiledialog.cpp

tdeio/tdefile

Skip menu "tdeio/tdefile"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeio/tdefile

Skip menu "tdeio/tdefile"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdefile by doxygen 1.7.1
This website is maintained by Timothy Pearson.