PreferencesManager.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 /**
33  @file PreferencesManager.hpp
34 
35  @author Jean-Christophe Fabre <jean-christophe.fabre@supagro.inra.fr>
36  @author Aline LIBRES <libres@supagro.inra.fr>
37  */
38 
39 #ifndef __OPENFLUID_BASE_PREFERENCESMANAGER_HPP__
40 #define __OPENFLUID_BASE_PREFERENCESMANAGER_HPP__
41 
42 
43 #include <map>
44 #include <vector>
45 
46 #include <QSettings>
47 #include <QStringList>
48 
49 #include <openfluid/dllexport.hpp>
52 
53 
54 namespace openfluid { namespace base {
55 
56 
57 // =====================================================================
58 // =====================================================================
59 
60 
62 {
63 
65 
66  private:
67 
68  static QString m_FileName;
69 
70  QSettings* mp_ConfFile;
71 
73 
75 
76  void setDefaultValues();
77 
78  void setBuilderExtraPaths(const QString& Key, const QStringList& Paths);
79 
80  void addBuilderExtraPath(const QString& Key, const QString& Path);
81 
82  void removeBuilderExtraPath(const QString& Key, const QString& Path);
83 
84  QStringList getBuilderExtraPaths(const QString& Key);
85 
86  static QString guessLang();
87 
88 
89  public:
90 
91  static const int RecentProjectsLimit;
92 
94  {
95  public:
96  QString Name;
97  QString Path;
98  };
99 
101  {
102  QString m_Color;
103  QStringList m_Decoration;
104 
105  SyntaxHighlightingRule_t(const QString& Color,const QStringList& Decoration)
106  : m_Color(Color),m_Decoration(Decoration) {}
107  };
108 
109  typedef std::vector<RecentProject_t> RecentProjectsList_t;
110 
111  typedef QMap<QString, SyntaxHighlightingRule_t> SyntaxHighlightingRules_t;
112 
113  typedef std::map<QString, QString> MarketPlaces_t;
114 
115  /* Used only if we want to set another file name for the conf file
116  * instead of the default one (for tests eg.)
117  * To be set before the first call of instance().
118  */
119  static void setFileName(const QString& AbsoluteFileName);
120 
121  QString getFileName();
122 
123  bool isValidKey(const QString& Group, const QString& Key);
124 
125 
126  void setLang(const QString& Lang);
127 
128  QString getLang();
129 
130  static QStringList getAvailableLangs();
131 
132  static bool isAvailableLang(const QString& Lang);
133 
134  void setBuilderRecentMax(int RecentMax);
135 
136  int getBuilderRecentMax();
137 
138  bool addBuilderRecentProject(const QString& ProjectName, const QString& ProjectPath = "");
139 
140  RecentProjectsList_t getBuilderRecentProjects();
141 
142  void clearBuilderRecentProjects();
143 
144  void adaptBuilderRecentProjects();
145 
146 
147  void setBuilderWorkspacesPaths(const QStringList& Paths);
148 
149  QStringList getBuilderWorkspacesPaths();
150 
151  QString getBuilderWorkspacePath();
152 
153  QString getBuilderProjectsPath();
154 
155 
156  void setBuilderExtraSimulatorsPaths(const QStringList& Paths);
157 
158  void addBuilderExtraSimulatorsPath(const QString& Path);
159 
160  void removeBuilderExtraSimulatorsPath(const QString& Path);
161 
162  QStringList getBuilderExtraSimulatorsPaths();
163 
164 
165  void setBuilderExtraExtensionsPaths(const QStringList& Paths);
166 
167  void addBuilderExtraExtensionsPath(const QString& Path);
168 
169  void removeBuilderExtraExtensionsPath(const QString& Path);
170 
171  QStringList getBuilderExtraExtensionsPaths();
172 
173 
174  void setBuilderExtraObserversPaths(const QStringList& Paths);
175 
176  void addBuilderExtraObserversPath(const QString& Path);
177 
178  void removeBuilderExtraObserversPath(const QString& Path);
179 
180  QStringList getBuilderExtraObserversPaths();
181 
182 
183  void setBuilderDeltaT(openfluid::core::Duration_t DeltaT);
184 
185  openfluid::core::Duration_t getBuilderDeltaT();
186 
187 
188  void setBuilderBegin(const QString& Begin);
189 
190  QString getBuilderBegin();
191 
192  void setBuilderEnd(const QString& End);
193 
194  QString getBuilderEnd();
195 
196 
197  bool addMarketplace(const QString& PlaceName, const QString& PlaceUrl);
198 
199  void removeMarketplace(const QString& PlaceName);
200 
201  MarketPlaces_t getMarketplaces();
202 
203 
204  bool isBuilderExtensionValueExist(const QString& PluginName, const QString& Key);
205 
206  QString getBuilderExtensionValue(const QString& PluginName, const QString& Key);
207 
208  void setBuilderExtensionValue(const QString& PluginName, const QString& Key, const QString& Value);
209 
210 
211  Qt::DockWidgetArea getBuilderDockPosition();
212 
213  void setBuilderDockPosition(Qt::DockWidgetArea Position);
214 
215  Qt::ToolBarArea getBuilderToolBarPosition();
216 
217  void setBuilderToolBarPosition(Qt::ToolBarArea Position);
218 
219 
220  bool isBuilderItemRemovalConfirm();
221 
222  void setBuilderItemRemovalConfirm(bool Confirm);
223 
224  bool isBuilderParamRemovalConfirm();
225 
226  void setBuilderParamRemovalConfirm(bool Confirm);
227 
228  bool isBuilderWaresWatchersActive();
229 
230  void setBuilderWaresWatchersActive(bool Active);
231 
232  bool isBuilderAutomaticSaveBeforeRun();
233 
234  void setBuilderAutomaticSaveBeforeRun(bool AutoSave);
235 
236  bool isBuilderSpatialUnitsRemovalConfirm();
237 
238  void setBuilderSpatialUnitsRemovalConfirm(bool Confirm);
239 
240  bool isBuilderSpatialConnsRemovalConfirm();
241 
242  void setBuilderSpatialConnsRemovalConfirm(bool Confirm);
243 
244  bool isBuilderSpatialAttrsRemovalConfirm();
245 
246  void setBuilderSpatialAttrsRemovalConfirm(bool Confirm);
247 
248 
249  bool isWaresdevAutomaticSaveBeforeBuild();
250 
251  void setWaresdevAutomaticSaveBeforeBuild(bool AutoSave);
252 
253 
254  void setWaresdevTextEditorDefaults(bool ForceReset);
255 
256  bool isWaresdevSyntaxHighlightingEnabled();
257 
258  void setWaresdevSyntaxHighlightingEnabled(bool Enabled);
259 
260  SyntaxHighlightingRules_t getWaresdevSyntaxHighlightingRules();
261 
262  void setWaresdevSyntaxHighlightingRules(const SyntaxHighlightingRules_t& Rules);
263 
264  bool isWaresdevCurrentlineHighlightingEnabled();
265 
266  void setWaresdevCurrentlineHighlightingEnabled(bool Enabled);
267 
268  QString getWaresdevCurrentlineColor();
269 
270  void setWaresdevCurrentlineColor(const QString& Color);
271 
272  QString getWaresdevFontName();
273 
274  void setWaresdevFontName(const QString& FontName);
275 
276  bool isWaresdevLineWrappingEnabled();
277 
278  void setWaresdevLineWrappingEnabled(bool Enabled);
279 
280  int getWaresdevIndentSpaceNb();
281 
282  void setWaresdevIndentSpaceNb(int SpaceNumber);
283 
284  QString getWaresdevConfigEnv(const QString& Name);
285 
286  void setWaresdevConfigEnv(const QString& Name, const QString& Value);
287 
288  QString getWaresdevConfigOptions();
289 
290  void setWaresdevConfigOptions(const QString& Options);
291 
292  QString getWaresdevConfigGenerator();
293 
294  void setWaresdevConfigGenerator(const QString& Generator);
295 
296  QString getWaresdevBuildEnv(const QString& Name);
297 
298  void setWaresdevBuildEnv(const QString& Name, const QString& Value);
299 
300  bool isWaresdevShowCommandEnv(const QString& Name);
301 
302  void setWaresdevShowCommandEnv(const QString& Name, bool Enabled);
303 
304  bool isWaresdevGitSslNoVerify();
305 
306  void setWaresdevGitSslNoVerify(bool NoVerify);
307 
308  QString getWaresdevImportWaresHubLastUrl();
309 
310  void setWaresdevImportWaresHubLastUrl(const QString& Url);
311 
312  QString getWaresdevImportWaresHubLastUsername();
313 
314  void setWaresdevImportWaresHubLastUsername(const QString& Username);
315 };
316 
317 } } //namespaces
318 
319 #endif /* __OPENFLUID_BASE_PREFERENCESMANAGER_HPP__ */
SyntaxHighlightingRule_t(const QString &Color, const QStringList &Decoration)
Definition: PreferencesManager.hpp:105
unsigned long long Duration_t
Definition: DateTime.hpp:68
QString Name
Definition: PreferencesManager.hpp:96
Definition: PreferencesManager.hpp:93
QStringList m_Decoration
Definition: PreferencesManager.hpp:103
QString Path
Definition: PreferencesManager.hpp:97
#define OPENFLUID_SINGLETON_DEFINITION(T)
Definition: SingletonMacros.hpp:78
Definition: ApplicationException.hpp:47
Definition: PreferencesManager.hpp:61
QMap< QString, SyntaxHighlightingRule_t > SyntaxHighlightingRules_t
Definition: PreferencesManager.hpp:111
QString m_Color
Definition: PreferencesManager.hpp:102
std::vector< RecentProject_t > RecentProjectsList_t
Definition: PreferencesManager.hpp:109
static const int RecentProjectsLimit
Definition: PreferencesManager.hpp:91
#define OPENFLUID_API
Definition: dllexport.hpp:87
std::map< QString, QString > MarketPlaces_t
Definition: PreferencesManager.hpp:113