FileDialog.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 terralib/qt/widgets/utils/FileDialog.h
22 
23  \brief An instance of QFileDialog that includes file extention if necessary.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_FILEDIALOG_H
27 #define __TERRALIB_QT_WIDGETS_INTERNAL_FILEDIALOG_H
28 
29 // TerraLib
30 #include "../Config.h"
31 
32 // Qt
33 #include <QDialog>
34 #include <QFileDialog>
35 
36 namespace te
37 {
38  namespace qt
39  {
40  namespace widgets
41  {
42  /*!
43  \class FileDialog
44 
45  \brief Defines a component for choose a file.
46 
47  This class is used to create a QFileDialog in order to facilitate the use of file path,
48  file name and file extension.
49 
50  \ingroup widgets
51  */
53  {
54  public:
55 
56  enum FileType
57  {
59  VECTOR
60  };
61 
62  /*!
63  \brief Constructor.
64  \param parent The QWidget parent argumnt.
65  */
66  FileDialog(QWidget* parent, FileType type, std::string pathInfo = "");
67 
68  /*!
69  \brief Destructor.
70  */
72 
73  /*!
74  \brief This method will open the dialog of file selection and
75  populate the class members with the chosen file path.
76  */
77  void exec();
78 
79  /*!
80  \brief This method will return the chosen path.
81  \return The complete chosen path.
82  */
83  std::string getPath();
84 
85  /*!
86  \brief Sets the file path.
87  \param The file path.
88  */
89  void setPath(std::string filePath);
90 
91  /*!
92  \brief This method will return the file name.
93  \return The complete chosen file name.
94  */
95  std::string getFileName();
96 
97  /*!
98  \brief Sets the file name.
99  \param The file path with a file name.
100  */
101  void setFileName(std::string filePath);
102 
103  /*!
104  \brief This method will return the file extension.
105  \return The complete chosen file extension.
106  */
107  std::string getExtension();
108 
109  /*!
110  \brief Sets the file extension.
111  \param The file path with a file and an extension.
112  */
113  void setExtension(std::string filePath);
114 
115  /*!
116  \brief Genarate an extensions map with the extensions returned by driver.
117  \param The extensions returned by driver.
118  */
119  std::map<QString, QString> getMappedExtensions(QString extensions);
120 
121  /*!
122  \brief Verify if the file name has special characters
123  \param The name of the file.
124  */
125  bool hasInvalidCharacters(std::string filename);
126 
127  private:
128 
129  QWidget* m_parent; //!< The QWidget parent argumnt.
130  FileType m_type; //!< The type of file.
131  std::string m_fileInfo; //!< The file path info.
132  std::string m_path; //!< The path of the file.
133  std::string m_fileName; //!< The name of the file.
134  std::string m_extension; //!< The extension of the file.
135  };
136 
137  } // end namespace widgets
138  } // end namespace qt
139 } // end namespace te
140 
141 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_FILEDIALOG_H
142 
Defines a component for choose a file.
Definition: FileDialog.h:52
std::string m_extension
The extension of the file.
Definition: FileDialog.h:134
std::string m_path
The path of the file.
Definition: FileDialog.h:132
URI C++ Library.
~FileDialog()
Destructor.
Definition: FileDialog.h:71
std::string m_fileName
The name of the file.
Definition: FileDialog.h:133
QWidget * m_parent
The QWidget parent argumnt.
Definition: FileDialog.h:129
FileType m_type
The type of file.
Definition: FileDialog.h:130
std::string m_fileInfo
The file path info.
Definition: FileDialog.h:131
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63