dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
lineardialgadgetconfiguration.cpp
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 
28 #include "utils/pathutils.h"
29 
35  QObject *parent)
36  : IUAVGadgetConfiguration(classId, parent)
37  , dialFile("Unknown")
38  , sourceDataObject("Unknown")
39  , sourceObjectField("Unknown")
40  , minValue(0)
41  , maxValue(100)
42  , redMin(0)
43  , redMax(33)
44  , yellowMin(33)
45  , yellowMax(66)
46  , greenMin(66)
47  , greenMax(100)
48  , factor(1.00)
49  , decimalPlaces(0)
50 {
51  // if a saved configuration exists load it
52  if (qSettings != nullptr) {
53  QString dFile = qSettings->value("dFile").toString();
54  dialFile = Utils::PathUtils().InsertDataPath(dFile);
55  sourceDataObject = qSettings->value("sourceDataObject").toString();
56  sourceObjectField = qSettings->value("sourceObjectField").toString();
57  minValue = qSettings->value("minValue").toDouble();
58  maxValue = qSettings->value("maxValue").toDouble();
59  redMin = qSettings->value("redMin").toDouble();
60  redMax = qSettings->value("redMax").toDouble();
61  yellowMin = qSettings->value("yellowMin").toDouble();
62  yellowMax = qSettings->value("yellowMax").toDouble();
63  greenMin = qSettings->value("greenMin").toDouble();
64  greenMax = qSettings->value("greenMax").toDouble();
65  font = qSettings->value("font").toString();
66  decimalPlaces = qSettings->value("decimalPlaces").toInt();
67  factor = qSettings->value("factor").toDouble();
68  }
69 }
70 
75 IUAVGadgetConfiguration *LineardialGadgetConfiguration::clone()
76 {
78  m->dialFile = dialFile;
79  m->sourceDataObject = sourceDataObject;
80  m->sourceObjectField = sourceObjectField;
81  m->minValue = minValue;
82  m->maxValue = maxValue;
83  m->redMin = redMin;
84  m->redMax = redMax;
85  m->yellowMin = yellowMin;
86  m->yellowMax = yellowMax;
87  m->greenMin = greenMin;
88  m->greenMax = greenMax;
89  m->font = font;
90  m->decimalPlaces = decimalPlaces;
91  m->factor = factor;
92 
93  return m;
94 }
95 
100 void LineardialGadgetConfiguration::saveConfig(QSettings *qSettings) const
101 {
102  QString dFile = Utils::PathUtils().RemoveDataPath(dialFile);
103  qSettings->setValue("dFile", dFile);
104  qSettings->setValue("sourceDataObject", sourceDataObject);
105  qSettings->setValue("sourceObjectField", sourceObjectField);
106  qSettings->setValue("minValue", minValue);
107  qSettings->setValue("maxValue", maxValue);
108  qSettings->setValue("redMin", redMin);
109  qSettings->setValue("redMax", redMax);
110  qSettings->setValue("yellowMin", yellowMin);
111  qSettings->setValue("yellowMax", yellowMax);
112  qSettings->setValue("greenMin", greenMin);
113  qSettings->setValue("greenMax", greenMax);
114  qSettings->setValue("font", font);
115  qSettings->setValue("decimalPlaces", decimalPlaces);
116  qSettings->setValue("factor", factor);
117 }
static QString RemoveDataPath(QString path)
Definition: pathutils.cpp:67
LineardialGadgetConfiguration(QString classId, QSettings *qSettings=nullptr, QObject *parent=nullptr)
static QString InsertDataPath(QString path)
Definition: pathutils.cpp:84