All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 #include <openfluid/dllexport.hpp>
44 
45 #include <map>
46 #include <vector>
47 
48 
49 #include <QSettings>
50 #include <QStringList>
51 
52 
53 namespace openfluid { namespace base {
54 
55 
56 // =====================================================================
57 // =====================================================================
58 
59 
61 {
62 
63  private:
64 
65  static PreferencesManager* mp_Instance;
66 
67  static QString m_FileName;
68 
69  QSettings* mp_ConfFile;
70 
72 
73  void setDefaultValues();
74 
75  void setExtraPaths(const QString& Key, const QStringList& Paths);
76 
77  void addExtraPath(const QString& Key, const QString& Path);
78 
79  void removeExtraPath(const QString& Key, const QString& Path);
80 
81  QStringList getExtraPaths(const QString& Key);
82 
83  static QString guessLang();
84 
85 
86  public:
87 
88  static const int RecentProjectsLimit;
89 
91  {
92  public:
93  QString Name;
94  QString Path;
95  };
96 
98  {
99  QString m_Color;
100  QStringList m_Decoration;
101 
102  SyntaxHighlightingRule_t(const QString& Color,const QStringList& Decoration)
103  : m_Color(Color),m_Decoration(Decoration) {}
104  };
105 
106  typedef std::vector<RecentProject_t> RecentProjectsList_t;
107 
108  typedef QMap<QString,SyntaxHighlightingRule_t> SyntaxHighlightingRules_t;
109 
110  typedef std::map<QString, QString> MarketPlaces_t;
111 
112  static PreferencesManager* instance();
113 
115 
116  /* Used only if we want to set another file name for the conf file
117  * instead of the default one (for tests eg.)
118  * To be set before the first call of instance().
119  */
120  static void setFileName(const QString& AbsoluteFileName);
121 
122  QString getFileName();
123 
124  bool isValidKey(const QString& Group, const QString& Key);
125 
126 
127  void setLang(const QString& Lang);
128 
129  QString getLang();
130 
131  static QStringList getAvailableLangs();
132 
133  static bool isAvailableLang(const QString& Lang);
134 
135  void setRecentMax(int RecentMax);
136 
137  int getRecentMax();
138 
139  bool addRecentProject(const QString& ProjectName, const QString& ProjectPath = "");
140 
141  RecentProjectsList_t getRecentProjects();
142 
143  void clearRecentProjects();
144 
145  void adaptRecentProjects();
146 
147 
148  void setWorkspacesPaths(const QStringList& Paths);
149 
150  QStringList getWorkspacesPaths();
151 
152  QString getWorkspacePath();
153 
154  QString getProjectsPath();
155 
156 
157  void setExtraSimulatorsPaths(const QStringList& Paths);
158 
159  void addExtraSimulatorsPath(const QString& Path);
160 
161  void removeExtraSimulatorsPath(const QString& Path);
162 
163  QStringList getExtraSimulatorsPaths();
164 
165 
166  void setExtraExtensionsPaths(const QStringList& Paths);
167 
168  void addExtraExtensionsPath(const QString& Path);
169 
170  void removeExtraExtensionsPath(const QString& Path);
171 
172  QStringList getExtraExtensionsPaths();
173 
174 
175  void setExtraObserversPaths(const QStringList& Paths);
176 
177  void addExtraObserversPath(const QString& Path);
178 
179  void removeExtraObserversPath(const QString& Path);
180 
181  QStringList getExtraObserversPaths();
182 
183 
184  void setDeltaT(openfluid::core::Duration_t DeltaT);
185 
186  openfluid::core::Duration_t getDeltaT();
187 
188 
189  void setBegin(const QString& Begin);
190 
191  QString getBegin();
192 
193  void setEnd(const QString& End);
194 
195  QString getEnd();
196 
197 
198  bool addMarketplace(const QString& PlaceName, const QString& PlaceUrl);
199 
200  void removeMarketplace(const QString& PlaceName);
201 
202  MarketPlaces_t getMarketplaces();
203 
204 
205  bool isExtensionValueExist(const QString& PluginName, const QString& Key);
206 
207  QString getExtensionValue(const QString& PluginName, const QString& Key);
208 
209  void setExtensionValue(const QString& PluginName, const QString& Key, const QString& Value);
210 
211 
212  Qt::DockWidgetArea getDockPosition();
213 
214  void setDockPosition(Qt::DockWidgetArea Position);
215 
216  Qt::ToolBarArea getToolBarPosition();
217 
218  void setToolBarPosition(Qt::ToolBarArea Position);
219 
220 
221  bool isItemRemovalConfirm();
222 
223  void setItemRemovalConfirm(bool Confirm);
224 
225  bool isParamRemovalConfirm();
226 
227  void setParamRemovalConfirm(bool Confirm);
228 
229  bool isWaresWatchersActive();
230 
231  void setWaresWatchersActive(bool Active);
232 
233  bool isAutomaticSaveBeforeRun();
234 
235  void setAutomaticSaveBeforeRun(bool AutoSave);
236 
237  bool isSpatialUnitsRemovalConfirm();
238 
239  void setSpatialUnitsRemovalConfirm(bool Confirm);
240 
241  bool isSpatialConnsRemovalConfirm();
242 
243  void setSpatialConnsRemovalConfirm(bool Confirm);
244 
245  bool isSpatialAttrsRemovalConfirm();
246 
247  void setSpatialAttrsRemovalConfirm(bool Confirm);
248 
249 
250  bool isAutomaticSaveBeforeBuild();
251 
252  void setAutomaticSaveBeforeBuild(bool AutoSave);
253 
254 
255  void setTextEditorDefaults(bool ForceReset);
256 
257  bool isSyntaxHighlightingEnabled();
258 
259  void setSyntaxHighlightingEnabled(bool Enabled);
260 
261  SyntaxHighlightingRules_t getSyntaxHighlightingRules();
262 
263  void setSyntaxHighlightingRules(const SyntaxHighlightingRules_t& Rules);
264 
265  bool isCurrentlineHighlightingEnabled();
266 
267  void setCurrentlineHighlightingEnabled(bool Enabled);
268 
269  QString getCurrentlineColor();
270 
271  void setCurrentlineColor(const QString& Color);
272 
273  QString getFontName();
274 
275  void setFontName(const QString& FontName);
276 
277  bool isLineWrappingEnabled();
278 
279  void setLineWrappingEnabled(bool Enabled);
280 
281  int getIndentSpaceNb();
282 
283  void setIndentSpaceNb(int SpaceNumber);
284 
285  QString getWaresdevConfigEnv(const QString& Name);
286 
287  void setWaresdevConfigEnv(const QString& Name,const QString& Value);
288 
289  QString getWaresdevConfigOptions();
290 
291  void setWaresdevConfigOptions(const QString& Options);
292 
293  QString getWaresdevConfigGenerator();
294 
295  void setWaresdevConfigGenerator(const QString& Generator);
296 
297  QString getWaresdevBuildEnv(const QString& Name);
298 
299  void setWaresdevBuildEnv(const QString& Name,const QString& Value);
300 
301  bool isWaresdevShowCommandEnv(const QString& Name);
302 
303  void setWaresdevShowCommandEnv(const QString& Name, bool Enabled);
304 
305 
306 };
307 
308 } } //namespaces
309 
310 #endif /* __OPENFLUID_BASE_PREFERENCESMANAGER_HPP__ */
QString m_Color
Definition: PreferencesManager.hpp:99
Definition: PreferencesManager.hpp:60
unsigned long long Duration_t
Definition: DateTime.hpp:68
std::map< QString, QString > MarketPlaces_t
Definition: PreferencesManager.hpp:110
SyntaxHighlightingRule_t(const QString &Color, const QStringList &Decoration)
Definition: PreferencesManager.hpp:102
Definition: PreferencesManager.hpp:90
QMap< QString, SyntaxHighlightingRule_t > SyntaxHighlightingRules_t
Definition: PreferencesManager.hpp:108
static const int RecentProjectsLimit
Definition: PreferencesManager.hpp:88
QStringList m_Decoration
Definition: PreferencesManager.hpp:100
QString Name
Definition: PreferencesManager.hpp:93
QString Path
Definition: PreferencesManager.hpp:94
std::vector< RecentProject_t > RecentProjectsList_t
Definition: PreferencesManager.hpp:106
#define OPENFLUID_API
Definition: dllexport.hpp:87