All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

Type of resource required.

Enumerator
FILE 

Search files.

FOLDER 

Search folders.

Definition at line 69 of file FileChooser.h.

Constructor & Destructor Documentation

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

Constructor.

Parameters
parentThe 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 ( )

Destructor.

Definition at line 55 of file FileChooser.cpp.

References m_ui.

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

Copy constructor.

Member Function Documentation

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

Returns the text presented in line edit.

Returns
The complete path to the selected file.

Definition at line 76 of file FileChooser.cpp.

References m_ui.

Referenced by onChooseFileToolButtonClicked().

void te::qt::widgets::FileChooser::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.

void te::qt::widgets::FileChooser::onReturnPressed ( )
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().

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

Copy operator.

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.

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:

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.

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.

Parameters
pathPath 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.

Parameters
labelThe 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.

Parameters
typeResource type.

Definition at line 81 of file FileChooser.cpp.

References FILE, FOLDER, and m_fp_model.

Referenced by FileChooser().

Member Data Documentation

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

Files filter.

Definition at line 151 of file FileChooser.h.

Referenced by onChooseFileToolButtonClicked(), and setFilterPattern().

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

Model to show full path.

Definition at line 150 of file FileChooser.h.

Referenced by FileChooser(), onChooseFileToolButtonClicked(), setFilterPattern(), setInitialPath(), and setResourceType().

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

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