Rev 162 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
158 | 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 | { |
||
162 | KeyOz | 27 | read_Settings(); |
28 | |||
29 | Analog1.LogView.resize(MaxAnalog); |
||
30 | Analog1.PlotView.resize(MaxAnalog); |
||
31 | |||
32 | // Alte Settingsstruktur Löschen. |
||
33 | if (Settings_ID == 1) |
||
34 | { |
||
35 | qDebug("Konvertiere Einstellungen Version 1 -> 2"); |
||
36 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
37 | |||
38 | Setting.beginGroup("AnalogWerte"); |
||
39 | for (int a = 0; a < MaxAnalog; a++) |
||
40 | { |
||
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()); |
||
43 | Analog1.Label[a] = Setting.value(("Analog_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
||
44 | } |
||
45 | Setting.endGroup(); |
||
46 | |||
47 | Settings_ID = 2; |
||
48 | |||
49 | Setting.remove("AnalogWerte-FC"); |
||
50 | Setting.remove("AnalogWerte"); |
||
51 | |||
52 | write_Settings_Analog(); |
||
53 | write_Settings_AnalogLabels(); |
||
54 | } |
||
55 | else |
||
56 | { |
||
57 | read_Settings_Analog(); |
||
58 | read_Settings_AnalogLabels(); |
||
59 | } |
||
158 | KeyOz | 60 | } |
61 | |||
162 | KeyOz | 62 | void cSettings::write_Settings_Analog(int ID) |
63 | { |
||
64 | QString Hardware = HardwareType[ID]; |
||
65 | |||
66 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
67 | |||
68 | Setting.beginGroup("Analog-Werte"); |
||
69 | Setting.setValue(Hardware + "-LogView", QBitArray(Analog1.LogView)); |
||
70 | Setting.setValue(Hardware + "-PlotView", QBitArray(Analog1.PlotView)); |
||
71 | Setting.endGroup(); |
||
72 | } |
||
73 | |||
74 | void cSettings::read_Settings_Analog(int ID) |
||
75 | { |
||
76 | QBitArray Def_View; |
||
77 | Def_View.fill(true,MaxAnalog); |
||
78 | |||
79 | QString Hardware = HardwareType[ID]; |
||
80 | |||
81 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
82 | |||
83 | Setting.beginGroup("Analog-Werte"); |
||
84 | Analog1.LogView = Setting.value(Hardware + "-LogView", QBitArray(Def_View)).value<QBitArray>(); |
||
85 | Analog1.PlotView = Setting.value(Hardware + "-PlotView", QBitArray(Def_View)).value<QBitArray>(); |
||
86 | Setting.endGroup(); |
||
87 | } |
||
88 | |||
89 | void cSettings::write_Settings_AnalogLabels(int ID) |
||
90 | { |
||
91 | QString Hardware = HardwareType[ID]; |
||
92 | |||
93 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
||
94 | |||
95 | Setting.beginGroup("Analog-Labels-" + Hardware); |
||
163 | KeyOz | 96 | Setting.setValue("Version", Analog1.Version); |
162 | KeyOz | 97 | for (int a=0; a<MaxAnalog; a++) |
98 | { |
||
99 | Setting.setValue("Label_" + QString("%1").arg(a), Analog1.Label[a]); |
||
100 | } |
||
101 | Setting.endGroup(); |
||
102 | } |
||
103 | |||
104 | void cSettings::read_Settings_AnalogLabels(int ID) |
||
105 | { |
||
106 | QString Hardware = HardwareType[ID]; |
||
107 | |||
108 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
||
109 | |||
110 | Setting.beginGroup("Analog-Labels-" + Hardware); |
||
163 | KeyOz | 111 | Analog1.Version = Setting.value(("Version"), "0").toString(); |
162 | KeyOz | 112 | for (int a=0; a<MaxAnalog; a++) |
113 | { |
||
114 | Analog1.Label[a] = Setting.value(("Label_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
||
115 | } |
||
116 | Setting.endGroup(); |
||
117 | } |
||
118 | |||
158 | KeyOz | 119 | void cSettings::read_Settings() |
120 | { |
||
121 | QBitArray Def_TabViews; |
||
122 | Def_TabViews.fill(true, 6); |
||
123 | |||
124 | QDir Dir; |
||
125 | |||
126 | QString HomeDir = (QString(Dir.homePath() + "/")); |
||
127 | |||
128 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
129 | |||
162 | KeyOz | 130 | Setting.beginGroup("Global"); |
131 | Settings_ID = Setting.value("Settings ID", 1).toInt(); |
||
132 | Setting.endGroup(); |
||
133 | |||
158 | KeyOz | 134 | Setting.beginGroup("Port"); |
135 | TTY.Port = Setting.value("TTY", QString("/dev/ttyUSB0")).toString(); |
||
136 | Setting.endGroup(); |
||
137 | |||
138 | Setting.beginGroup("GUI"); |
||
162 | KeyOz | 139 | GUI.isMax = Setting.value("IsMax",false).toBool(); |
140 | GUI.Size = Setting.value("Size", QSize(700, 300)).toSize(); |
||
141 | GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
||
142 | GUI.TabViews = Setting.value("TabViews", QBitArray(Def_TabViews)).value<QBitArray>(); |
||
143 | GUI.Term_Info = Setting.value("Terminal_Info",false).toBool(); |
||
144 | GUI.Term_Data = Setting.value("Terminal_Data",true).toBool(); |
||
145 | GUI.Term_Always = Setting.value("Terminal_Always",false).toBool(); |
||
146 | Setting.endGroup(); |
||
158 | KeyOz | 147 | |
148 | Setting.beginGroup("Dirs"); |
||
149 | DIR.Logging = Setting.value("LogDir", HomeDir).toString(); |
||
150 | DIR.Parameter = Setting.value("ParDir", HomeDir).toString(); |
||
151 | Setting.endGroup(); |
||
152 | } |
||
153 | |||
154 | void cSettings::write_Settings() |
||
155 | { |
||
156 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
157 | |||
162 | KeyOz | 158 | Setting.beginGroup("Global"); |
159 | Setting.setValue("Settings ID", Settings_ID); |
||
160 | Setting.endGroup(); |
||
161 | |||
158 | KeyOz | 162 | Setting.beginGroup("Port"); |
163 | KeyOz | 163 | Setting.setValue("TTY", TTY.Port); |
158 | KeyOz | 164 | Setting.endGroup(); |
165 | |||
166 | Setting.beginGroup("Dirs"); |
||
167 | Setting.setValue("LogDir", DIR.Logging); |
||
168 | Setting.setValue("ParDir", DIR.Parameter); |
||
169 | Setting.endGroup(); |
||
170 | |||
171 | Setting.beginGroup("GUI"); |
||
162 | KeyOz | 172 | Setting.setValue("Terminal_Info", GUI.Term_Info); |
173 | Setting.setValue("Terminal_Data", GUI.Term_Data); |
||
174 | Setting.setValue("Terminal_Always", GUI.Term_Always); |
||
163 | KeyOz | 175 | Setting.setValue("TabViews", QBitArray(GUI.TabViews)); |
158 | KeyOz | 176 | Setting.endGroup(); |
177 | } |
||
178 | |||
179 | cSettings::~cSettings() |
||
180 | { |
||
181 | } |
||
182 | |||
183 |