The QtxPathDialog class provides a simple convenience dialog to enter a path to the file or to the directory. More...
#include <QtxPathDialog.h>

Classes | |
| struct | FileEntry |
Public Slots | |
| virtual void | setVisible (bool) |
| Show/hide the path dialog box/. More... | |
Public Slots inherited from QtxDialog | |
| void | update () |
| Update dialog box. More... | |
| virtual void | setVisible (bool) |
| Show/hide dialog box, set keyboard focus to the dialog. More... | |
Signals | |
| void | fileNameChanged (QString) |
| Emitted when the file name is changed. More... | |
Signals inherited from QtxDialog | |
| void | dlgButton (int) |
| Emitted when the user button is clicked. More... | |
| void | dlgParamChanged () |
| This signal can be used in successor classes to signalize about some dialog parameter changing. More... | |
| void | dlgHelp () |
| Emitted when the "Help" button is clicked. More... | |
| void | dlgApply () |
| Emitted when the "Apply" button is clicked. More... | |
| void | dlgOk () |
| Emitted when the "OK" button is clicked. More... | |
| void | dlgNo () |
| Emitted when the "No" button is clicked. More... | |
| void | dlgYes () |
| Emitted when the "Yes" button is clicked. More... | |
| void | dlgClose () |
| Emitted when the "Close" button is clicked. More... | |
| void | dlgCancel () |
| Emitted when the "Cancel" button is clicked. More... | |
Public Member Functions | |
| QtxPathDialog (const bool, QWidget *=0, const bool=true, const bool=false, const int=Standard, Qt::WindowFlags=0) | |
| Constructor. More... | |
| virtual | ~QtxPathDialog () |
| Destructor. More... | |
| QString | fileName () const |
| Get selected file name. More... | |
| void | setFileName (const QString &, const bool=false) |
| Set the file name. More... | |
| QString | filter () const |
| Get current file filter. More... | |
| void | setFilter (const QString &) |
| Change file filter. More... | |
Public Member Functions inherited from QtxDialog | |
| QtxDialog (QWidget *=0, bool=false, bool=false, const int=Standard, Qt::WindowFlags=0) | |
| Constructor. More... | |
| virtual | ~QtxDialog () |
| Destructor. More... | |
| void | setDialogFlags (const int) |
| Set specified dialog box flags. More... | |
| void | clearDialogFlags (const int) |
| Clear specified the dialog flags. More... | |
| bool | testDialogFlags (const int) const |
| Test specified dialog flags. More... | |
| void | setButtonFlags (const int) |
| Add specified control button(s) to the dialog box. More... | |
| void | clearButtonFlags (const int) |
| Remove specified control button(s) from the dialog box. More... | |
| bool | testButtonFlags (const int) const |
| Test specified buttons. More... | |
| int | buttonPosition (const int) const |
| Get specified control button position. More... | |
| void | setButtonPosition (const int, const int=-1) |
| Set the specified control button(s) position. More... | |
| void | setPlacePosition (const int, const int) |
| Set button position for all buttons in specified area. More... | |
| int | placePolicy (const int) const |
| Get buttons layouting policy for the specified area. More... | |
| void | setPlacePolicy (const int, const int) |
| set buttons layouting policy for the specified area. More... | |
| void | setButtonPlace (const int, const int) |
| Move specified button(s) into specified area. More... | |
| QString | buttonText (const int) |
| Get specified button's text. More... | |
| void | setButtonText (const int, const QString &text) |
| Set specified button's text. More... | |
| void | setButtonFocus (const int) |
| Sets the keyboard focus to the specified button. More... | |
| bool | hasButtonFocus (const int) const |
| Check if specified button has keyboard focus. More... | |
| bool | isButtonEnabled (const int) const |
| Get "enabled" status of the specified button(s). More... | |
| void | setButtonEnabled (const bool, const int) |
| Enable/disable specified button(s). More... | |
| bool | isBorderEnabled (const int) const |
| Check if border is enabled. More... | |
| void | setBorderEnabled (const bool, const int) |
| Show/hide border for the specified button area. More... | |
| void | removeButton (const int) |
| Remove user button. More... | |
| int | insertButton (const QString &, const int=BottomArea) |
| Add user button to the dialog box. More... | |
| QIntList | userButtonIds () const |
| Get all user button IDs. More... | |
| QAbstractButton * | userButton (const int) const |
| Get user button by the specified id. More... | |
| uint | setAlignment (uint align) |
| Sets alignment policy. More... | |
Protected Types | |
| enum | { OpenFile , SaveFile , OpenDir , SaveDir , NewDir } |
Protected Types inherited from QtxDialog | |
| typedef QMap< int, QAbstractButton * > | ButtonMap |
| button map More... | |
Protected Slots | |
| void | validate () |
Check validity of the entered text and enable/disable standard OK, Yes buttons. More... | |
Protected Slots inherited from QtxDialog | |
| virtual void | accept () |
| Accept the dialog box. More... | |
| virtual void | reject () |
| Reject the dialog box. More... | |
Protected Member Functions | |
| QtxPathDialog (QWidget *=0, const bool=true, const bool=false, const int=Standard, Qt::WindowFlags=0) | |
| Constructor. More... | |
| virtual bool | isValid () |
| Check if the entered file/directory name is valid. More... | |
| virtual bool | acceptData () const |
| Check if the entered data is acceptable. More... | |
| virtual void | fileNameChanged (int, QString) |
| Perform custom actions when the file name is changed. More... | |
| QFrame * | optionsFrame () |
| Get options grame widget. More... | |
| QString | fileName (const int) const |
| Get file name from specified entry. More... | |
| void | setFileName (const int, const QString &, const bool=false) |
| Change file name by specified file entry. More... | |
| QString | filter (const int) const |
| Get file filter from the specified file entry. More... | |
| void | setFilter (const int, const QString &) |
| Set file filter to the specified file entry. More... | |
| QLineEdit * | fileEntry (const int) const |
| Get line edit widget for the specified file entry. More... | |
| QLineEdit * | fileEntry (const int, int &) const |
| Get line edit widget and file mode for the specified file entry. More... | |
| int | createFileEntry (const QString &, const int, const QString &=QString(), const int=-1) |
| Create new file entry. More... | |
| int | defaultEntry () const |
| Get default file entry ID. More... | |
| void | setDefaultEntry (const int) |
| Set default entry. More... | |
Protected Member Functions inherited from QtxDialog | |
| QFrame * | mainFrame () const |
| Get dialog box main frame widget. More... | |
| virtual bool | rejectData () const |
| Check if dialog box can be cancelled. More... | |
| virtual QAbstractButton * | createButton (QWidget *) |
| Create new user button. More... | |
| QAbstractButton * | button (const int) const |
| Get button by the specified ID. More... | |
| ButtonMap | buttons (const int=All) const |
| Get buttons by the specified IDs. More... | |
| int | buttonId (const QAbstractButton *) const |
| Get specified button's identifier. More... | |
| int | buttonPosition (QAbstractButton *) const |
| Get position of specified button. More... | |
| virtual void | showEvent (QShowEvent *) |
| Align this dialog according to the parent widget and alignment policy before the dialog box is shown. More... | |
| virtual void | hideEvent (QHideEvent *) |
| Process all existing events when dialog box is hidden. More... | |
| virtual void | closeEvent (QCloseEvent *) |
| Called when user closes dialog box. More... | |
| virtual void | childEvent (QChildEvent *) |
| Update dialog box layout when the size grip is added. More... | |
| virtual void | keyPressEvent (QKeyEvent *) |
| Process key pressing event. More... | |
Private Types | |
| typedef QMap< int, FileEntry > | FileEntryMap |
Private Slots | |
| void | onBrowse () |
| Called when user clicks a "browse" button to open standard file dialog. More... | |
| void | onReturnPressed () |
Called when user presses Return key being in the line edit. More... | |
| void | onTextChanged (const QString &) |
| Called when the text in the line edit is changed by the user. More... | |
Private Member Functions | |
| void | initialize () |
| Initialize dialog layout. More... | |
| void | updateVisibility () |
| Upadte dialof box's child widgets visibility state. More... | |
| QStringList | prepareFilters (const QString &) const |
| Prepare file filters. More... | |
| bool | hasVisibleChildren (QWidget *) const |
| Check if there are visible child widgets. More... | |
| QStringList | filterWildCards (const QString &) const |
| Get wildcards from the specified file filter. More... | |
| QString | autoExtension (const QString &, const QString &=QString()) const |
| Get file file name with automatically assigned extension. More... | |
Private Attributes | |
| FileEntryMap | myEntries |
| int | myDefault |
| QWidget * | myEntriesFrame |
| QFrame * | myOptionsFrame |
Additional Inherited Members | |
Public Types inherited from QtxDialog | |
| enum | PlacePolicy { Position , Expand , Uniform } |
| Buttons alignment type. More... | |
| enum | ButtonArea { TopArea , BottomArea , LeftArea , RightArea } |
| Buttons area. More... | |
| enum | ButtonPosition { Left , Right , Center , Top = Left , Bottom = Right } |
| Button position. More... | |
| enum | ButtonFlags { None = 0x00000000 , OK = 0x00000001 , Apply = 0x00000002 , Cancel = 0x00000004 , Yes = 0x00000008 , No = 0x00000010 , Close = 0x00000020 , Help = 0x00000040 , OKCancel = OK | Cancel , YesNo = Yes | No , Standard = OK | Cancel | Help , All = Standard | YesNo | Apply | Close } |
| Button ID flags. More... | |
| enum | DialogFlags { Accept = 0x000001 , Reject = 0x000002 , AlignOnce = 0x000004 , SetFocus = 0x000008 } |
| Dialog box flags. More... | |
Static Public Member Functions inherited from QtxDialog | |
| static void | setUnits (QLabel *, const QString &) |
| Set measure units to the specified label. More... | |
The QtxPathDialog class provides a simple convenience dialog to enter a path to the file or to the directory.
The QtxPathDialog class adds possibility to browse the file system with help of standard Open/Save dialog boxes or enter the file/directory path manually.
Default implementation provides only one "standard" file entry. Sometimes it is necessary to select several different files/directories from the same dialog box. In this case it is possible to derive from the QtxPathDialog class and use createFileEntry() method to add required number of file entries.
|
private |
|
protected |
Constructor.
| parent | parent widget |
| modal | if true, the dialog box should be modal |
| resize | if true, the dialog box is resizable |
| buttons | required buttons (QtxDialog::ButtonFlags) |
| f | window flags |
References initialize(), and updateVisibility().
| QtxPathDialog::QtxPathDialog | ( | const bool | import, |
| QWidget * | parent = 0, |
||
| const bool | modal = true, |
||
| const bool | resize = false, |
||
| const int | buttons = Standard, |
||
| Qt::WindowFlags | f = 0 |
||
| ) |
Constructor.
| import | if true, the dialog box is shown for "open" mode, otherwise, it is shown in the "save" mode |
| parent | parent widget |
| modal | if true, the dialog box should be modal |
| resize | if true, the dialog box is resizable |
| buttons | required buttons (QtxDialog::ButtonFlags) |
| f | window flags |
References createFileEntry(), defaultEntry(), fileEntry(), initialize(), OpenFile, SaveFile, setDefaultEntry(), updateVisibility(), and validate().
|
virtual |
Destructor.
|
protectedvirtual |
Check if the entered data is acceptable.
true if entered data is acceptable Reimplemented from QtxDialog.
References QtxPathDialog::FileEntry::edit, QtxPathDialog::FileEntry::mode, myEntries, NewDir, OpenDir, OpenFile, SaveDir, and SaveFile.
|
private |
Get file file name with automatically assigned extension.
| theFileName | file name being processed |
| theFilter | list of file filters |
References filter(), filterWildCards(), and prepareFilters().
|
protected |
Create new file entry.
If required file entry is already in use or if specified id is < 0, new ID is generated and returned.
| lab | file entry title |
| mode | file entry mode |
| id | required file entry ID |
References QtxPathDialog::FileEntry::btn, QtxPathDialog::FileEntry::dlg, QtxPathDialog::FileEntry::edit, filter(), QtxPathDialog::FileEntry::filter, QtxPathDialog::FileEntry::mode, myEntries, myEntriesFrame, NewDir, onBrowse(), onReturnPressed(), onTextChanged(), open_icon, OpenDir, OpenFile, Qtx::pathCompleter(), Qtx::PT_Directory, Qtx::PT_OpenFile, Qtx::PT_SaveFile, SaveDir, and SaveFile.
|
protected |
|
protected |
Get line edit widget for the specified file entry.
| id | file entry ID |
References myEntries.
|
protected |
Get line edit widget and file mode for the specified file entry.
| id | file entry ID |
| theMode | to return file entry mode |
References myEntries.
| QString QtxPathDialog::fileName | ( | ) | const |
|
protected |
Get file name from specified entry.
| id | file entry ID |
References myEntries.
|
protectedvirtual |
Perform custom actions when the file name is changed.
This method can be redefined in the successor classes. Default implementation does nothing.
| id | file entry |
| fileName | file name |
|
signal |
Emitted when the file name is changed.
| fileName | file name |
| QString QtxPathDialog::filter | ( | ) | const |
|
protected |
Get file filter from the specified file entry.
| id | file entry ID |
References myEntries.
|
private |
Get wildcards from the specified file filter.
| theFilter | file filter being processed |
|
private |
Check if there are visible child widgets.
| wid | parent widget being checked |
true if widget wid has visible children
|
private |
Initialize dialog layout.
References Horizontal, main(), QtxDialog::mainFrame(), myEntriesFrame, myOptionsFrame, and QtxGroupBox::setWidget().
|
protectedvirtual |
Check if the entered file/directory name is valid.
true if selected file name is valid References myEntries.
|
privateslot |
Called when user clicks a "browse" button to open standard file dialog.
References autoExtension(), defaultEntry(), QtxPathDialog::FileEntry::dlg, Qtx::extension(), fileName(), fileNameChanged(), QtxPathDialog::FileEntry::filter, QtxPathDialog::FileEntry::mode, myEntries, NewDir, OpenDir, OpenFile, prepareFilters(), SaveDir, SaveFile, and setFileName().
|
privateslot |
Called when user presses Return key being in the line edit.
References defaultEntry(), fileName(), fileNameChanged(), and myEntries.
|
privateslot |
Called when the text in the line edit is changed by the user.
| txt | current text (not used) |
References validate().
|
protected |
|
private |
Prepare file filters.
| list | of file masks, separated by ';;', for example, "*.h;;*.cxx" |
References filter(), and filterWildCards().
|
protected |
|
protected |
Change file name by specified file entry.
| id | file entry ID |
| txt | new file name |
| autoExt | if true, assign extension automatically |
References autoExtension(), fileEntry(), filter(), OpenFile, and SaveFile.
| void QtxPathDialog::setFileName | ( | const QString & | txt, |
| const bool | autoExtension = false |
||
| ) |
Set the file name.
| txt | new file name |
| autoExtension | if true an extension is determined automatically by file |
References autoExtension(), and defaultEntry().
|
protected |
| void QtxPathDialog::setFilter | ( | const QString & | fltr | ) |
Change file filter.
Filter is a list of file masks, separated by ';;'. For example, "*.h;;*.cxx"
| fltr | new file filter |
References defaultEntry().
|
virtualslot |
Show/hide the path dialog box/.
| on | new visibility state |
References QtxDialog::setVisible(), and updateVisibility().
|
private |
Upadte dialof box's child widgets visibility state.
References hasVisibleChildren(), myEntriesFrame, and myOptionsFrame.
|
protectedslot |
Check validity of the entered text and enable/disable standard OK, Yes buttons.
References isValid(), QtxDialog::OK, QtxDialog::setButtonEnabled(), and QtxDialog::Yes.
|
private |
|
private |
|
private |
|
private |