Toolbox Qt
Loading...
Searching...
No Matches
tbq::FileChooser Class Reference

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

Inheritance diagram for tbq::FileChooser:
Collaboration diagram for tbq::FileChooser:

Public Types

enum  Type { CHOOSE_FILE_EXIST , CHOOSE_FILE_CREATE }
 

Static Public Member Functions

static QString fromUserSpaceFile (QWidget *parent, Type idType, QStandardPaths::StandardLocation stdLocation, const QString &filter=QString(), SettingsIni *settings=nullptr, const QString &keyLatest=QString())
 Choose a file from user-space with standard location.
 
static QString fromUserSpaceFile (QWidget *parent, Type idType, const QString &dirLocation, const QString &filter=QString(), SettingsIni *settings=nullptr, const QString &keyLatest=QString())
 Choose a file from user-space.
 
static QStringList fromUserSpaceFiles (QWidget *parent, QStandardPaths::StandardLocation stdLocation, const QString &filter=QString(), SettingsIni *settings=nullptr, const QString &keyLatest=QString())
 Choose multiple files from user-space with standard location.
 
static QStringList fromUserSpaceFiles (QWidget *parent, const QString &dirLocation, const QString &filter=QString(), SettingsIni *settings=nullptr, const QString &keyLatest=QString())
 Choose multiple files from user-space.
 
static QString fromUserSpaceDir (QWidget *parent, QStandardPaths::StandardLocation stdLocation, SettingsIni *settings=nullptr, const QString &keyLatest=QString())
 Choose a directory from user-space with standard location.
 
static QString fromUserSpaceDir (QWidget *parent, const QString &dirLocation, SettingsIni *settings=nullptr, const QString &keyLatest=QString())
 Choose a directory from user-space.
 
static QString getPathFromKey (const SettingsIni *settings, 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

◆ fromUserSpaceFile() [1/2]

QString tbq::FileChooser::fromUserSpaceFile ( QWidget * parent,
Type idType,
QStandardPaths::StandardLocation stdLocation,
const QString & filter = QString(),
SettingsIni * settings = nullptr,
const QString & keyLatest = QString() )
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.

◆ fromUserSpaceFile() [2/2]

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

Choose a file from user-space.

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

Parameters
[in,out]parentParent widget.
[in]idTypeType of file to choose.
If unknown, nothing will be performed.
[in]dirLocationDefault directory to used when opening file dialog window
[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]settingsSettings entity to use store if using keyLatest argument.
Nothing performed if nullptr.
[in]keyLatestIf not empty, provided key will be read from setting argument 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
Returns
Returns absolute path of the selected file.
This value will be empty if no file has been selected.
See also
fromUserSpaceFile()
fromUserSpaceDir()

◆ fromUserSpaceFiles() [1/2]

QStringList tbq::FileChooser::fromUserSpaceFiles ( QWidget * parent,
QStandardPaths::StandardLocation stdLocation,
const QString & filter = QString(),
SettingsIni * settings = nullptr,
const QString & keyLatest = QString() )
static

Choose multiple files 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.

◆ fromUserSpaceFiles() [2/2]

QStringList tbq::FileChooser::fromUserSpaceFiles ( QWidget * parent,
const QString & dirLocation,
const QString & filter = QString(),
SettingsIni * settings = nullptr,
const QString & keyLatest = QString() )
static

Choose multiple files from user-space.

Allow to choose list of files from user-space and allow to easily remember latest used directory.

Parameters
[in,out]parentParent widget.
[in]dirLocationDefault directory to used when opening file dialog window
[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]settingsSettings entity to use store if using keyLatest argument.
Nothing performed if nullptr.
[in]keyLatestIf not empty, provided key will be read from setting argument 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
Returns
Returns absolute path of selected files.
This value will be empty if no file has been selected.
See also
fromUserSpaceFile()
fromUserSpaceDir()

◆ fromUserSpaceDir() [1/2]

QString tbq::FileChooser::fromUserSpaceDir ( QWidget * parent,
QStandardPaths::StandardLocation stdLocation,
SettingsIni * settings = nullptr,
const QString & keyLatest = QString() )
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.

◆ fromUserSpaceDir() [2/2]

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

Choose a directory from user-space.

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

Parameters
[in,out]parentParent widget.
[in]dirLocationDefault directory to used when opening directory dialog window
[in,out]settingsSettings entity to use store if using keyLatest argument.
Nothing performed if nullptr.
[in]keyLatestIf not empty, provided key will be read from setting argument 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.
Returns
Returns selected directory path.
This value will be empty if no file has been selected.
See also
fromUserSpaceFile(), fromUserSpaceFiles()

◆ getPathFromKey()

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

Allow to retrieve a FileChooser path from key.

Parameters
[in]settingSetting instance to use.
Must be not NULL.
[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: