Rev 158 | 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); |
||
96 | for (int a=0; a<MaxAnalog; a++) |
||
97 | { |
||
98 | Setting.setValue("Label_" + QString("%1").arg(a), Analog1.Label[a]); |
||
99 | } |
||
100 | Setting.endGroup(); |
||
101 | } |
||
102 | |||
103 | void cSettings::read_Settings_AnalogLabels(int ID) |
||
104 | { |
||
105 | QString Hardware = HardwareType[ID]; |
||
106 | |||
107 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
||
108 | |||
109 | Setting.beginGroup("Analog-Labels-" + Hardware); |
||
110 | for (int a=0; a<MaxAnalog; a++) |
||
111 | { |
||
112 | Analog1.Label[a] = Setting.value(("Label_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
||
113 | } |
||
114 | Setting.endGroup(); |
||
115 | } |
||
116 | |||
158 | KeyOz | 117 | void cSettings::read_Settings() |
118 | { |
||
119 | QBitArray Def_TabViews; |
||
120 | Def_TabViews.fill(true, 6); |
||
121 | |||
122 | QDir Dir; |
||
123 | |||
124 | QString HomeDir = (QString(Dir.homePath() + "/")); |
||
125 | |||
126 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
127 | |||
162 | KeyOz | 128 | Setting.beginGroup("Global"); |
129 | Settings_ID = Setting.value("Settings ID", 1).toInt(); |
||
130 | Setting.endGroup(); |
||
131 | |||
158 | KeyOz | 132 | Setting.beginGroup("Port"); |
133 | TTY.Port = Setting.value("TTY", QString("/dev/ttyUSB0")).toString(); |
||
134 | Setting.endGroup(); |
||
135 | |||
136 | Setting.beginGroup("GUI"); |
||
162 | KeyOz | 137 | GUI.isMax = Setting.value("IsMax",false).toBool(); |
138 | GUI.Size = Setting.value("Size", QSize(700, 300)).toSize(); |
||
139 | GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
||
140 | GUI.TabViews = Setting.value("TabViews", QBitArray(Def_TabViews)).value<QBitArray>(); |
||
141 | GUI.Term_Info = Setting.value("Terminal_Info",false).toBool(); |
||
142 | GUI.Term_Data = Setting.value("Terminal_Data",true).toBool(); |
||
143 | GUI.Term_Always = Setting.value("Terminal_Always",false).toBool(); |
||
144 | Setting.endGroup(); |
||
158 | KeyOz | 145 | |
146 | Setting.beginGroup("Dirs"); |
||
147 | DIR.Logging = Setting.value("LogDir", HomeDir).toString(); |
||
148 | DIR.Parameter = Setting.value("ParDir", HomeDir).toString(); |
||
149 | Setting.endGroup(); |
||
150 | } |
||
151 | |||
152 | void cSettings::write_Settings() |
||
153 | { |
||
154 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
155 | |||
162 | KeyOz | 156 | Setting.beginGroup("Global"); |
157 | Setting.setValue("Settings ID", Settings_ID); |
||
158 | Setting.endGroup(); |
||
159 | |||
158 | KeyOz | 160 | Setting.beginGroup("Port"); |
161 | // Setting.setValue("TTY", le_Port->text()); |
||
162 | Setting.endGroup(); |
||
163 | |||
164 | Setting.beginGroup("Dirs"); |
||
165 | Setting.setValue("LogDir", DIR.Logging); |
||
166 | Setting.setValue("ParDir", DIR.Parameter); |
||
167 | Setting.endGroup(); |
||
168 | |||
169 | Setting.beginGroup("GUI"); |
||
162 | KeyOz | 170 | Setting.setValue("Terminal_Info", GUI.Term_Info); |
171 | Setting.setValue("Terminal_Data", GUI.Term_Data); |
||
172 | Setting.setValue("Terminal_Always", GUI.Term_Always); |
||
158 | KeyOz | 173 | Setting.endGroup(); |
174 | } |
||
175 | |||
176 | cSettings::~cSettings() |
||
177 | { |
||
178 | } |
||
179 | |||
180 |