itom 2.2.1
|
Advanced line edit to select a file or directory. More...
#include <pathLineEdit.h>
Public Types | |
enum | Filter { Dirs = 0x001, Files = 0x002, Drives = 0x004, NoSymLinks = 0x008, AllEntries = Dirs | Files | Drives, TypeMask = 0x00f, Readable = 0x010, Writable = 0x020, Executable = 0x040, PermissionMask = 0x070, Modified = 0x080, Hidden = 0x100, System = 0x200, AccessMask = 0x3F0, AllDirs = 0x400, CaseSensitive = 0x800, NoDotAndDotDot = 0x1000, NoDot = 0x2000, NoDotDot = 0x4000, NoFilter = -1 } |
enum | Option { ShowDirsOnly = 0x00000001, DontResolveSymlinks = 0x00000002, DontConfirmOverwrite = 0x00000004, DontUseSheet = 0x00000008, DontUseNativeDialog = 0x00000010, ReadOnly = 0x00000020, HideNameFilterDetails = 0x00000040 } |
enum | SizeAdjustPolicy { AdjustToContents, AdjustToContentsOnFirstShow, AdjustToMinimumContentsLength } |
Public Slots | |
void | setCurrentPath (const QString &path) |
void | browse () |
void | retrieveHistory () |
void | addCurrentPathToHistory () |
Signals | |
void | validInputChanged (bool) |
void | currentPathChanged (const QString &path) |
Public Member Functions | |
PathLineEdit (QWidget *parent=0) | |
PathLineEdit (const QString &label, const QStringList &nameFilters, Filters filters=PathLineEdit::AllEntries, QWidget *parent=0) | |
QString | currentPath () const |
void | setLabel (const QString &label) |
const QString & | label () const |
void | setNameFilters (const QStringList &nameFilters) |
const QStringList & | nameFilters () const |
void | setFilters (const Filters &filters) |
Filters | filters () const |
void | setOptions (const Options &options) |
const Options & | options () const |
void | setCurrentFileExtension (const QString &extension) |
QString | settingKey () const |
void | setSettingKey (const QString &key) |
bool | showBrowseButton () const |
void | setShowBrowseButton (bool visible) |
bool | showHistoryButton () const |
void | setShowHistoryButton (bool visible) |
SizeAdjustPolicy | sizeAdjustPolicy () const |
void | setSizeAdjustPolicy (SizeAdjustPolicy policy) |
int | minimumContentsLength () const |
void | setMinimumContentsLength (int lenght) |
QComboBox * | comboBox () const |
Return the combo box internally used by the path line edit. | |
virtual QSize | minimumSizeHint () const |
virtual QSize | sizeHint () const |
Protected Slots | |
void | setCurrentDirectory (const QString &directory) |
void | updateHasValidInput () |
Protected Attributes | |
QScopedPointer < PathLineEditPrivate > | d_ptr |
Properties | |
QString | label |
Filters | filters |
QString | currentPath |
Options | options |
QString | settingKey |
bool | showBrowseButton |
bool | showHistoryButton |
SizeAdjustPolicy | sizeAdjustPolicy |
int | minimumContentsLength |
QStringList | nameFilters |
Private Member Functions | |
Q_DECLARE_PRIVATE (PathLineEdit) | |
Q_DISABLE_COPY (PathLineEdit) |
Advanced line edit to select a file or directory.
PathLineEdit::PathLineEdit | ( | QWidget * | parent = 0 | ) |
Default constructor
PathLineEdit::PathLineEdit | ( | const QString & | label, |
const QStringList & | nameFilters, | ||
Filters | filters = PathLineEdit::AllEntries , |
||
QWidget * | parent = 0 |
||
) |
Constructor /param label Used in file dialogs /param nameFilters Regular expression (in wildcard mode) used to help the user to complete the line, example: "Images (*.jpg *.gif *.png)" /param parent Parent widget
void PathLineEdit::addCurrentPathToHistory | ( | ) | [slot] |
Save the current value (this->currentPath()) into the history. That value will be retrieved next time retrieveHistory() is called.
void PathLineEdit::browse | ( | ) | [slot] |
Open a QFileDialog to select a file or directory and set current text to it You would probably connect a browse push button like this: connect(myPushButton,SIGNAL(clicked()),myPathLineEdit,SLOT(browse())) As a conveniency, such button is provided by default via the browseButton
QSize PathLineEdit::minimumSizeHint | ( | ) | const [virtual] |
The width returned, in pixels, is the length of the file name (with no path) if any. Otherwise, it's enough for 15 to 20 characters.
void PathLineEdit::retrieveHistory | ( | ) | [slot] |
Load the history of the paths that have been saved in the application settings with addCurrentPathToHistory(). The history is identified using settingKey
void PathLineEdit::setCurrentFileExtension | ( | const QString & | extension | ) |
Change the current extension of the edit line. If there is no extension yet, set it
void PathLineEdit::setOptions | ( | const Options & | options | ) |
Options of the file dialog pop up.
SizeAdjustPolicy PathLineEdit::sizeAdjustPolicy | ( | ) | const |
the policy describing how the size of the combobox changes when the content changes
The default value is AdjustToContentsOnFirstShow
.
QSize PathLineEdit::sizeHint | ( | ) | const [virtual] |
The width returned, in pixels, is the entire length of the current path if any. Otherwise, it's enough for 15 to 20 characters.
void PathLineEdit::validInputChanged | ( | bool | ) | [signal] |
the signal is emit when the state of hasValidInput changed
int PathLineEdit::minimumContentsLength [read, write] |
This property holds the minimum number of characters that should fit into the path line edit. The default value is 0. If this property is set to a positive value, the minimumSizeHint() and sizeHint() take it into account.
const QStringList & PathLineEdit::nameFilters [read, write] |
This property holds the list of regular expressions (in wildcard mode) used to help the user complete a line. For example: "Images (*.jpg *.gif *.png)"
const PathLineEdit::Options & PathLineEdit::options [read, write] |
Qt versions prior to 4.7.0 didn't expose QFileDialog::Options in the public API. We need to create a custom property that will be used when instanciating a QFileDialog in PathLineEdit::browse()
QString PathLineEdit::settingKey [read, write] |
This property controls the key used to search the settings for recorded paths. If multiple path line edits share the same key, their history is then shared. If an empty key string is given, the object name is used as key. Setting the key automatically retrieve the history from settings Empty by default.
bool PathLineEdit::showBrowseButton [read, write] |
This property controls whether the browse ("...") button is visible or not. Clicking on the button calls opens a dialog to select the current path. True by default
bool PathLineEdit::showHistoryButton [read, write] |
This property controls whether the history button (arrow button that opens the history menu) is visible or not. True by default.
PathLineEdit::SizeAdjustPolicy PathLineEdit::sizeAdjustPolicy [read, write] |
This property holds the policy describing how the size of the path line edit widget changes when the content changes. The default value is AdjustToContentsOnFirstShow.