FileChooser.h
Go to the documentation of this file.
1
/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3
This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5
TerraLib is free software: you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published by
7
the Free Software Foundation, either version 3 of the License,
8
or (at your option) any later version.
9
10
TerraLib is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU Lesser General Public License for more details.
14
15
You should have received a copy of the GNU Lesser General Public License
16
along with TerraLib. See COPYING. If not, write to
17
TerraLib Team at <terralib-team@terralib.org>.
18
*/
19
20
/*!
21
\file FileChooser.h
22
23
\brief Defines a component for choose a file.
24
*/
25
#ifndef __TERRALIB_QT_WIDGETS_INTERNAL_FILECHOOSER_H
26
#define __TERRALIB_QT_WIDGETS_INTERNAL_FILECHOOSER_H
27
28
//TerraLib include files.
29
#include <
terralib/qt/widgets/Config.h
>
30
31
//Qt include files.
32
#include <QWidget>
33
#include <QModelIndex>
34
35
//Forward declarations
36
namespace
Ui
37
{
38
class
FileChooser;
39
}
40
41
class
QFileSystemModel;
42
43
namespace
te
44
{
45
namespace
qt
46
{
47
namespace
widgets
48
{
49
/*!
50
\class FileChooser
51
52
\brief Defines a component for choose a file.
53
54
This class is used for choosing a file. Its also possible to inform the file extensions to be searched. This way the
55
client can change the filter for the files to be listed when searching. The component is composed of a line edit containing the
56
complete path of the file selected and a tool button used to open de choose file dialog.
57
58
\ingroup widgets
59
*/
60
class
TEQTWIDGETSEXPORT
FileChooser
:
public
QWidget
61
{
62
Q_OBJECT
63
64
public
:
65
/*!
66
\enum ResourceType
67
\brief Type of resource required.
68
*/
69
enum
ResourceType
70
{
71
FILE
,
//!< Search files.
72
FOLDER
//!< Search folders.
73
};
74
75
/*!
76
\brief Constructor.
77
\param parent The QWidget parent argumnt.
78
*/
79
FileChooser
(QWidget* parent=0,
const
ResourceType
& type=FILE);
80
81
/*!
82
\brief Destructor.
83
*/
84
~FileChooser
();
85
86
/*!
87
\brief This will open the dialog of file selection in the given \a path.
88
\param path Path to open when initing a file search.
89
*/
90
void
setInitialPath
(
const
QString& path);
91
92
/*!
93
\brief Defines the filter for files of interest.
94
95
This can be used to restrict the seach for different kinds of files.
96
The client must use something like "Images(*.png *.bmp) Text files(*.txt)".
97
98
Example:
99
\code{.cpp}
100
FileChooser ch;
101
102
QString filter(tr("Images(*.png *.bmp) Text files(*.txt)");
103
ch.setFilterPattern(filter);
104
\endcode
105
In the above example two filters are created, for images and text files.
106
\param filter The filter pattern. For details of syntax, see QFileDialog documentation.
107
*/
108
void
setFilterPattern
(
const
QString& filter);
109
110
/*!
111
\brief Returns the text presented in line edit.
112
\return The complete path to the selected file.
113
*/
114
QString
getSelectedResource
()
const
;
115
116
/*!
117
\brief Updates the resource type of the search to be done.
118
\param type Resource type.
119
*/
120
void
setResourceType
(
const
ResourceType
& type);
121
122
/*!
123
\brief Sets the label to be presented.
124
\param label The new label.
125
*/
126
void
setLabel
(
const
QString& label);
127
128
signals:
129
130
/*!
131
\brief Emit a qt signal to inform that a resource was selected or defined.
132
\param s Resource Name.
133
*/
134
void
resourceSelected
(
const
QString&);
135
136
protected
slots
:
137
138
/*!
139
\brief Shows the file selection dialog.
140
*/
141
void
onChooseFileToolButtonClicked
();
142
143
/*!
144
\brief Event on return pressed over the resource line edit.
145
*/
146
void
onReturnPressed
();
147
148
protected
:
149
150
QFileSystemModel*
m_fp_model
;
//!< Model to show full path.
151
QString
m_filter
;
//!< Files filter.
152
153
private
:
154
155
Ui::FileChooser*
m_ui
;
//!< Qt ui pointer.
156
157
/*!
158
\name Copy methods.
159
No copy allowed.
160
*/
161
//@{
162
163
/*!
164
\brief Copy constructor.
165
*/
166
FileChooser
(
const
FileChooser
&);
167
168
/*!
169
\brief Copy operator.
170
*/
171
FileChooser
&
operator=
(
const
FileChooser
&);
172
//@}
173
};
174
}
175
}
176
}
177
178
#endif
//__TERRALIB_QT_WIDGETS_INTERNAL_FILECHOOSER_H
te::qt::widgets::FileChooser
Defines a component for choose a file.
Definition:
FileChooser.h:61
te::qt::widgets::FileChooser::getSelectedResource
QString getSelectedResource() const
Returns the text presented in line edit.
te::qt::widgets::FileChooser::onChooseFileToolButtonClicked
void onChooseFileToolButtonClicked()
Shows the file selection dialog.
te::qt::widgets::FileChooser::onReturnPressed
void onReturnPressed()
Event on return pressed over the resource line edit.
te::qt::widgets::FileChooser::setInitialPath
void setInitialPath(const QString &path)
This will open the dialog of file selection in the given path.
te::qt::widgets::FileChooser::ResourceType
ResourceType
Type of resource required.
Definition:
FileChooser.h:70
te::qt::widgets::FileChooser::FILE
@ FILE
Search files.
Definition:
FileChooser.h:71
te::qt::widgets::FileChooser::operator=
FileChooser & operator=(const FileChooser &)
Copy operator.
te::qt::widgets::FileChooser::m_filter
QString m_filter
Files filter.
Definition:
FileChooser.h:151
te::qt::widgets::FileChooser::resourceSelected
void resourceSelected(const QString &)
Emit a qt signal to inform that a resource was selected or defined.
te::qt::widgets::FileChooser::m_ui
Ui::FileChooser * m_ui
Qt ui pointer.
Definition:
FileChooser.h:155
te::qt::widgets::FileChooser::m_fp_model
QFileSystemModel * m_fp_model
Model to show full path.
Definition:
FileChooser.h:150
te::qt::widgets::FileChooser::~FileChooser
~FileChooser()
Destructor.
te::qt::widgets::FileChooser::setResourceType
void setResourceType(const ResourceType &type)
Updates the resource type of the search to be done.
te::qt::widgets::FileChooser::setLabel
void setLabel(const QString &label)
Sets the label to be presented.
te::qt::widgets::FileChooser::setFilterPattern
void setFilterPattern(const QString &filter)
Defines the filter for files of interest.
te::qt::widgets::FileChooser::FileChooser
FileChooser(const FileChooser &)
Copy constructor.
te::qt::widgets::FileChooser::FileChooser
FileChooser(QWidget *parent=0, const ResourceType &type=FILE)
Constructor.
Ui
Definition:
ConfigInputAddressDialog.h:44
te
TerraLib.
Definition:
AddressGeocodingOp.h:52
slots
#define slots
Definition:
VirtualMachine.h:48
Config.h
Configuration flags for the TerraLib Qt Widgets.
TEQTWIDGETSEXPORT
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition:
Config.h:63
git_release
src
terralib
qt
widgets
utils
FileChooser.h
Generated on Mon Dec 19 2022 08:37:06 for TerraLib by
1.9.1