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 Load setted dpi X and Y. If there is no configuration to load,
221  it fills dpiX and dpiY with -1.
222 
223  \param dpiX to be filled
224  \param dpiY to be filled
225  */
226  TEQTAFEXPORT void GetDPIValuesFromSettings(int& dpiX, int& dpiY);
227 
228  /*!
229  \brief
230 
231  \return
232  */
233  TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor);
234 
235  /*!
236  \brief
237 
238  \return
239  */
241 
242  /*!
243  \brief
244 
245  \return
246  */
248 
249  /*!
250  \brief Check QSettings for existance of \a act and adds it if necessary.
251 
252  \param act Action to be inserted.
253  */
255 
256  /*!
257  \brief Returns the complete path of the configuration file or an empty value if it not exists.
258  */
259  //TEQTAFEXPORT QString GetConfigFileName();
260 
261  /*!
262  \brief Setts the name of the application configuration file.
263 
264  \param fileName Complete path to the application configuration file.
265  */
266  TEQTAFEXPORT void SetConfigFileName(const QString& fileName);
267 
268  /*!
269  \brief
270  */
271  TEQTAFEXPORT QString GetDateTime();
272 
273  /*!
274  \brief
275  \param
276  */
277  TEQTAFEXPORT void SetDateTime(const QString& dateTime);
278 
279 
280  /*!
281  \brief Returns the default path for output of configuration file.
282  */
284 
285  TEQTAFEXPORT std::vector<std::string> GetPluginsFiles();
286 
287  TEQTAFEXPORT std::vector<std::string> GetDefaultPluginsNames(te::qt::af::ApplicationController* appController);
288 
289  TEQTAFEXPORT std::vector<std::string> GetPluginsNames(const std::vector<std::string>& plgFiles);
290 
291  /*!
292  \brief Changes the user settings file location.
293 
294  \param fileName The new file to be generated.
295 
296  \param removeOlder Flag information the remove older settings file. If true remove the older file, otherwise maintain it.
297  */
298  TEQTAFEXPORT void UpdateUserSettingsFile(const QString& fileName, const bool& removeOlder = true);
299 
300  /*!
301  \brief Changes the application plugins file location.
302 
303  \param fileName The new file to be generated.
304 
305  \param removeOlder Flag information the remove older application plugins file. If true remove the older file, otherwise maintain it.
306  */
307  TEQTAFEXPORT void UpdateAppPluginsFile(const QString& fileName, const bool& removeOlder = true);
308 
309  /*!
310  \brief Writes the configuration file. It updates the application settings.
311 
312  \param fileName Complete path to the configuration file.
313 
314  \param appName Name of the application.
315 
316  \param appTitle Title to be presented on the main window.
317  */
318  //TEQTAFEXPORT void WriteConfigFile(const QString& fileName, const QString& appName, const QString& appTitle, const bool& writeOnlyConfig = false);
319 
320  /*!
321  \brief Writes the user settings file.
322  */
323  //TEQTAFEXPORT void WriteUserSettingsFile(const QString& fileName);
324 
325  /*!
326  \brief Writes the application plugins file.
327  */
328  //TEQTAFEXPORT void WriteAppPluginsFile(const QString& fileName);
329 
330  /*!
331  \brief Writes the default project file.
332  */
333  //TEQTAFEXPORT void WriteDefaultProjectFile(const QString& fileName);
334 
335  /*!
336  \brief Returns the date and time of generated binary.
337  */
339 
340  } // end namespace af
341  } // end namespace qt
342 } // end namespace te
343 
344 #endif // __TERRALIB_QT_AF_INTERNAL_UTILS_H
345 
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 void GetDPIValuesFromSettings(int &dpiX, int &dpiY)
Load setted dpi X and Y. If there is no configuration to load, it fills dpiX and dpiY with -1...
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++.