All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Utils.h
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 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/af/Utils.h
22 
23  \brief Utility routines for the TerraLib Application Framework module.
24 */
25 
26 #ifndef __TERRALIB_QT_AF_INTERNAL_UTILS_H
27 #define __TERRALIB_QT_AF_INTERNAL_UTILS_H
28 
29 // TerraLib
30 #include "../../common/Exception.h"
31 #include "Config.h"
32 
33 // Qt
34 #include <QtCore/QString>
35 #include <QtGui/QColor>
36 
37 // Forward declarations
38 class QAction;
39 class QMainWindow;
40 class QStringList;
41 class QToolBar;
42 class QWidget;
43 
44 namespace te
45 {
46 
47 // Forward declaration
48  namespace xml
49  {
50  class Reader;
51  class Writer;
52  }
53 
54  namespace qt
55  {
56  namespace af
57  {
58  class Project;
59 
60  /*!
61  \brief Reads and return a te::qt::af::Project from the file.
62 
63  \param uri Location of the te::qt::af::Project file.
64 
65  \return A pointer to the te::qt::af::Project defined in the \a uri file.
66  */
67  TEQTAFEXPORT Project* ReadProject(const std::string& uri);
68 
69  /*!
70  \brief Reads and return a te::qt::af::Project using \a reader XML reader.
71 
72  \param reader The XML reader to be used.
73 
74  \return A pointer to the te::qt::af::Project.
75  */
76  TEQTAFEXPORT Project* ReadProject(te::xml::Reader& reader);
77 
78  /*!
79  \brief Saves the informations of the project in the \a uri file.
80 
81  \param project The te::qt::af::Project to be saved.
82 
83  \param uri File location.
84  */
85  TEQTAFEXPORT void Save(const Project& project, const std::string& uri);
86 
87  /*!
88  \brief Saves the informations of the te::qt::af::Project using \a writer XML writer.
89 
90  \param project The te::qt::af::Project to be saved.
91 
92  \param writer The XML writer to be used.
93  */
94  TEQTAFEXPORT void Save(const Project& project, te::xml::Writer& writer);
95 
96  /*!
97  \brief Updates user settings file section about information of the projects.
98 
99  \param prjFiles List of the files containing projects.
100 
101  \param prjTitles List of the titles of the projects.
102 
103  \param userConfigFile Name of the user configuration file.
104  */
105  TEQTAFEXPORT void UpdateUserSettings(const QStringList& prjFiles, const QStringList& prjTitles, const std::string& userConfigFile);
106 
107  /*!
108  \brief Saves data sources file.
109  */
111 
112  /*!
113  \brief Unsaved star
114  */
115  TEQTAFEXPORT QString UnsavedStar(const QString windowTitle, bool isUnsaved);
116 
117  /*!
118  \brief Update plugins file.
119  */
120  //TEQTAFEXPORT void UpdateApplicationPlugins();
121 
122  /*!
123  \brief Update the existing tool bars
124 
125  \param bars Set with the existing tool bars.
126  */
128 
129  /*!
130  \brief Update settings with a new tool bar.
131 
132  \param bar Bar to be added.
133  */
134  TEQTAFEXPORT void AddToolBarToSettings(QToolBar* bar);
135 
136  /*!
137  \brief Removes a tool bar from the settings.
138 
139  \param bar Bar to be removed.
140  */
141  TEQTAFEXPORT void RemoveToolBarFromSettings(QToolBar* bar);
142 
143  /*!
144  \brief Returns a vector of tool bars registered in the QSettings.
145 
146  \param barsParent
147  */
148  TEQTAFEXPORT std::vector<QToolBar*> ReadToolBarsFromSettings(QWidget* barsParent=0);
149 
150  /*
151  \brief
152 
153  \param
154  */
155  TEQTAFEXPORT void SaveState(QMainWindow* mainWindow);
156 
157  /*
158  \brief
159 
160  \param
161  */
162  TEQTAFEXPORT void RestoreState(QMainWindow* mainWindow);
163 
164  /*
165  \brief
166 
167  \param[out]
168 
169  \param[out]
170  */
171  TEQTAFEXPORT void GetProjectInformationsFromSettings(QString& defaultAuthor, int& maxSaved);
172 
173  /*
174  \brief
175 
176  \param
177 
178  \param
179  */
180  TEQTAFEXPORT void SaveProjectInformationsOnSettings(const QString& defaultAuthor, const int& maxSaved);
181 
182  /*!
183  \brief
184 
185  \param
186  */
187  TEQTAFEXPORT void SaveLastDatasourceOnSettings(const QString& dsType);
188 
189  /*!
190  \brief
191 
192  \param
193  */
194  TEQTAFEXPORT void SaveOpenLastProjectOnSettings(bool openLast);
195 
196  /*!
197  \brief
198 
199  \return
200  */
202 
203  /*!
204  \brief
205 
206  \return
207  */
209 
210  /*!
211  \brief
212 
213  \return
214  */
216 
217  /*!
218  \brief
219 
220  \return
221  */
222  TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor);
223 
224  /*!
225  \brief
226 
227  \return
228  */
230 
231  /*!
232  \brief
233 
234  \return
235  */
237 
238  /*!
239  \brief Creates a default QSettings.
240  */
242 
243  /*!
244  \brief Check QSettings for existance of \a act and adds it if necessary.
245 
246  \param act Action to be inserted.
247  */
248  TEQTAFEXPORT void AddActionToCustomToolbars(QAction* act);
249 
250  /*!
251  \brief Returns the complete path of the configuration file or an empty value if it not exists.
252  */
253  //TEQTAFEXPORT QString GetConfigFileName();
254 
255  /*!
256  \brief Setts the name of the application configuration file.
257 
258  \param fileName Complete path to the application configuration file.
259  */
260  TEQTAFEXPORT void SetConfigFileName(const QString& fileName);
261 
262  /*!
263  \brief
264  */
265  TEQTAFEXPORT QString GetDateTime();
266 
267  /*!
268  \brief
269  \param
270  */
271  TEQTAFEXPORT void SetDateTime(const QString& dateTime);
272 
273 
274  /*!
275  \brief Returns the default path for output of configuration file.
276  */
278 
279  TEQTAFEXPORT std::vector<std::string> GetPluginsFiles();
280 
281  TEQTAFEXPORT std::vector<std::string> GetPluginsNames(const std::vector<std::string>& plgFiles);
282 
283  /*!
284  \brief Changes the user settings file location.
285 
286  \param fileName The new file to be generated.
287 
288  \param removeOlder Flag information the remove older settings file. If true remove the older file, otherwise maintain it.
289  */
290  TEQTAFEXPORT void UpdateUserSettingsFile(const QString& fileName, const bool& removeOlder = true);
291 
292  /*!
293  \brief Changes the application plugins file location.
294 
295  \param fileName The new file to be generated.
296 
297  \param removeOlder Flag information the remove older application plugins file. If true remove the older file, otherwise maintain it.
298  */
299  TEQTAFEXPORT void UpdateAppPluginsFile(const QString& fileName, const bool& removeOlder = true);
300 
301  /*!
302  \brief Writes the configuration file. It updates the application settings.
303 
304  \param fileName Complete path to the configuration file.
305 
306  \param appName Name of the application.
307 
308  \param appTitle Title to be presented on the main window.
309  */
310  //TEQTAFEXPORT void WriteConfigFile(const QString& fileName, const QString& appName, const QString& appTitle, const bool& writeOnlyConfig = false);
311 
312  /*!
313  \brief Writes the user settings file.
314  */
315  //TEQTAFEXPORT void WriteUserSettingsFile(const QString& fileName);
316 
317  /*!
318  \brief Writes the application plugins file.
319  */
320  //TEQTAFEXPORT void WriteAppPluginsFile(const QString& fileName);
321 
322  /*!
323  \brief Writes the default project file.
324  */
325  TEQTAFEXPORT void WriteDefaultProjectFile(const QString& fileName);
326 
327  /*!
328  \brief Returns the date and time of generated binary.
329  */
331  } // end namespace af
332  } // end namespace qt
333 } // end namespace te
334 
335 #endif // __TERRALIB_QT_AF_INTERNAL_UTILS_H
336 
TEQTAFEXPORT void RemoveToolBarFromSettings(QToolBar *bar)
Removes a tool bar from the settings.
Definition: Utils.cpp:351
TEQTAFEXPORT void UpdateToolBarsInTheSettings()
Update plugins file.
Definition: Utils.cpp:320
TEQTAFEXPORT QColor GetDefaultDisplayColorFromSettings()
Definition: Utils.cpp:582
TEQTAFEXPORT std::vector< std::string > GetPluginsFiles()
Definition: Utils.cpp:661
This class models a XML reader object.
Definition: Reader.h:55
TEQTAFEXPORT void CreateDefaultSettings()
Creates a default QSettings.
Definition: Utils.cpp:488
TEQTAFEXPORT void SaveOpenLastProjectOnSettings(bool openLast)
Definition: Utils.cpp:461
This class models a XML writer object.
Definition: Writer.h:52
TEQTAFEXPORT void SetDateTime(const QString &dateTime)
Definition: Utils.cpp:704
TEQTAFEXPORT std::vector< QToolBar * > ReadToolBarsFromSettings(QWidget *barsParent=0)
Returns a vector of tool bars registered in the QSettings.
Definition: Utils.cpp:360
TEQTAFEXPORT QString UnsavedStar(const QString windowTitle, bool isUnsaved)
Unsaved star.
Definition: Utils.cpp:564
TEQTAFEXPORT void SaveLastDatasourceOnSettings(const QString &dsType)
Definition: Utils.cpp:454
Configuration flags for the TerraLib Application Framework.
TEQTAFEXPORT void SaveState(QMainWindow *mainWindow)
Definition: Utils.cpp:414
TEQTAFEXPORT void UpdateUserSettings(const QStringList &prjFiles, const QStringList &prjTitles, const std::string &userConfigFile)
Updates user settings file section about information of the projects.
Definition: Utils.cpp:222
TEQTAFEXPORT bool GetAlternateRowColorsFromSettings()
Definition: Utils.cpp:622
TEQTAFEXPORT void SaveDataSourcesFile()
Saves data sources file.
Definition: Utils.cpp:280
TEQTAFEXPORT void AddToolBarToSettings(QToolBar *bar)
Update settings with a new tool bar.
Definition: Utils.cpp:340
TEQTAFEXPORT void UpdateUserSettingsFile(const QString &fileName, const bool &removeOlder=true)
Changes the user settings file location.
Definition: Utils.cpp:720
TEQTAFEXPORT void AddActionToCustomToolbars(QAction *act)
Check QSettings for existance of act and adds it if necessary.
Definition: Utils.cpp:630
TEQTAFEXPORT void SaveProjectInformationsOnSettings(const QString &defaultAuthor, const int &maxSaved)
Definition: Utils.cpp:444
TEQTAFEXPORT QString GetDefaultConfigFileOutputDir()
Returns the default path for output of configuration file.
Definition: Utils.cpp:711
TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
Definition: Utils.cpp:594
TEQTAFEXPORT void GetProjectInformationsFromSettings(QString &defaultAuthor, int &maxSaved)
Definition: Utils.cpp:434
TEQTAFEXPORT void RestoreState(QMainWindow *mainWindow)
Definition: Utils.cpp:424
TEQTAFEXPORT QString GetGenerationDate()
Returns the date and time of generated binary.
Definition: Utils.cpp:775
TEQTAFEXPORT QString GetDateTime()
Definition: Utils.cpp:697
#define TEQTAFEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:81
TEQTAFEXPORT void WriteDefaultProjectFile(const QString &fileName)
Writes the configuration file. It updates the application settings.
Definition: Utils.cpp:750
TEQTAFEXPORT QString GetStyleSheetFromSettings()
Definition: Utils.cpp:605
TEQTAFEXPORT Project * ReadProject(const std::string &uri)
Reads and return a te::qt::af::Project from the file.
Definition: Utils.cpp:68
TEQTAFEXPORT void UpdateAppPluginsFile(const QString &fileName, const bool &removeOlder=true)
Changes the application plugins file location.
TEQTAFEXPORT void SetConfigFileName(const QString &fileName)
Returns the complete path of the configuration file or an empty value if it not exists.
TEQTAFEXPORT bool GetOpenLastProjectFromSettings()
Definition: Utils.cpp:475
TEQTAFEXPORT void Save(const Project &project, const std::string &uri)
Saves the informations of the project in the uri file.
Definition: Utils.cpp:162
TEQTAFEXPORT std::vector< std::string > GetPluginsNames(const std::vector< std::string > &plgFiles)
Definition: Utils.cpp:681
TEQTAFEXPORT QString GetLastDatasourceFromSettings()
Definition: Utils.cpp:468