Toolbox Qt
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
tbq::FileChooser Class Reference

Used to choose a file from user-space. More...

Inheritance diagram for tbq::FileChooser:
Inheritance graph
[legend]
Collaboration diagram for tbq::FileChooser:
Collaboration graph
[legend]

Public Types

enum  Type { CHOOSE_FILE_EXIST , CHOOSE_FILE_CREATE }
 

Static Public Member Functions

static QFileInfo fromUserSpaceFile (Type idType, QStandardPaths::StandardLocation stdLocation, const QString &keyLatest=QString(), const QString &filter=QString(), QWidget *parent=nullptr)
 Choose a file from user-space with standard location.
 
static QFileInfo fromUserSpaceFile (Type idType, const QString &dirLocation, const QString &keyLatest=QString(), const QString &filter=QString(), QWidget *parent=nullptr)
 Choose a file from user-space.
 
static QString fromUserSpaceDir (QStandardPaths::StandardLocation stdLocation, const QString &keyLatest=QString(), QWidget *parent=nullptr)
 Choose a directory from user-space with standard location.
 
static QString fromUserSpaceDir (const QString &dirLocation, const QString &keyLatest=QString(), QWidget *parent=nullptr)
 Choose a directory from user-space.
 
static QString getPathFromKey (const QString &key, const QString &defaultValue=QString())
 Allow to retrieve a FileChooser path from key.
 

Detailed Description

Used to choose a file from user-space.

This class provide methods making easier to choose a file from user-space.

Member Function Documentation

◆ fromUserSpaceDir() [1/2]

QString tbq::FileChooser::fromUserSpaceDir ( const QString &  dirLocation,
const QString &  keyLatest = QString(),
QWidget *  parent = nullptr 
)
static

Choose a directory from user-space.

Allow to choose directory from user-space and allowing to easily remember latest.

Parameters
[in]dirLocationDefault directory to used when opening directory dialog window
[in]keyLatestIf not empty, provided key will be read from tbq::SettingsIni and use the registered directory in it (and save it when directory dialog window is closed).
This is useful to directly open directory dialog window to the latest used.
[in,out]parentParent widget.
Returns
Returns selected directory path.
This value will be empty if no file has been selected.
See also
fromUserSpaceFile()

◆ fromUserSpaceDir() [2/2]

QString tbq::FileChooser::fromUserSpaceDir ( QStandardPaths::StandardLocation  stdLocation,
const QString &  keyLatest = QString(),
QWidget *  parent = nullptr 
)
static

Choose a directory from user-space with standard location.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ fromUserSpaceFile() [1/2]

QFileInfo tbq::FileChooser::fromUserSpaceFile ( Type  idType,
const QString &  dirLocation,
const QString &  keyLatest = QString(),
const QString &  filter = QString(),
QWidget *  parent = nullptr 
)
static

Choose a file from user-space.

Allow to choose file from user-space and allowing to easily remember latest used directory.

Parameters
[in]idTypeType of file to choose.
If unknown, nothing will be performed.
[in]dirLocationDefault directory to used when opening file dialog window
[in]keyLatestIf not empty, provided key will be read from tbq::SettingsIni and use the registered directory in it (and save it when file dialog window is closed).
This is useful to directly open file dialog window to the latest use directory for this specific ressource
[in]filterFilter to use. Can be set using:
tr("Images (*.png *.xpm *.jpg)" // Only display images files
tr("Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" // Allow multiple filters (separated with ";;")
[in,out]parentParent widget.
Returns
Returns file information of the selected file.
This value will be empty if no file has been selected.
Can be verified with QFileInfo::filePath() method.
See also
fromUserSpaceDir()

◆ fromUserSpaceFile() [2/2]

QFileInfo tbq::FileChooser::fromUserSpaceFile ( Type  idType,
QStandardPaths::StandardLocation  stdLocation,
const QString &  keyLatest = QString(),
const QString &  filter = QString(),
QWidget *  parent = nullptr 
)
static

Choose a file from user-space with standard location.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getPathFromKey()

QString tbq::FileChooser::getPathFromKey ( const QString &  key,
const QString &  defaultValue = QString() 
)
static

Allow to retrieve a FileChooser path from key.

Parameters
[in]keyKey used to perform registration
[in]defaultValueDefault value to use if key doesn't exist or if value is empty.
Returns
Returns string path associated to key

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