Loading...
Searching...
No Matches
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.
30
31//Qt include files.
32#include <QWidget>
33#include <QModelIndex>
34
35//Forward declarations
36namespace Ui
37{
38 class FileChooser;
39}
40
41class QFileSystemModel;
42
43namespace 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 */
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 */
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 */
142
143 /*!
144 \brief Event on return pressed over the resource line edit.
145 */
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 */
167
168 /*!
169 \brief Copy operator.
170 */
172 //@}
173 };
174 }
175 }
176}
177
178#endif //__TERRALIB_QT_WIDGETS_INTERNAL_FILECHOOSER_H
Defines a component for choose a file.
Definition: FileChooser.h:61
QString getSelectedResource() const
Returns the text presented in line edit.
FileChooser & operator=(const FileChooser &)
Copy operator.
void onChooseFileToolButtonClicked()
Shows the file selection dialog.
void onReturnPressed()
Event on return pressed over the resource line edit.
void setInitialPath(const QString &path)
This will open the dialog of file selection in the given path.
ResourceType
Type of resource required.
Definition: FileChooser.h:70
QString m_filter
Files filter.
Definition: FileChooser.h:151
void resourceSelected(const QString &)
Emit a qt signal to inform that a resource was selected or defined.
Ui::FileChooser * m_ui
Qt ui pointer.
Definition: FileChooser.h:155
QFileSystemModel * m_fp_model
Model to show full path.
Definition: FileChooser.h:150
void setResourceType(const ResourceType &type)
Updates the resource type of the search to be done.
void setLabel(const QString &label)
Sets the label to be presented.
void setFilterPattern(const QString &filter)
Defines the filter for files of interest.
FileChooser(const FileChooser &)
Copy constructor.
FileChooser(QWidget *parent=0, const ResourceType &type=FILE)
Constructor.
TerraLib.
#define slots
Configuration flags for the TerraLib Qt Widgets.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63