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  \brief Header of ...
35 
36  \author Jean-Christophe Fabre <fabrejc@supagro.inra.fr>
37  \author Aline LIBRES <libres@supagro.inra.fr>
38  */
39 
40 #ifndef __PREFERENCESMANAGER_HPP__
41 #define __PREFERENCESMANAGER_HPP__
42 
43 #include <openfluid/dllexport.hpp>
45 
46 #include <map>
47 #include <vector>
48 
49 
50 #include <QSettings>
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 
97  typedef std::vector<RecentProject_t> RecentProjectsList_t;
98 
99  typedef std::map<QString, QString> MarketPlaces_t;
100 
101  static PreferencesManager* getInstance();
102 
104 
105  /* Used only if we want to set another file name for the conf file
106  * instead of the default one (for tests eg.)
107  * To be set before the first call of getInstance().
108  */
109  static void setFileName(const QString& AbsoluteFileName);
110 
111  QString getFileName();
112 
113  bool isValidKey(const QString& Group, const QString& Key);
114 
115 
116  void setLang(const QString& Lang);
117 
118  QString getLang();
119 
120  static QStringList getAvailableLangs();
121 
122  static bool isAvailableLang(const QString& Lang);
123 
124  void setRecentMax(int RecentMax);
125 
126  int getRecentMax();
127 
128  bool addRecentProject(const QString& ProjectName, const QString& ProjectPath = "");
129 
130  RecentProjectsList_t getRecentProjects();
131 
132  void clearRecentProjects();
133 
134  void adaptRecentProjects();
135 
136 
137  void setWorkspacesPaths(const QStringList& Paths);
138 
139  QStringList getWorkspacesPaths();
140 
141  QString getWorkspacePath();
142 
143  QString getProjectsPath();
144 
145 
146  void setExtraSimulatorsPaths(const QStringList& Paths);
147 
148  void addExtraSimulatorsPath(const QString& Path);
149 
150  void removeExtraSimulatorsPath(const QString& Path);
151 
152  QStringList getExtraSimulatorsPaths();
153 
154 
155  void setExtraExtensionsPaths(const QStringList& Paths);
156 
157  void addExtraExtensionsPath(const QString& Path);
158 
159  void removeExtraExtensionsPath(const QString& Path);
160 
161  QStringList getExtraExtensionsPaths();
162 
163 
164  void setExtraObserversPaths(const QStringList& Paths);
165 
166  void addExtraObserversPath(const QString& Path);
167 
168  void removeExtraObserversPath(const QString& Path);
169 
170  QStringList getExtraObserversPaths();
171 
172 
173  void setDeltaT(openfluid::core::Duration_t DeltaT);
174 
175  openfluid::core::Duration_t getDeltaT();
176 
177 
178  void setBegin(const QString& Begin);
179 
180  QString getBegin();
181 
182  void setEnd(const QString& End);
183 
184  QString getEnd();
185 
186 
187  bool addMarketplace(const QString& PlaceName, const QString& PlaceUrl);
188 
189  void removeMarketplace(const QString& PlaceName);
190 
191  MarketPlaces_t getMarketplaces();
192 
193 
194  bool isExtensionValueExist(const QString& PluginName, const QString& Key);
195 
196  QString getExtensionValue(const QString& PluginName, const QString& Key);
197 
198  void setExtensionValue(const QString& PluginName, const QString& Key, const QString& Value);
199 
200 
201  Qt::DockWidgetArea getDockPosition();
202 
203  void setDockPosition(Qt::DockWidgetArea Position);
204 
205  Qt::ToolBarArea getToolBarPosition();
206 
207  void setToolBarPosition(Qt::ToolBarArea Position);
208 
209 
210  bool isItemRemovalConfirm();
211 
212  void setItemRemovalConfirm(bool Confirm);
213 
214  bool isParamRemovalConfirm();
215 
216  void setParamRemovalConfirm(bool Confirm);
217 
218  bool isWaresWatchersActive();
219 
220  void setWaresWatchersActive(bool Active);
221 
222  bool isAutomaticSaveBeforeRun();
223 
224  void setAutomaticSaveBeforeRun(bool AutoSave);
225 
226  bool isSpatialUnitsRemovalConfirm();
227 
228  void setSpatialUnitsRemovalConfirm(bool Confirm);
229 
230  bool isSpatialConnsRemovalConfirm();
231 
232  void setSpatialConnsRemovalConfirm(bool Confirm);
233 
234  bool isSpatialAttrsRemovalConfirm();
235 
236  void setSpatialAttrsRemovalConfirm(bool Confirm);
237 
238 };
239 
240 } } //namespaces
241 
242 #endif /* __PREFERENCESMANAGER_HPP__ */
QString Name
Definition: PreferencesManager.hpp:93
Definition: PreferencesManager.hpp:90
static const int RecentProjectsLimit
Definition: PreferencesManager.hpp:88
std::vector< RecentProject_t > RecentProjectsList_t
Definition: PreferencesManager.hpp:97
std::map< QString, QString > MarketPlaces_t
Definition: PreferencesManager.hpp:99
QString Path
Definition: PreferencesManager.hpp:94
Definition: PreferencesManager.hpp:60
unsigned long long Duration_t
Definition: DateTime.hpp:68
#define DLLEXPORT
Definition: dllexport.hpp:51