|
|
The KFileDialog widget provides a user (and developer) friendly way to select files. The widget can be used as a drop in replacement for the QFileDialog widget, but has greater functionality and a nicer GUI.
You will usually want to use one of the two static methods KFileDialog::getOpenFileName or KFileDialog::getSaveFileName.
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 which will be incorperated into the layout.
KFileBaseDialog (const char *dirName, const char *filter= 0, QWidget *parent= 0, const char *name= 0, bool modal = false, bool acceptURLs = true) |
Construct a KFileBaseDialog
Parameters:
dirName | The name of the directory to start in. |
filter | A shell glob that specifies which files to display. see setFilter for details on how to use this argument |
acceptURLs | If set to false, kfiledialog will just accept files on the local filesystem. |
~KFileBaseDialog () |
Cleans up
QString selectedFile () |
Returns the fully qualified filename.
QString dirPath () |
Return the path of the selected directory.
void rereadDir () |
Rereads the currently selected directory.
void back () |
Go back to the previous directory if this is not the first.
void forward () |
Go forward to the next directory if this is not the last.
void home () |
Go home.
void cdUp () |
Go to parent.
bool dirIsLocal () |
Returns true for local files, false for remote files.
QString selectedFileURL () |
Returns the url of the selected filename
QStrList selectedFileURLList () |
Returns the URLs of the selected files.
void setMultiSelection (bool multi= true) |
If the argument is true the dialog will accept multiple selections.
bool isMultiSelection () |
Returns true if multiple selections are enabled.
QString getDirectory (const char *url, QWidget *parent = 0, const char *name = 0) |
This method creates a modal directory dialog and returns the selected directory or an empty string if none was chosen. Note that with this method the user must select an existing directory.
Parameters:
url | This specifies the path the dialog will start in. |
parent | The widget the dialog will be centered on initially. |
name | The name of the dialog widget. |
QStrList getOpenFileURLList (const char *url= 0, const char *filter= 0, QWidget *parent= 0, const char *name= 0) |
This a multiple selection version of getOpenFileURL().
QStrList getSaveFileURLList (const char *url= 0, const char *filter= 0, QWidget *parent= 0, const char *name= 0) |
This a multiple selection version of getSaveFileURL().
void setDir (const char *name, bool clearforward = true) |
Sets the directory to view
Parameters:
name | URL to show |
clearforward | indicate, if the forward queue should be cleared |
void setSelection (const char *name) |
Sets the filename to preselect. It takes absolute and relative file names
void setFilter (const char *filter) |
Sets the filter to be used to filter. You can set more filters for the user to select seperated by \n. Every filter entry is defined through namefilter|text to diplay. If no | is found in the expression, just the namefilter is shown. Examples:
kfile->setFilter("*.cpp|C++ Source Files\n*.h|Header files"); kfile->setFilter("*.cpp"); kfile->setFilter("*.cpp|Sources (*.cpp");
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.
void fileSelected (const char *) |
Emitted when the user selects a file.
void fileHighlighted (const char *) |
Emitted when the user highlights a file.
void dirEntered (const char *) |
Emitted when a new directory is entered.
void historyUpdate (bool, bool) |
Emitted when the allowable history operations change.
QStack<QString> backStack |
Contains all URLs you can reach with the back button.
QStack<QString> forwardStack |
Contains all URLs you can reach with the forward button.
bool stackLock |
Lock backStack and forwardStack .
QWidget * swallower () |
Subclasses should reimplement this method to swallow the main layout. This allows the addition of children that are outside the existing layout. The function should return the widget that should be the parent of the main layout.
KFileInfoContents * initFileList ( QWidget *parent ) |
Subclasses, that want another view should override this function to provide another file view. It will be used to display files.
bool getShowFilter () |
Overload this function, if you want the filter shown/unshown
void addDirEntry (KFileInfo *entry, bool disableUpdating) |
adds a entry of the current directory. If disableUpdating is set to true, it will care about clever updating
void initGUI () |
rebuild geometry managment.
void mkdir () |
Makes a new directory in current directory after asking user for a name
void checkPath (const char *txt, bool takeFiles = false) |
takes action on the new location. If it's a directory, change into it, if it's a file, correct the name, etc.
Parameters:
takeFiles | if set to true, if will close the dialog, if txt is a file name |
void init () |
this functions must be called by the constructor of a derived class.
void help () |
You should override this method if you change the user interface of this dialog in a subclass in order to invoke your updated user help.
void addToBookmarks () |
Add the current location to the global bookmarks list