Crossfire Server, Trunk  R20513
CRESettings.cpp
Go to the documentation of this file.
1 #include "CRESettings.h"
2 #include "CRESettingsDialog.h"
3 
4 #include <QFileInfo>
5 #include <QDir>
6 
8 {
9 }
10 
12 {
13  bool need = false;
14  if (mapCacheDirectory().isEmpty())
15  need = true;
16  else
17  {
18  QFileInfo info(mapCacheDirectory());
19  if (!info.exists())
20  {
21  QDir dir(mapCacheDirectory());
22  dir.mkpath(".");
23  info.refresh();
24  }
25 
26  if (!info.exists())
27  need = true;
28  }
29 
30  if (need)
31  {
32  CRESettingsDialog dlg(this);
33  if (dlg.exec() == QDialog::Rejected)
34  return false;
35 
36  setValue("mapCacheDirectory", dlg.mapCache());
37  return ensureOptions();
38  }
39 
40  return true;
41 }
42 
44 {
45  return value("mapCacheDirectory").toString();
46 }
47 
49 {
50  filters.copy(value("filters").value<CREFilterDefinitionManager>());
51 }
52 
54 {
55  QVariant val;
56  val.setValue(filters);
57  setValue("filters", val);
58 }
59 
61 {
62  reports.copy(value("reports").value<CREReportDefinitionManager>());
63 }
64 
66 {
67  QVariant val;
68  val.setValue(reports);
69  setValue("reports", val);
70 }
void saveFilters(const CREFilterDefinitionManager &filters)
Definition: CRESettings.cpp:53
void copy(const CREReportDefinitionManager &other)
void copy(const CREFilterDefinitionManager &other)
QString mapCacheDirectory() const
Definition: CRESettings.cpp:43
void saveReports(const CREReportDefinitionManager &reports)
Definition: CRESettings.cpp:65
QString mapCache() const
bool ensureOptions()
Definition: CRESettings.cpp:11
void loadFilters(CREFilterDefinitionManager &filters)
Definition: CRESettings.cpp:48
void loadReports(CREReportDefinitionManager &reports)
Definition: CRESettings.cpp:60