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) 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/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 QString;
39 class QColor;
40 class QAction;
41 class QMainWindow;
42 class QStringList;
43 class QToolBar;
44 class QWidget;
45 
46 namespace te
47 {
48 
49 // Forward declaration
50  namespace xml
51  {
52  class AbstractWriter;
53  class Reader;
54  }
55 
56  namespace qt
57  {
58  namespace af
59  {
60  class Project;
61 
62  /*!
63  \brief Reads and return a te::qt::af::Project from the file.
64 
65  \param uri Location of the te::qt::af::Project file.
66 
67  \return A pointer to the te::qt::af::Project defined in the \a uri file.
68  */
69  TEQTAFEXPORT Project* ReadProject(const std::string& uri);
70 
71  /*!
72  \brief Reads and return a te::qt::af::Project using \a reader XML reader.
73 
74  \param reader The XML reader to be used.
75 
76  \return A pointer to the te::qt::af::Project.
77  */
78  TEQTAFEXPORT Project* ReadProject(te::xml::Reader& reader);
79 
80  /*!
81  \brief Saves the informations of the project in the \a uri file.
82 
83  \param project The te::qt::af::Project to be saved.
84 
85  \param uri File location.
86  */
87  TEQTAFEXPORT void Save(const Project& project, const std::string& uri);
88 
89  /*!
90  \brief Saves the informations of the te::qt::af::Project using \a writer XML writer.
91 
92  \param project The te::qt::af::Project to be saved.
93 
94  \param writer The XML writer to be used.
95  */
96  TEQTAFEXPORT void Save(const Project& project, te::xml::AbstractWriter& writer);
97 
98  /*!
99  \brief Updates user settings file section about information of the projects.
100 
101  \param prjFiles List of the files containing projects.
102 
103  \param prjTitles List of the titles of the projects.
104 
105  \param userConfigFile Name of the user configuration file.
106  */
107  TEQTAFEXPORT void UpdateUserSettings(const QStringList& prjFiles, const QStringList& prjTitles, const std::string& userConfigFile);
108 
109  /*!
110  \brief Saves data sources file.
111  */
113 
114  /*!
115  \brief Unsaved star
116  */
117  TEQTAFEXPORT QString UnsavedStar(const QString windowTitle, bool isUnsaved);
118 
119  /*!
120  \brief Update plugins file.
121  */
122  //TEQTAFEXPORT void UpdateApplicationPlugins();
123 
124  /*!
125  \brief Update the existing tool bars
126 
127  \param bars Set with the existing tool bars.
128  */
130 
131  /*!
132  \brief Update settings with a new tool bar.
133 
134  \param bar Bar to be added.
135  */
136  TEQTAFEXPORT void AddToolBarToSettings(QToolBar* bar);
137 
138  /*!
139  \brief Removes a tool bar from the settings.
140 
141  \param bar Bar to be removed.
142  */
143  TEQTAFEXPORT void RemoveToolBarFromSettings(QToolBar* bar);
144 
145  /*!
146  \brief Returns a vector of tool bars registered in the QSettings.
147 
148  \param barsParent
149  */
150  TEQTAFEXPORT std::vector<QToolBar*> ReadToolBarsFromSettings(QWidget* barsParent=0);
151 
152  /*
153  \brief
154 
155  \param
156  */
157  TEQTAFEXPORT void SaveState(QMainWindow* mainWindow);
158 
159  /*
160  \brief
161 
162  \param
163  */
164  TEQTAFEXPORT void RestoreState(QMainWindow* mainWindow);
165 
166  /*
167  \brief
168 
169  \param[out]
170 
171  \param[out]
172  */
173  TEQTAFEXPORT void GetProjectInformationsFromSettings(QString& defaultAuthor, int& maxSaved);
174 
175  /*
176  \brief
177 
178  \param
179 
180  \param
181  */
182  TEQTAFEXPORT void SaveProjectInformationsOnSettings(const QString& defaultAuthor, const int& maxSaved);
183 
184  /*!
185  \brief
186 
187  \param
188  */
189  TEQTAFEXPORT void SaveLastDatasourceOnSettings(const QString& dsType);
190 
191  /*!
192  \brief
193 
194  \param
195  */
196  TEQTAFEXPORT void SaveOpenLastProjectOnSettings(bool openLast);
197 
198  /*!
199  \brief
200 
201  \return
202  */
204 
205  /*!
206  \brief
207 
208  \return
209  */
211 
212  /*!
213  \brief
214 
215  \return
216  */
218 
219  /*!
220  \brief
221 
222  \return
223  */
224  TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor);
225 
226  /*!
227  \brief
228 
229  \return
230  */
232 
233  /*!
234  \brief
235 
236  \return
237  */
239 
240  /*!
241  \brief Creates a default QSettings.
242  */
244 
245  /*!
246  \brief Check QSettings for existance of \a act and adds it if necessary.
247 
248  \param act Action to be inserted.
249  */
250  TEQTAFEXPORT void AddActionToCustomToolbars(QAction* act);
251 
252  /*!
253  \brief Returns the complete path of the configuration file or an empty value if it not exists.
254  */
255  //TEQTAFEXPORT QString GetConfigFileName();
256 
257  /*!
258  \brief Setts the name of the application configuration file.
259 
260  \param fileName Complete path to the application configuration file.
261  */
262  TEQTAFEXPORT void SetConfigFileName(const QString& fileName);
263 
264  /*!
265  \brief
266  */
267  TEQTAFEXPORT QString GetDateTime();
268 
269  /*!
270  \brief
271  \param
272  */
273  TEQTAFEXPORT void SetDateTime(const QString& dateTime);
274 
275 
276  /*!
277  \brief Returns the default path for output of configuration file.
278  */
280 
281  TEQTAFEXPORT std::vector<std::string> GetPluginsFiles();
282 
283  TEQTAFEXPORT std::vector<std::string> GetDefaultPluginsNames();
284 
285  TEQTAFEXPORT std::vector<std::string> GetPluginsNames(const std::vector<std::string>& plgFiles);
286 
287  /*!
288  \brief Changes the user settings file location.
289 
290  \param fileName The new file to be generated.
291 
292  \param removeOlder Flag information the remove older settings file. If true remove the older file, otherwise maintain it.
293  */
294  TEQTAFEXPORT void UpdateUserSettingsFile(const QString& fileName, const bool& removeOlder = true);
295 
296  /*!
297  \brief Changes the application plugins file location.
298 
299  \param fileName The new file to be generated.
300 
301  \param removeOlder Flag information the remove older application plugins file. If true remove the older file, otherwise maintain it.
302  */
303  TEQTAFEXPORT void UpdateAppPluginsFile(const QString& fileName, const bool& removeOlder = true);
304 
305  /*!
306  \brief Writes the configuration file. It updates the application settings.
307 
308  \param fileName Complete path to the configuration file.
309 
310  \param appName Name of the application.
311 
312  \param appTitle Title to be presented on the main window.
313  */
314  //TEQTAFEXPORT void WriteConfigFile(const QString& fileName, const QString& appName, const QString& appTitle, const bool& writeOnlyConfig = false);
315 
316  /*!
317  \brief Writes the user settings file.
318  */
319  //TEQTAFEXPORT void WriteUserSettingsFile(const QString& fileName);
320 
321  /*!
322  \brief Writes the application plugins file.
323  */
324  //TEQTAFEXPORT void WriteAppPluginsFile(const QString& fileName);
325 
326  /*!
327  \brief Writes the default project file.
328  */
329  TEQTAFEXPORT void WriteDefaultProjectFile(const QString& fileName);
330 
331  /*!
332  \brief Return a QString with the new window title based on the project informations.
333  */
334  TEQTAFEXPORT QString GetWindowTitle(const Project& project);
335 
336  /*!
337  \brief Returns the date and time of generated binary.
338  */
340 
341  /*!
342  \brief Return extension filter string
343  */
345  } // end namespace af
346  } // end namespace qt
347 } // end namespace te
348 
349 #endif // __TERRALIB_QT_AF_INTERNAL_UTILS_H
350 
TEQTAFEXPORT void RemoveToolBarFromSettings(QToolBar *bar)
Removes a tool bar from the settings.
Definition: Utils.cpp:484
TEQTAFEXPORT void UpdateToolBarsInTheSettings()
Update plugins file.
Definition: Utils.cpp:453
TEQTAFEXPORT QColor GetDefaultDisplayColorFromSettings()
Definition: Utils.cpp:715
TEQTAFEXPORT std::vector< std::string > GetPluginsFiles()
Definition: Utils.cpp:794
This class models a XML reader object.
Definition: Reader.h:55
TEQTAFEXPORT void CreateDefaultSettings()
Creates a default QSettings.
Definition: Utils.cpp:621
TEQTAFEXPORT void SaveOpenLastProjectOnSettings(bool openLast)
Definition: Utils.cpp:594
TEQTAFEXPORT QString GetWindowTitle(const Project &project)
Return a QString with the new window title based on the project informations.
Definition: Utils.cpp:954
TEQTAFEXPORT void SetDateTime(const QString &dateTime)
Definition: Utils.cpp:859
TEQTAFEXPORT std::vector< QToolBar * > ReadToolBarsFromSettings(QWidget *barsParent=0)
Returns a vector of tool bars registered in the QSettings.
Definition: Utils.cpp:493
TEQTAFEXPORT QString UnsavedStar(const QString windowTitle, bool isUnsaved)
Unsaved star.
Definition: Utils.cpp:697
TEQTAFEXPORT void SaveLastDatasourceOnSettings(const QString &dsType)
Definition: Utils.cpp:587
Configuration flags for the TerraLib Application Framework.
This class models a XML writer object.
TEQTAFEXPORT void SaveState(QMainWindow *mainWindow)
Definition: Utils.cpp:547
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:320
TEQTAFEXPORT bool GetAlternateRowColorsFromSettings()
Definition: Utils.cpp:755
TEQTAFEXPORT void SaveDataSourcesFile()
Saves data sources file.
Definition: Utils.cpp:413
TEQTAFEXPORT void AddToolBarToSettings(QToolBar *bar)
Update settings with a new tool bar.
Definition: Utils.cpp:473
TEQTAFEXPORT void UpdateUserSettingsFile(const QString &fileName, const bool &removeOlder=true)
Changes the user settings file location.
Definition: Utils.cpp:875
TEQTAFEXPORT void AddActionToCustomToolbars(QAction *act)
Check QSettings for existance of act and adds it if necessary.
Definition: Utils.cpp:763
TEQTAFEXPORT void SaveProjectInformationsOnSettings(const QString &defaultAuthor, const int &maxSaved)
Definition: Utils.cpp:577
TEQTAFEXPORT std::vector< std::string > GetDefaultPluginsNames()
Definition: Utils.cpp:814
TEQTAFEXPORT QString GetDefaultConfigFileOutputDir()
Returns the default path for output of configuration file.
Definition: Utils.cpp:866
TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
Definition: Utils.cpp:727
TEQTAFEXPORT void GetProjectInformationsFromSettings(QString &defaultAuthor, int &maxSaved)
Definition: Utils.cpp:567
TEQTAFEXPORT void RestoreState(QMainWindow *mainWindow)
Definition: Utils.cpp:557
TEQTAFEXPORT QString GetGenerationDate()
Returns the date and time of generated binary.
Definition: Utils.cpp:938
TEQTAFEXPORT QString GetDateTime()
Definition: Utils.cpp:852
TEQTAFEXPORT QString GetExtensionFilter()
Return extension filter string.
Definition: Utils.cpp:971
#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:909
TEQTAFEXPORT QString GetStyleSheetFromSettings()
Definition: Utils.cpp:738
TEQTAFEXPORT Project * ReadProject(const std::string &uri)
Reads and return a te::qt::af::Project from the file.
Definition: Utils.cpp:77
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:608
TEQTAFEXPORT void Save(const Project &project, const std::string &uri)
Saves the informations of the project in the uri file.
Definition: Utils.cpp:194
TEQTAFEXPORT std::vector< std::string > GetPluginsNames(const std::vector< std::string > &plgFiles)
Definition: Utils.cpp:836
A class that models a XML writer object built on top of Xerces-C++.
TEQTAFEXPORT QString GetLastDatasourceFromSettings()
Definition: Utils.cpp:601