Rev 440 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
227 | KeyOz | 1 | /*************************************************************************** |
2 | * Copyright (C) 2008 by Manuel Schrape * |
||
3 | * manuel.schrape@gmx.de * |
||
4 | * * |
||
5 | * This program is free software; you can redistribute it and/or modify * |
||
6 | * it under the terms of the GNU General Public License as published by * |
||
7 | * the Free Software Foundation; either version 2 of the License. * |
||
8 | * * |
||
9 | * This program is distributed in the hope that it will be useful, * |
||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
12 | * GNU General Public License for more details. * |
||
13 | * * |
||
14 | * You should have received a copy of the GNU General Public License * |
||
15 | * along with this program; if not, write to the * |
||
16 | * Free Software Foundation, Inc., * |
||
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
18 | ***************************************************************************/ |
||
19 | #include <QCoreApplication> |
||
20 | #include <QSettings> |
||
21 | #include <QDir> |
||
22 | |||
23 | #include "cSettings.h" |
||
24 | |||
25 | cSettings::cSettings() |
||
26 | { |
||
27 | read_SettingsID(); |
||
28 | |||
29 | if (Settings_ID < 3) |
||
30 | { |
||
31 | QBitArray Def_TabViews; |
||
32 | Def_TabViews.fill(true, 6); |
||
33 | |||
34 | qDebug("Konvertiere Einstellungen Version 1+2 -> 3"); |
||
35 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
36 | |||
37 | Setting.beginGroup("GUI"); |
||
38 | GUI.TabViews = Setting.value("TabViews", QBitArray(Def_TabViews)).value<QBitArray>(); |
||
39 | |||
40 | GUI.TabViews.resize(10); |
||
41 | GUI.TabViews[6] = true; |
||
42 | |||
43 | Setting.setValue("TabViews", QBitArray(GUI.TabViews)); |
||
44 | Setting.endGroup(); |
||
45 | } |
||
46 | |||
47 | read_Settings(); |
||
48 | |||
49 | Analog1.LogView.resize(MaxAnalog); |
||
50 | Analog1.PlotView.resize(MaxAnalog); |
||
51 | |||
52 | // Alte Settingsstruktur Löschen. |
||
53 | if (Settings_ID < 2) |
||
54 | { |
||
55 | qDebug("Konvertiere Einstellungen Version 1 -> 2"); |
||
56 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
57 | |||
58 | Setting.beginGroup("AnalogWerte"); |
||
59 | for (int a = 0; a < MaxAnalog; a++) |
||
60 | { |
||
61 | Analog1.LogView.setBit(a, Setting.value(("Analog_" + QString("%1").arg(a) + "_Log"), Def_Log[a]).toBool()); |
||
62 | Analog1.PlotView.setBit(a, Setting.value(("Analog_" + QString("%1").arg(a) + "_Plot"), Def_Plot_Show[a]).toBool()); |
||
63 | Analog1.Label[a] = Setting.value(("Analog_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
||
64 | } |
||
65 | Setting.endGroup(); |
||
66 | |||
67 | Setting.remove("AnalogWerte-FC"); |
||
68 | Setting.remove("AnalogWerte"); |
||
69 | |||
70 | write_Settings_Analog(); |
||
71 | write_Settings_AnalogLabels(); |
||
72 | } |
||
73 | else |
||
74 | { |
||
75 | read_Settings_Analog(); |
||
76 | read_Settings_AnalogLabels(); |
||
77 | } |
||
78 | |||
79 | Settings_ID = 3; |
||
80 | } |
||
81 | |||
82 | // Config der Analogwert-Anzeige (Plotter / CVS) |
||
83 | void cSettings::write_Settings_Analog(int ID) |
||
84 | { |
||
449 | Brean | 85 | QString Hardware = QString(HardwareType[ID]); |
227 | KeyOz | 86 | |
87 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
88 | |||
89 | Setting.beginGroup("Analog-Werte"); |
||
90 | Setting.setValue(Hardware + "-LogView", QBitArray(Analog1.LogView)); |
||
91 | Setting.setValue(Hardware + "-PlotView", QBitArray(Analog1.PlotView)); |
||
92 | Setting.endGroup(); |
||
93 | } |
||
94 | |||
95 | void cSettings::read_Settings_Analog(int ID) |
||
96 | { |
||
97 | QBitArray Def_View; |
||
98 | Def_View.fill(true,MaxAnalog); |
||
99 | |||
449 | Brean | 100 | QString Hardware = QString(HardwareType[ID]); |
227 | KeyOz | 101 | |
102 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
103 | |||
104 | Setting.beginGroup("Analog-Werte"); |
||
105 | Analog1.LogView = Setting.value(Hardware + "-LogView", QBitArray(Def_View)).value<QBitArray>(); |
||
106 | Analog1.PlotView = Setting.value(Hardware + "-PlotView", QBitArray(Def_View)).value<QBitArray>(); |
||
107 | Setting.endGroup(); |
||
108 | } |
||
109 | |||
110 | // Labels der Analogwerte. |
||
111 | void cSettings::write_Settings_AnalogLabels(int ID) |
||
112 | { |
||
449 | Brean | 113 | QString Hardware = QString(HardwareType[ID]); |
227 | KeyOz | 114 | |
115 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
||
116 | |||
117 | Setting.beginGroup("Analog-Labels-" + Hardware); |
||
118 | Setting.setValue("Version", Analog1.Version); |
||
119 | for (int a=0; a<MaxAnalog; a++) |
||
120 | { |
||
121 | Setting.setValue("Label_" + QString("%1").arg(a), Analog1.Label[a]); |
||
122 | } |
||
123 | Setting.endGroup(); |
||
124 | } |
||
125 | |||
126 | void cSettings::read_Settings_AnalogLabels(int ID) |
||
127 | { |
||
449 | Brean | 128 | QString Hardware = QString(HardwareType[ID]); |
227 | KeyOz | 129 | |
130 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
||
131 | |||
132 | Setting.beginGroup("Analog-Labels-" + Hardware); |
||
133 | Analog1.Version = Setting.value(("Version"), "0").toString(); |
||
134 | for (int a=0; a<MaxAnalog; a++) |
||
135 | { |
||
136 | Analog1.Label[a] = Setting.value(("Label_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
||
137 | } |
||
138 | Setting.endGroup(); |
||
139 | } |
||
140 | |||
141 | // Programmeinstellungen |
||
142 | void cSettings::read_SettingsID() |
||
143 | { |
||
144 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
145 | |||
146 | Setting.beginGroup("Global"); |
||
147 | Settings_ID = Setting.value("Settings ID", 1).toInt(); |
||
148 | Setting.endGroup(); |
||
149 | } |
||
150 | |||
151 | // Programmeinstellungen |
||
152 | void cSettings::read_Settings() |
||
153 | { |
||
154 | QBitArray Def_BitArray; |
||
155 | Def_BitArray.fill(true, 10); |
||
156 | |||
157 | QDir Dir; |
||
158 | |||
159 | QString HomeDir = (QString(Dir.homePath() + "/")); |
||
160 | |||
161 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
162 | |||
163 | Setting.beginGroup("Global"); |
||
164 | Settings_ID = Setting.value("Settings ID", 1).toInt(); |
||
165 | Setting.endGroup(); |
||
166 | |||
167 | Setting.beginGroup("Port"); |
||
168 | TTY.Port = Setting.value("TTY", QString(OS_PORT)).toString(); |
||
169 | Setting.endGroup(); |
||
170 | |||
171 | Setting.beginGroup("GUI"); |
||
172 | GUI.isMax = Setting.value("IsMax",false).toBool(); |
||
173 | GUI.Size = Setting.value("Size", QSize(700, 300)).toSize(); |
||
174 | GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
||
175 | GUI.TabViews = Setting.value("TabViews", QBitArray(Def_BitArray)).value<QBitArray>(); |
||
176 | GUI.ToolViews = Setting.value("ToolViews", QBitArray(Def_BitArray)).value<QBitArray>(); |
||
177 | GUI.Term_Info = Setting.value("Terminal_Info",false).toBool(); |
||
178 | GUI.Term_Data = Setting.value("Terminal_Data",true).toBool(); |
||
179 | GUI.Term_Always = Setting.value("Terminal_Always",false).toBool(); |
||
180 | GUI.Term_Send = Setting.value("Terminal_Send",true).toBool(); |
||
181 | Setting.endGroup(); |
||
182 | |||
306 | KeyOz | 183 | Setting.beginGroup("Map"); |
184 | Map.GotoPosition = Setting.value("Goto_Position",true).toBool(); |
||
185 | Map.ShowTrack = Setting.value("Show_Track",true).toBool(); |
||
186 | Setting.endGroup(); |
||
187 | |||
227 | KeyOz | 188 | Setting.beginGroup("Dirs"); |
189 | DIR.Logging = Setting.value("LogDir", HomeDir).toString(); |
||
190 | DIR.Parameter = Setting.value("ParDir", HomeDir).toString(); |
||
306 | KeyOz | 191 | DIR.Cache = Setting.value("Dir_MapCache", HomeDir + ".QMK-Cache").toString(); |
192 | DIR.AVRDUDE = Setting.value("Path_AVRDUDE", "avrdude").toString(); |
||
227 | KeyOz | 193 | Setting.endGroup(); |
194 | |||
195 | Setting.beginGroup("MKData"); |
||
196 | Data.Plotter_Count = Setting.value("Plotter_Count", 100).toInt(); |
||
197 | Data.Debug_Fast = Setting.value("Debug_Fast", 100).toInt(); |
||
198 | Data.Debug_Slow = Setting.value("Debug_Slow", 500).toInt(); |
||
199 | Data.Debug_Off = Setting.value("Debug_Off", 1000).toInt(); |
||
200 | Data.Navi_Fast = Setting.value("Navi_Fast", 100).toInt(); |
||
201 | Data.Navi_Slow = Setting.value("Navi_Slow", 500).toInt(); |
||
202 | Data.Navi_Off = Setting.value("Navi_Off", 1000).toInt(); |
||
203 | Setting.endGroup(); |
||
204 | |||
205 | Setting.beginGroup("GoogleEarth-Server"); |
||
206 | Server.Port = Setting.value("Port", 10664).toString(); |
||
207 | Server.StartServer = Setting.value("StartServer", false).toBool(); |
||
208 | Server.ToGround = Setting.value("ToGround", false).toBool(); |
||
209 | Setting.endGroup(); |
||
210 | |||
211 | Setting.beginGroup("QMK-Server"); |
||
212 | Server.QMKS_Login = Setting.value("Login", "").toString(); |
||
213 | Server.QMKS_Password = Setting.value("Password", "").toString(); |
||
272 | KeyOz | 214 | Server.QMKS_Host = Setting.value("Host", "nimari.de").toString(); |
215 | Server.QMKS_Port = Setting.value("Port", "16441").toString(); |
||
227 | KeyOz | 216 | Setting.endGroup(); |
217 | |||
218 | } |
||
219 | |||
220 | void cSettings::write_Settings() |
||
221 | { |
||
222 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
223 | |||
224 | Setting.beginGroup("Global"); |
||
225 | Setting.setValue("Settings ID", Settings_ID); |
||
226 | Setting.endGroup(); |
||
227 | |||
228 | Setting.beginGroup("Port"); |
||
229 | Setting.setValue("TTY", TTY.Port); |
||
230 | Setting.endGroup(); |
||
231 | |||
232 | Setting.beginGroup("Dirs"); |
||
233 | Setting.setValue("LogDir", DIR.Logging); |
||
234 | Setting.setValue("ParDir", DIR.Parameter); |
||
306 | KeyOz | 235 | Setting.setValue("Dir_MapCache", DIR.Cache); |
236 | Setting.setValue("Path_AVRDUDE", DIR.AVRDUDE); |
||
227 | KeyOz | 237 | Setting.endGroup(); |
238 | |||
239 | Setting.beginGroup("GUI"); |
||
240 | Setting.setValue("IsMax", GUI.isMax); |
||
241 | Setting.setValue("Size", GUI.Size); |
||
242 | Setting.setValue("Point", GUI.Point); |
||
243 | Setting.setValue("TabViews", QBitArray(GUI.TabViews)); |
||
244 | Setting.setValue("ToolViews", QBitArray(GUI.ToolViews)); |
||
245 | Setting.setValue("Terminal_Info", GUI.Term_Info); |
||
246 | Setting.setValue("Terminal_Data", GUI.Term_Data); |
||
247 | Setting.setValue("Terminal_Always", GUI.Term_Always); |
||
248 | Setting.setValue("Terminal_Send", GUI.Term_Send); |
||
249 | Setting.endGroup(); |
||
250 | |||
306 | KeyOz | 251 | Setting.beginGroup("Map"); |
252 | Setting.setValue("Goto_Position", Map.GotoPosition); |
||
253 | Setting.setValue("Show_Track", Map.ShowTrack); |
||
254 | Setting.endGroup(); |
||
255 | |||
227 | KeyOz | 256 | Setting.beginGroup("MKData"); |
257 | Setting.setValue("Plotter_Count", Data.Plotter_Count); |
||
258 | Setting.setValue("Debug_Fast", Data.Debug_Fast); |
||
259 | Setting.setValue("Debug_Slow", Data.Debug_Slow); |
||
260 | Setting.setValue("Debug_Off", Data.Debug_Off); |
||
261 | Setting.setValue("Navi_Fast", Data.Navi_Fast); |
||
262 | Setting.setValue("Navi_Slow", Data.Navi_Slow); |
||
263 | Setting.setValue("Navi_Off", Data.Navi_Off); |
||
264 | Setting.endGroup(); |
||
265 | |||
266 | Setting.beginGroup("GoogleEarth-Server"); |
||
267 | Setting.setValue("Port", Server.Port); |
||
268 | Setting.setValue("StartServer", Server.StartServer); |
||
269 | Setting.setValue("ToGround", Server.ToGround); |
||
270 | Setting.endGroup(); |
||
271 | |||
272 | Setting.beginGroup("QMK-Server"); |
||
273 | Setting.setValue("Login", Server.QMKS_Login); |
||
274 | Setting.setValue("Password", Server.QMKS_Password); |
||
272 | KeyOz | 275 | Setting.setValue("Host", Server.QMKS_Host); |
276 | Setting.setValue("Port", Server.QMKS_Port); |
||
227 | KeyOz | 277 | Setting.endGroup(); |
278 | } |
||
279 | |||
280 | cSettings::~cSettings() |
||
281 | { |
||
282 | } |
||
283 | |||
284 |