te::qt::widgets::FileChooser Class Reference

Defines a component for choose a file. More...

#include <FileChooser.h>

Inheritance diagram for te::qt::widgets::FileChooser:

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...
 
FileChooseroperator= (const FileChooser &)
 Copy operator. More...
 

Private Attributes

Ui::FileChooser * m_ui
 Qt ui pointer. More...
 

Detailed Description

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.

Member Enumeration Documentation

◆ ResourceType

Type of resource required.

Enumerator
FILE 

Search files.

FOLDER 

Search folders.

Definition at line 69 of file FileChooser.h.

Constructor & Destructor Documentation

◆ FileChooser() [1/2]

te::qt::widgets::FileChooser::FileChooser ( QWidget *  parent = 0,
const ResourceType type = FILE 
)

Constructor.

Parameters
parentThe QWidget parent argumnt.

◆ ~FileChooser()

te::qt::widgets::FileChooser::~FileChooser ( )

Destructor.

◆ FileChooser() [2/2]

te::qt::widgets::FileChooser::FileChooser ( const FileChooser )
private

Copy constructor.

Member Function Documentation

◆ getSelectedResource()

QString te::qt::widgets::FileChooser::getSelectedResource ( ) const

Returns the text presented in line edit.

Returns
The complete path to the selected file.

◆ onChooseFileToolButtonClicked

void te::qt::widgets::FileChooser::onChooseFileToolButtonClicked ( )
protectedslot

Shows the file selection dialog.

◆ onReturnPressed

void te::qt::widgets::FileChooser::onReturnPressed ( )
protectedslot

Event on return pressed over the resource line edit.

◆ operator=()

FileChooser& te::qt::widgets::FileChooser::operator= ( const FileChooser )
private

Copy operator.

◆ resourceSelected

void te::qt::widgets::FileChooser::resourceSelected ( const QString &  )
signal

Emit a qt signal to inform that a resource was selected or defined.

Parameters
sResource Name.

◆ setFilterPattern()

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:

QString filter(tr("Images(*.png *.bmp) Text files(*.txt)");
ch.setFilterPattern(filter);

In the above example two filters are created, for images and text files.

Parameters
filterThe filter pattern. For details of syntax, see QFileDialog documentation.

◆ setInitialPath()

void te::qt::widgets::FileChooser::setInitialPath ( const QString &  path)

This will open the dialog of file selection in the given path.

Parameters
pathPath to open when initing a file search.

◆ setLabel()

void te::qt::widgets::FileChooser::setLabel ( const QString &  label)

Sets the label to be presented.

Parameters
labelThe new label.

◆ setResourceType()

void te::qt::widgets::FileChooser::setResourceType ( const ResourceType type)

Updates the resource type of the search to be done.

Parameters
typeResource type.

Member Data Documentation

◆ m_filter

QString te::qt::widgets::FileChooser::m_filter
protected

Files filter.

Definition at line 151 of file FileChooser.h.

◆ m_fp_model

QFileSystemModel* te::qt::widgets::FileChooser::m_fp_model
protected

Model to show full path.

Definition at line 150 of file FileChooser.h.

◆ m_ui

Ui::FileChooser* te::qt::widgets::FileChooser::m_ui
private

Qt ui pointer.

Definition at line 155 of file FileChooser.h.


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