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