Defines a component for choose a file. More...
#include <FileChooser.h>
Public Types | |
enum | ResourceType { FILE, FOLDER } |
Type of resource required. More... | |
Signals | |
void | resourceSelected (const QString &) |
Emit a qt signal to inform that a resource was selected or defined. More... | |
Public Member Functions | |
FileChooser (QWidget *parent=0, const ResourceType &type=FILE) | |
Constructor. More... | |
QString | getSelectedResource () const |
Returns the text presented in line edit. More... | |
void | setFilterPattern (const QString &filter) |
Defines the filter for files of interest. More... | |
void | setInitialPath (const QString &path) |
This will open the dialog of file selection in the given path. More... | |
void | setLabel (const QString &label) |
Sets the label to be presented. More... | |
void | setResourceType (const ResourceType &type) |
Updates the resource type of the search to be done. More... | |
~FileChooser () | |
Destructor. More... | |
Protected Slots | |
void | onChooseFileToolButtonClicked () |
Shows the file selection dialog. More... | |
void | onReturnPressed () |
Event on return pressed over the resource line edit. More... | |
Protected Attributes | |
QString | m_filter |
Files filter. More... | |
QFileSystemModel * | m_fp_model |
Model to show full path. More... | |
Private Member Functions | |
Copy methods. | |
No copy allowed. | |
FileChooser (const FileChooser &) | |
Copy constructor. More... | |
FileChooser & | operator= (const FileChooser &) |
Copy operator. More... | |
Private Attributes | |
Ui::FileChooser * | m_ui |
Qt ui pointer. More... | |
Defines a component for choose a file.
This class is used for choosing a file. Its also possible to inform the file extensions to be searched. This way the client can change the filter for the files to be listed when searching. The component is composed of a line edit containing the complete path of the file selected and a tool button used to open de choose file dialog.
Definition at line 60 of file FileChooser.h.
Type of resource required.
Enumerator | |
---|---|
FILE |
Search files. |
FOLDER |
Search folders. |
Definition at line 69 of file FileChooser.h.
te::qt::widgets::FileChooser::FileChooser | ( | QWidget * | parent = 0 , |
const ResourceType & | type = FILE |
||
) |
Constructor.
parent | The QWidget parent argumnt. |
Definition at line 34 of file FileChooser.cpp.
References m_fp_model, m_ui, onReturnPressed(), resourceSelected(), setInitialPath(), and setResourceType().
te::qt::widgets::FileChooser::~FileChooser | ( | ) |
|
private |
Copy constructor.
QString te::qt::widgets::FileChooser::getSelectedResource | ( | ) | const |
Returns the text presented in line edit.
Definition at line 76 of file FileChooser.cpp.
References m_ui.
Referenced by onChooseFileToolButtonClicked().
|
protectedslot |
Shows the file selection dialog.
Definition at line 105 of file FileChooser.cpp.
References getSelectedResource(), m_filter, m_fp_model, and m_ui.
|
protectedslot |
Event on return pressed over the resource line edit.
Definition at line 125 of file FileChooser.cpp.
References m_ui, and resourceSelected().
Referenced by FileChooser().
|
private |
Copy operator.
|
signal |
Emit a qt signal to inform that a resource was selected or defined.
s | Resource Name. |
Referenced by FileChooser(), and onReturnPressed().
void te::qt::widgets::FileChooser::setFilterPattern | ( | const QString & | filter | ) |
Defines the filter for files of interest.
This can be used to restrict the seach for different kinds of files. The client must use something like "Images(*.png *.bmp) Text files(*.txt)".
Example:
In the above example two filters are created, for images and text files.
filter | The filter pattern. For details of syntax, see QFileDialog documentation. |
Definition at line 70 of file FileChooser.cpp.
References getExtensionFilters(), m_filter, and m_fp_model.
void te::qt::widgets::FileChooser::setInitialPath | ( | const QString & | path | ) |
This will open the dialog of file selection in the given path.
path | Path to open when initing a file search. |
Definition at line 60 of file FileChooser.cpp.
References m_fp_model, and m_ui.
Referenced by FileChooser(), and te::qt::widgets::ResourceChooser::getResource().
void te::qt::widgets::FileChooser::setLabel | ( | const QString & | label | ) |
Sets the label to be presented.
label | The new label. |
Definition at line 99 of file FileChooser.cpp.
References m_ui.
void te::qt::widgets::FileChooser::setResourceType | ( | const ResourceType & | type | ) |
Updates the resource type of the search to be done.
type | Resource type. |
Definition at line 81 of file FileChooser.cpp.
References FILE, FOLDER, and m_fp_model.
Referenced by FileChooser().
|
protected |
Files filter.
Definition at line 151 of file FileChooser.h.
Referenced by onChooseFileToolButtonClicked(), and setFilterPattern().
|
protected |
Model to show full path.
Definition at line 150 of file FileChooser.h.
Referenced by FileChooser(), onChooseFileToolButtonClicked(), setFilterPattern(), setInitialPath(), and setResourceType().
|
private |
Qt ui pointer.
Definition at line 155 of file FileChooser.h.
Referenced by FileChooser(), getSelectedResource(), onChooseFileToolButtonClicked(), onReturnPressed(), setInitialPath(), setLabel(), and ~FileChooser().