All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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  */
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  } // end namespace af
251  } // end namespace qt
252 } // end namespace te
253 
254 #endif // __TERRALIB_QT_AF_INTERNAL_UTILS_H
255 
TEQTAFEXPORT void AddToolBarToSettings(QToolBar *bar)
Update settings with a new tool bar.
Definition: Utils.cpp:361
TEQTAFEXPORT bool GetAlternateRowColorsFromSettings()
Definition: Utils.cpp:643
This class models a XML reader object.
Definition: Reader.h:55
TEQTAFEXPORT void RemoveToolBarFromSettings(QToolBar *bar)
Removes a tool bar from the settings.
Definition: Utils.cpp:372
TEQTAFEXPORT void UpdateToolBarsInTheSettings()
Update the existing tool bars.
Definition: Utils.cpp:341
TEQTAFEXPORT QString UnsavedStar(const QString windowTitle, bool isUnsaved)
Unsaved star.
Definition: Utils.cpp:585
TEQTAFEXPORT void SaveProjectInformationsOnSettings(const QString &defaultAuthor, const int &maxSaved)
Definition: Utils.cpp:465
TEQTAFEXPORT Project * ReadProject(const std::string &uri)
Reads and return a te::qt::af::Project from the file.
Definition: Utils.cpp:62
TEQTAFEXPORT void SaveDataSourcesFile()
Saves data sources file.
Definition: Utils.cpp:283
TEQTAFEXPORT QColor GetDefaultDisplayColorFromSettings()
Definition: Utils.cpp:603
TEQTAFEXPORT void SaveState(QMainWindow *mainWindow)
Definition: Utils.cpp:435
TEQTAFEXPORT void RestoreState(QMainWindow *mainWindow)
Definition: Utils.cpp:445
TEQTAFEXPORT void SaveLastDatasourceOnSettings(const QString &dsType)
Definition: Utils.cpp:475
TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
Definition: Utils.cpp:615
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:234
Configuration flags for the TerraLib Application Framework.
TEQTAFEXPORT void CreateDefaultSettings()
Creates a default QSettings.
Definition: Utils.cpp:509
#define TEQTAFEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:108
TEQTAFEXPORT bool GetOpenLastProjectFromSettings()
Definition: Utils.cpp:496
TEQTAFEXPORT void Save(const Project &project, const std::string &uri)
Saves the informations of the project in the uri file.
Definition: Utils.cpp:172
TEQTAFEXPORT QString GetStyleSheetFromSettings()
Definition: Utils.cpp:626
TEQTAFEXPORT QString GetLastDatasourceFromSettings()
Definition: Utils.cpp:489
TEQTAFEXPORT void UpdateApplicationPlugins()
Update plugins file.
Definition: Utils.cpp:293
TEQTAFEXPORT void SaveOpenLastProjectOnSettings(bool openLast)
Definition: Utils.cpp:482
TEQTAFEXPORT std::vector< QToolBar * > ReadToolBarsFromSettings(QWidget *barsParent=0)
Returns a vector of tool bars registered in the QSettings.
Definition: Utils.cpp:381
TEQTAFEXPORT void GetProjectInformationsFromSettings(QString &defaultAuthor, int &maxSaved)
Definition: Utils.cpp:455
TEQTAFEXPORT void AddActionToCustomToolbars(QAction *act)
Check QSettings for existance of act and adds it if necessary.
Definition: Utils.cpp:651
This class models a XML writer object.
Definition: Writer.h:52