Subversion Repositories Projects

Rev

Rev 306 | 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
{
85
    QString Hardware = HardwareType[ID];
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
 
100
    QString Hardware = HardwareType[ID];
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
{
113
    QString Hardware = HardwareType[ID];
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
{
128
    QString Hardware = HardwareType[ID];
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");
481 KeyOz 184
        Map.GotoPosition  = Setting.value("Goto_Position",true).toBool();
185
        Map.ShowTrack     = Setting.value("Show_Track",true).toBool();
186
        Map.LastLatitude  = Setting.value("Last_Latitude",13.5).toDouble();
187
        Map.LastLongitude = Setting.value("Last_Longitude",52.5).toDouble();
306 KeyOz 188
    Setting.endGroup();
189
 
227 KeyOz 190
    Setting.beginGroup("Dirs");
191
        DIR.Logging   = Setting.value("LogDir", HomeDir).toString();
192
        DIR.Parameter = Setting.value("ParDir", HomeDir).toString();
306 KeyOz 193
        DIR.Cache     = Setting.value("Dir_MapCache", HomeDir + ".QMK-Cache").toString();
194
        DIR.AVRDUDE   = Setting.value("Path_AVRDUDE", "avrdude").toString();
227 KeyOz 195
    Setting.endGroup();
196
 
197
    Setting.beginGroup("MKData");
198
        Data.Plotter_Count  = Setting.value("Plotter_Count", 100).toInt();
199
        Data.Debug_Fast     = Setting.value("Debug_Fast", 100).toInt();
200
        Data.Debug_Slow     = Setting.value("Debug_Slow", 500).toInt();
201
        Data.Debug_Off      = Setting.value("Debug_Off", 1000).toInt();
202
        Data.Navi_Fast      = Setting.value("Navi_Fast", 100).toInt();
203
        Data.Navi_Slow      = Setting.value("Navi_Slow", 500).toInt();
204
        Data.Navi_Off       = Setting.value("Navi_Off", 1000).toInt();
205
    Setting.endGroup();
206
 
207
    Setting.beginGroup("GoogleEarth-Server");
208
        Server.Port        = Setting.value("Port", 10664).toString();
209
        Server.StartServer = Setting.value("StartServer", false).toBool();
210
        Server.ToGround    = Setting.value("ToGround",  false).toBool();
211
    Setting.endGroup();
212
 
213
    Setting.beginGroup("QMK-Server");
214
        Server.QMKS_Login    = Setting.value("Login", "").toString();
215
        Server.QMKS_Password = Setting.value("Password", "").toString();
272 KeyOz 216
        Server.QMKS_Host     = Setting.value("Host", "nimari.de").toString();
217
        Server.QMKS_Port     = Setting.value("Port", "16441").toString();
227 KeyOz 218
    Setting.endGroup();
219
 
220
}
221
 
222
void cSettings::write_Settings()
223
{
224
    QSettings Setting("KeyOz-Net", "QMK-Groundstation");
225
 
226
    Setting.beginGroup("Global");
227
        Setting.setValue("Settings ID", Settings_ID);
228
    Setting.endGroup();
229
 
230
    Setting.beginGroup("Port");
231
        Setting.setValue("TTY", TTY.Port);
232
    Setting.endGroup();
233
 
234
    Setting.beginGroup("Dirs");
235
        Setting.setValue("LogDir", DIR.Logging);
236
        Setting.setValue("ParDir", DIR.Parameter);
306 KeyOz 237
        Setting.setValue("Dir_MapCache", DIR.Cache);
238
        Setting.setValue("Path_AVRDUDE", DIR.AVRDUDE);
227 KeyOz 239
    Setting.endGroup();
240
 
241
    Setting.beginGroup("GUI");
242
        Setting.setValue("IsMax", GUI.isMax);
243
        Setting.setValue("Size", GUI.Size);
244
        Setting.setValue("Point", GUI.Point);
245
        Setting.setValue("TabViews", QBitArray(GUI.TabViews));
246
        Setting.setValue("ToolViews", QBitArray(GUI.ToolViews));
247
        Setting.setValue("Terminal_Info", GUI.Term_Info);
248
        Setting.setValue("Terminal_Data", GUI.Term_Data);
249
        Setting.setValue("Terminal_Always", GUI.Term_Always);
250
        Setting.setValue("Terminal_Send", GUI.Term_Send);
251
    Setting.endGroup();
252
 
306 KeyOz 253
    Setting.beginGroup("Map");
254
        Setting.setValue("Goto_Position", Map.GotoPosition);
255
        Setting.setValue("Show_Track", Map.ShowTrack);
481 KeyOz 256
        Setting.setValue("Last_Latitude", Map.LastLatitude);
257
        Setting.setValue("Last_Longitude", Map.LastLongitude);
258
 
306 KeyOz 259
    Setting.endGroup();
260
 
227 KeyOz 261
    Setting.beginGroup("MKData");
262
        Setting.setValue("Plotter_Count", Data.Plotter_Count);
263
        Setting.setValue("Debug_Fast", Data.Debug_Fast);
264
        Setting.setValue("Debug_Slow", Data.Debug_Slow);
265
        Setting.setValue("Debug_Off",  Data.Debug_Off);
266
        Setting.setValue("Navi_Fast", Data.Navi_Fast);
267
        Setting.setValue("Navi_Slow", Data.Navi_Slow);
268
        Setting.setValue("Navi_Off",  Data.Navi_Off);
269
    Setting.endGroup();
270
 
271
    Setting.beginGroup("GoogleEarth-Server");
272
        Setting.setValue("Port", Server.Port);
273
        Setting.setValue("StartServer", Server.StartServer);
274
        Setting.setValue("ToGround",  Server.ToGround);
275
    Setting.endGroup();
276
 
277
    Setting.beginGroup("QMK-Server");
278
        Setting.setValue("Login", Server.QMKS_Login);
279
        Setting.setValue("Password", Server.QMKS_Password);
272 KeyOz 280
        Setting.setValue("Host", Server.QMKS_Host);
281
        Setting.setValue("Port", Server.QMKS_Port);
227 KeyOz 282
    Setting.endGroup();
283
}
284
 
285
cSettings::~cSettings()
286
{
287
}
288
 
289