itom
Loading...
Searching...
No Matches
PathLineEdit Class Reference

Advanced line edit to select a file or directory. More...

#include <pathLineEdit.h>

Inheritance diagram for PathLineEdit:

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

 Q_ENUM (SizeAdjustPolicy)
 
 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 length)
 
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< PathLineEditPrivated_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)
 

Detailed Description

Advanced line edit to select a file or directory.

See also
ctkDirectoryButton, ctkPathListWidget

Member Enumeration Documentation

◆ SizeAdjustPolicy

Enumerator
AdjustToContents 

The path line edit will always adjust to the contents.

AdjustToContentsOnFirstShow 

The path line edit will adjust to its contents the first time it is shown.

AdjustToMinimumContentsLength 

The combobox will adjust to minimumContentsLength. For performance reasons use this policy on large models.

Constructor & Destructor Documentation

◆ PathLineEdit() [1/2]

PathLineEdit::PathLineEdit ( QWidget * parent = 0)

Default constructor

◆ PathLineEdit() [2/2]

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

Member Function Documentation

◆ addCurrentPathToHistory

void PathLineEdit::addCurrentPathToHistory ( )
slot

Save the current value (this->currentPath()) into the history. That value will be retrieved next time retrieveHistory() is called.

See also
retrieveHistory(), showHistoryButton, settingKey

◆ browse

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

See also
showBrowseButton

◆ minimumSizeHint()

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.

◆ retrieveHistory

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

See also
addCurrentPathToHistory(), showHistoryButton, settingKey

◆ setCurrentFileExtension()

void PathLineEdit::setCurrentFileExtension ( const QString & extension)

Change the current extension of the edit line. If there is no extension yet, set it

◆ setOptions()

void PathLineEdit::setOptions ( const Options & options)

Options of the file dialog pop up.

See also
QFileDialog::getExistingDirectory

◆ sizeAdjustPolicy()

PathLineEdit::SizeAdjustPolicy PathLineEdit::sizeAdjustPolicy ( ) const

the policy describing how the size of the combobox changes when the content changes

The default value is AdjustToContentsOnFirstShow.

See also
SizeAdjustPolicy

◆ sizeHint()

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.

◆ validInputChanged

void PathLineEdit::validInputChanged ( bool )
signal

the signal is emit when the state of hasValidInput changed

Property Documentation

◆ minimumContentsLength

int PathLineEdit::minimumContentsLength
readwrite

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.

◆ nameFilters

QStringList PathLineEdit::nameFilters
readwrite

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)"

◆ options

Options PathLineEdit::options
readwrite

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 instantiating a QFileDialog in PathLineEdit::browse()

◆ settingKey

QString PathLineEdit::settingKey
readwrite

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.

See also
retrieveHistory(), addCurrentPathToHistory(), showHistoryButton

◆ showBrowseButton

bool PathLineEdit::showBrowseButton
readwrite

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

See also
browse()

◆ showHistoryButton

bool PathLineEdit::showHistoryButton
readwrite

This property controls whether the history button (arrow button that opens the history menu) is visible or not. True by default.

See also
retrieveHistory(), addCurrentPathToHistory(), settingKey

◆ sizeAdjustPolicy

SizeAdjustPolicy PathLineEdit::sizeAdjustPolicy
readwrite

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.


The documentation for this class was generated from the following files: