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 ApplicationController;
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  */
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(te::qt::af::ApplicationController* appController, 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  */
210  //TEQTAFEXPORT bool GetOpenLastProjectFromSettings();
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 Check QSettings for existance of \a act and adds it if necessary.
242 
243  \param act Action to be inserted.
244  */
246 
247  /*!
248  \brief Returns the complete path of the configuration file or an empty value if it not exists.
249  */
250  //TEQTAFEXPORT QString GetConfigFileName();
251 
252  /*!
253  \brief Setts the name of the application configuration file.
254 
255  \param fileName Complete path to the application configuration file.
256  */
257  TEQTAFEXPORT void SetConfigFileName(const QString& fileName);
258 
259  /*!
260  \brief
261  */
262  TEQTAFEXPORT QString GetDateTime();
263 
264  /*!
265  \brief
266  \param
267  */
268  TEQTAFEXPORT void SetDateTime(const QString& dateTime);
269 
270 
271  /*!
272  \brief Returns the default path for output of configuration file.
273  */
275 
276  TEQTAFEXPORT std::vector<std::string> GetPluginsFiles();
277 
278  TEQTAFEXPORT std::vector<std::string> GetDefaultPluginsNames(te::qt::af::ApplicationController* appController);
279 
280  TEQTAFEXPORT std::vector<std::string> GetPluginsNames(const std::vector<std::string>& plgFiles);
281 
282  /*!
283  \brief Changes the user settings file location.
284 
285  \param fileName The new file to be generated.
286 
287  \param removeOlder Flag information the remove older settings file. If true remove the older file, otherwise maintain it.
288  */
289  TEQTAFEXPORT void UpdateUserSettingsFile(const QString& fileName, const bool& removeOlder = true);
290 
291  /*!
292  \brief Changes the application plugins file location.
293 
294  \param fileName The new file to be generated.
295 
296  \param removeOlder Flag information the remove older application plugins file. If true remove the older file, otherwise maintain it.
297  */
298  TEQTAFEXPORT void UpdateAppPluginsFile(const QString& fileName, const bool& removeOlder = true);
299 
300  /*!
301  \brief Writes the configuration file. It updates the application settings.
302 
303  \param fileName Complete path to the configuration file.
304 
305  \param appName Name of the application.
306 
307  \param appTitle Title to be presented on the main window.
308  */
309  //TEQTAFEXPORT void WriteConfigFile(const QString& fileName, const QString& appName, const QString& appTitle, const bool& writeOnlyConfig = false);
310 
311  /*!
312  \brief Writes the user settings file.
313  */
314  //TEQTAFEXPORT void WriteUserSettingsFile(const QString& fileName);
315 
316  /*!
317  \brief Writes the application plugins file.
318  */
319  //TEQTAFEXPORT void WriteAppPluginsFile(const QString& fileName);
320 
321  /*!
322  \brief Writes the default project file.
323  */
324  //TEQTAFEXPORT void WriteDefaultProjectFile(const QString& fileName);
325 
326  /*!
327  \brief Returns the date and time of generated binary.
328  */
330 
331  } // end namespace af
332  } // end namespace qt
333 } // end namespace te
334 
335 #endif // __TERRALIB_QT_AF_INTERNAL_UTILS_H
336 
TEQTAFEXPORT void UpdateUserSettingsFile(const QString &fileName, const bool &removeOlder=true)
Changes the user settings file location.
TEQTAFEXPORT void SetDateTime(const QString &dateTime)
TEQTAFEXPORT std::vector< std::string > GetPluginsFiles()
TEQTAFEXPORT void AddActionToCustomToolbars(te::qt::af::ApplicationController *appController, QAction *act)
Check QSettings for existance of act and adds it if necessary.
TEQTAFEXPORT QString GetGenerationDate()
Writes the configuration file. It updates the application settings.
The base API for TerraLib applications.
TEQTAFEXPORT bool GetAlternateRowColorsFromSettings()
TEQTAFEXPORT void AddToolBarToSettings(QToolBar *bar)
Update settings with a new tool bar.
Configuration flags for the TerraLib Application Framework.
TEQTAFEXPORT void RemoveToolBarFromSettings(QToolBar *bar)
Removes a tool bar from the settings.
TEQTAFEXPORT QColor GetDefaultDisplayColorFromSettings()
TEQTAFEXPORT std::vector< std::string > GetPluginsNames(const std::vector< std::string > &plgFiles)
TEQTAFEXPORT void RestoreState(QMainWindow *mainWindow)
TEQTAFEXPORT std::vector< QToolBar * > ReadToolBarsFromSettings(te::qt::af::ApplicationController *appController, QWidget *barsParent=0)
Returns a vector of tool bars registered in the QSettings.
TEQTAFEXPORT void SaveState(QMainWindow *mainWindow)
TEQTAFEXPORT QString GetLastDatasourceFromSettings()
TEQTAFEXPORT QString GetDefaultConfigFileOutputDir()
Returns the default path for output of configuration file.
URI C++ Library.
TEQTAFEXPORT void SaveLastDatasourceOnSettings(const QString &dsType)
TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
TEQTAFEXPORT QString GetDateTime()
TEQTAFEXPORT void SaveDataSourcesFile(te::qt::af::ApplicationController *appController)
Saves data sources file.
#define TEQTAFEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:71
TEQTAFEXPORT void UpdateUserSettings()
Reads and return a te::qt::af::Project from the file.
TEQTAFEXPORT QString UnsavedStar(const QString windowTitle, bool isUnsaved)
Unsaved star.
TEQTAFEXPORT std::vector< std::string > GetDefaultPluginsNames(te::qt::af::ApplicationController *appController)
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 QString GetStyleSheetFromSettings()
TEQTAFEXPORT void UpdateToolBarsInTheSettings(te::qt::af::ApplicationController *appController)
Update plugins file.
A class that models a XML writer object built on top of Xerces-C++.