Code_TYMPAN  4.4.0
Industrial site acoustic simulation
OPreferenceManager.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 /*
17  *
18  */
19 
20 #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
21 
22 #include "OPreferenceManager.h"
23 #include "DOMSave.h"
24 #include "Tympan/core/macros.h"
25 
26 #include <clocale>
27 #include <qfile.h>
28 #include <iostream>
29 #include <qtextstream.h>
30 
31 // using namespace ::std;
32 
34 static const int _strBufferSize = 64;
35 
37 // OPreferenceManager
38 
40 {
42  setXMLRootNodeName("Preferences");
43  setXMLParamNodeName("Preference");
44  setCurrentDirectory("Main");
45 }
46 
47 OPreferenceManager::OPreferenceManager(const QString& currentDirectory)
48 {
50  setXMLRootNodeName("Preferences");
51  setXMLParamNodeName("Preference");
52  setCurrentDirectory(currentDirectory);
53 }
54 
55 OPreferenceManager::OPreferenceManager(const QString& rootNodeName, const QString& paramNodeName)
56 {
58  setXMLRootNodeName(rootNodeName);
59  setXMLParamNodeName(paramNodeName);
60  setCurrentDirectory("Main");
61 }
62 
63 OPreferenceManager::OPreferenceManager(const QString& rootNodeName, const QString& paramNodeName,
64  const QString& currentDirectory)
65 {
67  setXMLRootNodeName(rootNodeName);
68  setXMLParamNodeName(paramNodeName);
69  setCurrentDirectory(currentDirectory);
70 }
71 
73 {
74  reset();
75 }
76 
78 {
79  std::vector<QString> nodenames;
80 
81  for (const auto& key : (_prefDirs._dirMap[_curDir])._prefMap)
82  {
83  nodenames.push_back(key.first);
84  }
85  return nodenames;
86 }
87 
89 {
91 
92  OPreferenceManager defaultSettings;
93  defaultSettings.readXML(filePath);
94  defaultSettings.setCurrentDirectory("UserPreferences");
95  std::vector<QString> nodenames = defaultSettings.getPreferenceNames();
96  setCurrentDirectory("UserPreferences");
97 
98  for (int i = 0; i < nodenames.size(); i++)
99  {
100  if (!exists(nodenames[i]))
101  {
102  (_prefDirs._dirMap[_curDir])._prefMap[nodenames[i]] = defaultSettings.getString(nodenames[i]);
103  }
104  }
105 }
106 
107 void OPreferenceManager::loadDefault(const char* defaultParams[][2], int nbParams)
108 {
110  // Charge le map avec les valeurs par defaut.
111  for (int i = 0; i < nbParams; i++)
112  {
113  (_prefDirs._dirMap[_curDir])._prefMap[defaultParams[i][0]] = defaultParams[i][1];
114  }
115 }
116 
118 {
119  _curDir = dir;
120 }
121 
123 {
125  // On vide le tableau, les QStrings sont effaces proprement...
126  _prefDirs._dirMap.clear();
127 }
128 
129 bool OPreferenceManager::readXML(QString fileName)
130 {
132  // int retval = 0;
133 
134  QDomDocument doc;
135  QFile file(fileName);
136  if (!file.open(QIODevice::ReadOnly))
137  {
138  std::cerr << "\nError when open '" << fileName.toLatin1().data() << "'\n";
139  return false;
140  }
141  QString errorMsg;
142  int errorLine = 0;
143  int errorColumn = 0;
144  if (!doc.setContent(&file, &errorMsg, &errorLine, &errorColumn))
145  {
146  std::cerr << "\nError during parsing: '" << fileName.toLatin1().data() << "'\n"
147  << "error message is: \n"
148  << errorMsg.toLatin1().constData() << "\n"
149  << "in line:" << errorLine << " in column:" << errorColumn << std::endl;
150  file.close();
151  return false;
152  }
153  file.close();
154  // On recupere le noeud Document
155  QDomDocument domDocument = doc;
156 
157  // On recupere l'element XML root du document
158  QDomElement rootElement = domDocument.documentElement();
159 
160  // Recense tous les elements enfants du root
161  QDomNodeList nodeList = rootElement.childNodes();
162 
163  QString str;
164 
165  int nodecount = nodeList.length();
166 
167  // Pour chaque noeud enfant du noeud root
168  for (int i = 0; i < nodecount; i++)
169  {
170  QDomNode curElem = nodeList.item(i);
171 
172  if (curElem.isElement())
173  {
174  // Le nom de la categorie
175  QString dir = curElem.nodeName();
176  // Recense tous les elements enfants du courant
177  QDomNodeList nodeList2 = curElem.childNodes();
178 
179  int nodecount2 = nodeList2.length();
180 
181  for (int j = 0; j < nodecount2; j++)
182  {
183  QDomElement curElem2 = nodeList2.item(j).toElement();
184  // Si c'est un noeud 'Preference'
185  if (!curElem2.isNull() && (_xmlParamNodeName == curElem2.nodeName()))
186  {
187  // On recupere les champs 'name' et 'value' du noeud
188  QString name = curElem2.attribute("key");
189  QString value = curElem2.attribute("value");
190  if (value.isEmpty())
191  {
192  value = "0";
193  }
194 
195  // Ajout de l'entree au tableau associatif
196  _prefDirs._dirMap[dir]._prefMap[name] = value;
197  }
198  }
199  }
200  }
201 
202  return true;
203 }
204 
205 bool OPreferenceManager::writeXML(QString fileName)
206 {
207  bool res = false;
208 
209  QDomImplementation domImpl;
210  // Declaration du type de document (DTD)
211  QString qualifiedName = _xmlRootNodeName; // Nom du noeud root
212  QString systemId = ""; //"Tympan.dtd "; // URI de la DTD
213 
214  QDomDocumentType docType = domImpl.createDocumentType(qualifiedName, QString(), systemId);
215  // Creation d'un Document XML vide (Precision: document != fichier)
216  QDomDocument domDocument = domImpl.createDocument(QString(), // root element namespace URI.
217  _xmlRootNodeName, // root element name
218  docType); // document type object (DTD).
219  // Recuperation du noeud root du document
220  QDomElement rootElement = domDocument.documentElement();
221  // Iteration du tableau associatif des preferences
222  ODirMap::ODirMapIt iter;
223  for (iter = _prefDirs._dirMap.begin(); iter != _prefDirs._dirMap.end(); iter++)
224  {
225  // La categorie correspondante
226  QString dir = (*iter).first;
227 
228  // Creation d'un nouveau noeud
229  QDomElement dirElem = domDocument.createElement(dir);
230  // Ajout du noeud au noeud root
231  rootElement.appendChild(dirElem);
232  // Iteration du tableau associatif des preferences
233  OPrefMap::OPrefMapIt iter2;
234  for (iter2 = _prefDirs._dirMap[dir]._prefMap.begin(); iter2 != _prefDirs._dirMap[dir]._prefMap.end();
235  iter2++)
236  {
237  // Creation d'un nouveau noeud
238  QDomElement prefElem = domDocument.createElement(_xmlParamNodeName);
239  // Ajout du noeud au noeud root
240  dirElem.appendChild(prefElem);
241 
242  // Ajout des attributs au nouveau noeud
243  prefElem.setAttribute("key", ((*iter2).first));
244  prefElem.setAttribute("value", ((*iter2).second));
245  }
246  }
247 
248  QFile file(fileName);
249  if (!file.open(QIODevice::WriteOnly))
250  {
251  return res;
252  }
253 
254  QTextStream ts(&file);
255  ts.setEncoding(QStringConverter::Utf8);
256  ts << domDocument.toString();
257 
258  file.close();
259 
260  res = true;
261  return res;
262 }
263 
264 bool OPreferenceManager::exists(const QString& pref)
265 {
266  return exists(_curDir, pref);
267 }
268 
269 bool OPreferenceManager::exists(const QString& dir, const QString& pref)
270 {
272  ite = _prefDirs._dirMap[dir]._prefMap.find(pref);
273  return (ite != _prefDirs._dirMap[dir]._prefMap.end());
274 }
275 
276 QString OPreferenceManager::getDirectory(const QString& pref)
277 {
278  ODirMap::ODirMapIt ite;
279  QString dir;
280 
281  // On parcours la totalite du tableau associatif
282  for (ite = _prefDirs._dirMap.begin(); ite != _prefDirs._dirMap.end(); ite++)
283  {
284  // La categorie courante
285  dir = (*ite).first;
286 
287  if (exists(dir, pref))
288  {
289  // On retourne le nom de la categorie
290  return dir;
291  }
292  }
293 
294  return dir;
295 }
296 
297 void OPreferenceManager::setString(const QString& pref, const QString& value)
298 {
299  setString(_curDir, pref, value);
300 }
301 
302 void OPreferenceManager::setString(const QString& dir, const QString& pref, const QString& value)
303 {
305  // ODirMap::iterator it;
306  _prefDirs._dirMap[dir]._prefMap.erase(pref);
307  // preference[pref] = value;
308 
309  // QString test = preference[pref];
310  // preference->insert(make_pair(pref, value));
311  // pair<QString, QString> couple = make_pair(pref, value);
312  // it = _prefDirs.find(dir);
313  // *it.insert(couple);
314  _prefDirs._dirMap[dir]._prefMap[pref] = value;
315 }
316 
317 QString OPreferenceManager::getString(const QString& pref)
318 {
319  return getString(_curDir, pref);
320 }
321 
322 QString OPreferenceManager::getString(const QString& dir, const QString& pref)
323 {
324  return _prefDirs._dirMap[dir]._prefMap[pref];
325 }
326 
327 void OPreferenceManager::setStringArray(const QString& pref, const QString* valueArray, const int& sizeArray)
328 {
329  setStringArray(_curDir, pref, valueArray, sizeArray);
330 }
331 
332 void OPreferenceManager::setStringArray(const QString& dir, const QString& pref, const QString* valueArray,
333  const int& sizeArray)
334 {
335  if (sizeArray <= 0)
336  {
337  return;
338  }
339 
340  for (int i = 0; i < sizeArray; i++)
341  {
342  setString(dir, pref + intToString(i), valueArray[i]);
343  }
344 }
345 
346 QString* OPreferenceManager::getStringArray(const QString& pref, int& sizeArray)
347 {
348  return getStringArray(_curDir, pref, sizeArray);
349 }
350 
351 QString* OPreferenceManager::getStringArray(const QString& dir, const QString& pref, int& sizeArray)
352 {
353  sizeArray = 0;
354 
355  // Recherche de la taille du tableau
356  while (exists(dir, pref + intToString(sizeArray)))
357  {
358  ++sizeArray;
359  }
360 
361  if (sizeArray <= 0)
362  {
363  return NULL;
364  }
365 
366  // Tableau de QString a retourner
367  QString* strs = new QString[sizeArray];
368 
369  for (int i = 0; i < sizeArray; i++)
370  {
371  strs[i] = getString(dir, pref + intToString(i));
372  }
373 
374  return strs;
375 }
376 
377 #if TY_ARCH_TYPE == TY_ARCHITECTURE_64
378 void OPreferenceManager::setUInt(const QString& pref, const unsigned int& value)
379 {
380  setUInt(_curDir, pref, value);
381 }
382 
383 void OPreferenceManager::setUInt(const QString& dir, const QString& pref, const unsigned int& value)
384 {
386  _prefDirs._dirMap[dir]._prefMap[pref] = uintToString(value);
387 }
388 
389 void OPreferenceManager::setUInt(const QString& pref, const size_t& value)
390 {
391  setUInt(_curDir, pref, value);
392 }
393 
394 void OPreferenceManager::setUInt(const QString& dir, const QString& pref, const size_t& value)
395 {
397  _prefDirs._dirMap[dir]._prefMap[pref] = uintToString(value);
398 }
399 
400  #if TY_COMPILER == TY_COMPILER_MSVC
401 void OPreferenceManager::setUInt(const QString& pref, const unsigned long& value)
402 {
403  setUInt(_curDir, pref, value);
404 }
405 
406 void OPreferenceManager::setUInt(const QString& dir, const QString& pref, const unsigned long& value)
407 {
409  _prefDirs._dirMap[dir]._prefMap[pref] = uintToString(value);
410 }
411  #endif
412 #else
413 void OPreferenceManager::setUInt(const QString& pref, const size_t& value)
414 {
415  setUInt(_curDir, pref, value);
416 }
417 
418 void OPreferenceManager::setUInt(const QString& dir, const QString& pref, const size_t& value)
419 {
421  _prefDirs._dirMap[dir]._prefMap[pref] = uintToString(value);
422 }
423 
424 void OPreferenceManager::setUInt(const QString& pref, const unsigned long& value)
425 {
426  setUInt(_curDir, pref, value);
427 }
428 
429 void OPreferenceManager::setUInt(const QString& dir, const QString& pref, const unsigned long& value)
430 {
432  _prefDirs._dirMap[dir]._prefMap[pref] = uintToString(value);
433 }
434 #endif
435 
436 void OPreferenceManager::setInt(const QString& pref, const int& value)
437 {
438  setInt(_curDir, pref, value);
439 }
440 
441 void OPreferenceManager::setInt(const QString& dir, const QString& pref, const int& value)
442 {
444  _prefDirs._dirMap[dir]._prefMap[pref] = intToString(value);
445 }
446 
447 int OPreferenceManager::getInt(const QString& pref)
448 {
449  return getInt(_curDir, pref);
450 }
451 
452 int OPreferenceManager::getInt(const QString& dir, const QString& pref)
453 {
454  QString str = _prefDirs._dirMap[dir]._prefMap[pref];
455  int res = str.toFloat();
456  return res;
457 }
458 
459 void OPreferenceManager::setBool(const QString& pref, const bool& value)
460 {
461  setBool(_curDir, pref, value);
462 }
463 
464 void OPreferenceManager::setBool(const QString& dir, const QString& pref, const bool& value)
465 {
467  _prefDirs._dirMap[dir]._prefMap[pref] = value ? "true" : "false";
468 }
469 
470 bool OPreferenceManager::getBool(const QString& pref)
471 {
472  return getBool(_curDir, pref);
473 }
474 
475 bool OPreferenceManager::getBool(const QString& dir, const QString& pref)
476 {
477  if (!exists(dir, pref)) // az++
478  {
479  return false;
480  }
481  QString sValue = _prefDirs._dirMap[dir]._prefMap[pref]; // az++
482  if (sValue.isEmpty())
483  {
484  return false;
485  }
486  return (_prefDirs._dirMap[dir]._prefMap[pref] == "true") ? true : false;
487 }
488 
489 void OPreferenceManager::setFloat(const QString& pref, const float& value)
490 {
491  setFloat(_curDir, pref, value);
492 }
493 
494 void OPreferenceManager::setFloat(const QString& dir, const QString& pref, const float& value)
495 {
497  _prefDirs._dirMap[dir]._prefMap[pref] = floatToString(value);
498 }
499 
500 float OPreferenceManager::getFloat(const QString& pref)
501 {
502  return getFloat(_curDir, pref);
503 }
504 
505 float OPreferenceManager::getFloat(const QString& dir, const QString& pref)
506 {
507  return _prefDirs._dirMap[dir]._prefMap[pref].toFloat();
508 }
509 
510 void OPreferenceManager::setDouble(const QString& pref, const double& value)
511 {
512  setDouble(_curDir, pref, value);
513 }
514 
515 void OPreferenceManager::setDouble(const QString& dir, const QString& pref, const double& value)
516 {
518  _prefDirs._dirMap[dir]._prefMap[pref] = doubleToString(value);
519 }
520 
521 double OPreferenceManager::getDouble(const QString& pref)
522 {
523  return getDouble(_curDir, pref);
524 }
525 
526 double OPreferenceManager::getDouble(const QString& dir, const QString& pref)
527 {
528  return _prefDirs._dirMap[dir]._prefMap[pref].toDouble();
529 }
530 
531 void OPreferenceManager::setFrame(const QString& pref, const int& posX, const int& posY, const int& sizeX,
532  const int& sizeY)
533 {
534  setFrame(_curDir, pref, posX, posY, sizeX, sizeY);
535 }
536 
537 void OPreferenceManager::setFrame(const QString& dir, const QString& pref, const int& posX, const int& posY,
538  const int& sizeX, const int& sizeY)
539 {
541  _prefDirs._dirMap[dir]._prefMap[pref + "PosX"] = intToString(posX);
542  _prefDirs._dirMap[dir]._prefMap[pref + "PosY"] = intToString(posY);
543  _prefDirs._dirMap[dir]._prefMap[pref + "SizeX"] = intToString(sizeX);
544  _prefDirs._dirMap[dir]._prefMap[pref + "SizeY"] = intToString(sizeY);
545 }
546 
547 void OPreferenceManager::getFrame(const QString& pref, int& posX, int& posY, int& sizeX, int& sizeY)
548 {
549  getFrame(_curDir, pref, posX, posY, sizeX, sizeY);
550 }
551 
552 void OPreferenceManager::getFrame(const QString& dir, const QString& pref, int& posX, int& posY, int& sizeX,
553  int& sizeY)
554 {
555  if (_prefDirs._dirMap[dir]._prefMap[pref + "PosX"].isEmpty())
556  {
557  posX = 0;
558  }
559  else
560  {
561  posX = _prefDirs._dirMap[dir]._prefMap[pref + "PosX"].toInt();
562  }
563 
564  if (_prefDirs._dirMap[dir]._prefMap[pref + "PosY"].isEmpty())
565  {
566  posY = 0;
567  }
568  else
569  {
570  posY = _prefDirs._dirMap[dir]._prefMap[pref + "PosY"].toInt();
571  }
572 
573  if (_prefDirs._dirMap[dir]._prefMap[pref + "SizeX"].isEmpty())
574  {
575  sizeX = 400;
576  }
577  else
578  {
579  sizeX = _prefDirs._dirMap[dir]._prefMap[pref + "SizeX"].toInt();
580  }
581 
582  if (_prefDirs._dirMap[dir]._prefMap[pref + "SizeY"].isEmpty())
583  {
584  sizeY = 400;
585  }
586  else
587  {
588  sizeY = _prefDirs._dirMap[dir]._prefMap[pref + "SizeY"].toInt();
589  }
590 }
591 
592 void OPreferenceManager::setPoint(const QString& pref, const int& x, const int& y)
593 {
594  setPoint(_curDir, pref, x, y);
595 }
596 
597 void OPreferenceManager::setPoint(const QString& dir, const QString& pref, const int& x, const int& y)
598 {
600  _prefDirs._dirMap[dir]._prefMap[pref + "X"] = intToString(x);
601  _prefDirs._dirMap[dir]._prefMap[pref + "Y"] = intToString(y);
602 }
603 
604 void OPreferenceManager::getPoint(const QString& pref, int& x, int& y)
605 {
606  getPoint(_curDir, pref, x, y);
607 }
608 
609 void OPreferenceManager::getPoint(const QString& dir, const QString& pref, int& x, int& y)
610 {
611  x = _prefDirs._dirMap[dir]._prefMap[pref + "X"].toInt();
612  y = _prefDirs._dirMap[dir]._prefMap[pref + "Y"].toInt();
613 }
614 
615 void OPreferenceManager::setColor(const QString& pref, const float& r, const float& g, const float& b)
616 {
617  setColor(_curDir, pref, r, g, b);
618 }
619 
620 void OPreferenceManager::setColor(const QString& dir, const QString& pref, const float& r, const float& g,
621  const float& b)
622 {
624  _prefDirs._dirMap[dir]._prefMap[pref + "R"] = floatToString(r);
625  _prefDirs._dirMap[dir]._prefMap[pref + "G"] = floatToString(g);
626  _prefDirs._dirMap[dir]._prefMap[pref + "B"] = floatToString(b);
627 }
628 
629 void OPreferenceManager::getColor(const QString& pref, float& r, float& g, float& b)
630 {
631  getColor(_curDir, pref, r, g, b);
632 }
633 
634 void OPreferenceManager::getColor(const QString& dir, const QString& pref, float& r, float& g, float& b)
635 {
636  r = _prefDirs._dirMap[dir]._prefMap[pref + "R"].toFloat();
637  g = _prefDirs._dirMap[dir]._prefMap[pref + "G"].toFloat();
638  b = _prefDirs._dirMap[dir]._prefMap[pref + "B"].toFloat();
639 }
640 
642 // Methodes statiques utilitaires.
644 
645 #if TY_ARCH_TYPE == TY_ARCHITECTURE_64
646 QString OPreferenceManager::uintToString(const unsigned int& val)
647 {
648  char buffer[_strBufferSize];
649  sprintf(buffer, "%d", val);
650  QString str(buffer);
651  return str;
652 }
653 
654 QString OPreferenceManager::uintToString(const size_t& val)
655 {
656  char buffer[_strBufferSize];
657  sprintf(buffer, "%zd", val);
658  QString str(buffer);
659  return str;
660 }
661  #if TY_COMPILER == TY_COMPILER_MSVC
662 QString OPreferenceManager::uintToString(const unsigned long& val)
663 {
664  char buffer[_strBufferSize];
665  sprintf(buffer, "%lu", val);
666  QString str(buffer);
667  return str;
668 }
669  #endif
670 #else
671 QString OPreferenceManager::uintToString(const size_t& val)
672 {
673  char buffer[_strBufferSize];
674  sprintf(buffer, "%d", val);
675  QString str(buffer);
676  return str;
677 }
678 
679 QString OPreferenceManager::uintToString(const unsigned long& val)
680 {
681  char buffer[_strBufferSize];
682  sprintf(buffer, "%lu", val);
683  QString str(buffer);
684  return str;
685 }
686 #endif
687 
688 QString OPreferenceManager::intToString(const int& val)
689 {
690  char buffer[_strBufferSize];
691  sprintf(buffer, "%d", val);
692  QString str(buffer);
693  return str;
694 }
695 
696 QString OPreferenceManager::floatToString(const float& val)
697 {
698  char buffer[_strBufferSize];
699  char* saved_locale = std::setlocale(LC_NUMERIC, "en_US.UTF-8");
700  sprintf(buffer, "%f", val);
701  std::setlocale(LC_NUMERIC, saved_locale);
702  QString str(buffer);
703  return str;
704 }
705 
706 QString OPreferenceManager::doubleToString(const double& val)
707 {
708  char buffer[_strBufferSize];
709  char* saved_locale = std::setlocale(LC_NUMERIC, "en_US.UTF-8");
710  sprintf(buffer, "%f", val);
711  std::setlocale(LC_NUMERIC, saved_locale);
712  QString str(buffer);
713  return str;
714 }
const char * name
Systeme de gestion des preferences.
QString _xmlParamNodeName
Nom des noeuds des parametres du fichier XML.
void loadDefault(const char *defaultParams[][2], int nbParams)
Charge le tableau associatif preference/valeur avec les valeurs par defaut.
void getColor(const QString &pref, float &r, float &g, float &b)
Charge les composantes RGB d'une couleur, en float.Utilise la categorie courante.
void setDouble(const QString &pref, const double &value)
Met a jour la valeur associee a une preference.
ODirMap _prefDirs
Tableau associatif parametre/valeur.
static QString doubleToString(const double &val)
QString getDirectory(const QString &pref)
Recherche le nom de la categorie pour une preference donnee.
void setBool(const QString &pref, const bool &value)
Met a jour la valeur associee a une preference. Si la preference n'existe pas, celle-ci est ajoutee a...
static QString floatToString(const float &val)
void setString(const QString &pref, const QString &value)
Met a jour la valeur associee a une preference.
static QString intToString(const int &val)
double getDouble(const QString &pref)
Recherche une ressource et retourne sa valeur associee. Utilise la categorie courante.
float getFloat(const QString &pref)
Recherche une ressource et retourne sa valeur associee. Utilise la categorie courante.
QString _curDir
Le nom de la categorie courante.
QString _xmlRootNodeName
Nom du noeud root du fichier XML.
void setUInt(const QString &pref, const unsigned int &value)
void completePreferences(QString filePath)
Complete les préférences utilisateur manquante avec les valeurs par défaut.
static QString uintToString(const unsigned int &val)
std::vector< QString > getPreferenceNames()
bool writeXML(QString fileName)
Enregistre le fichier de preference au format XML.
bool getBool(const QString &pref)
Recherche une ressource et retourne sa valeur associee. Utilise la categorie courante.
void setFrame(const QString &pref, const int &posX, const int &posY, const int &sizeX, const int &sizeY)
Sauvegarde la position et la taille d'une fenetre.
int getInt(const QString &pref)
Recherche une ressource et retourne sa valeur associee.Utilise la categorie courante.
void setFloat(const QString &pref, const float &value)
Met a jour la valeur associee a une preference.
void setXMLParamNodeName(QString name)
Change le nom des noeuds de parametres dans le fichier XML.
void setXMLRootNodeName(QString name)
Change le nom du noeud root du fichier XML.
bool readXML(QString fileName)
Ouvre un fichier de preference en XML et le parcours pour mettre a jour la tableau de preferences.
QString * getStringArray(const QString &pref, int &sizeArray)
Recherche une ressource et retourne son tableau de valeurs associees. Utilise la categorie courante.
void getPoint(const QString &pref, int &x, int &y)
Charge les coordonnees en pixel d'un point. Utilise la categorie courante.
void setColor(const QString &pref, const float &r, const float &g, const float &b)
Sauvegarde les composantes RGB d'une couleur, en float.Utilise la categorie courante.
void setStringArray(const QString &pref, const QString *valueArray, const int &sizeArray)
Met a jour un tableau de valeurs associees a une preference.
void reset()
Vide le tableau associatif preference/valeur.
bool exists(const QString &pref)
Test si une preference est presente dans le tableau de preferences. Utilise la categorie courante.
void setInt(const QString &pref, const int &value)
Met a jour la valeur associee a une preference.
void setPoint(const QString &pref, const int &x, const int &y)
Sauvegarde les coordonnees en pixel d'un point.
void setCurrentDirectory(QString dir)
Defini la categorie courante pour la lecture et l'ecriture de parametres.
void getFrame(const QString &pref, int &posX, int &posY, int &sizeX, int &sizeY)
Charge la position et la taille d'une fenetre. Utilise la categorie courante.
QString getString(const QString &pref)
Recherche une ressource et retourne sa valeur associee. Utilise la categorie courante.
std::map< QString, OPrefMap >::iterator ODirMapIt
std::map< QString, OPrefMap > _dirMap
std::map< QString, QString >::iterator OPrefMapIt