Subversion Repositories Projects

Rev

Rev 674 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 674 Rev 750
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 <QSettings>
19
#include <QSettings>
20
#include <QDir>
20
#include <QDir>
21
 
21
 
22
#include "cSettings.h"
22
#include "cSettings.h"
23
 
23
 
24
cSettings::cSettings()
24
cSettings::cSettings()
25
{
25
{
26
    Settings_ID = 1;
26
    Settings_ID = 1;
27
 
27
 
28
    read_Settings();
28
    read_Settings();
29
}
29
}
30
 
30
 
31
void cSettings::read_DebugLabels(int ID)
31
void cSettings::read_DebugLabels(int ID)
32
{
32
{
33
    QBitArray Def_View;
33
    QBitArray Def_View;
34
    Def_View.fill(true,MAX_DebugData);
34
    Def_View.fill(true,MAX_DebugData);
35
 
35
 
36
    QString Hardware = HardwareType[ID];
36
    QString Hardware = HardwareType[ID];
37
 
37
 
38
    QSettings Setting("QMK", "Debug-Labels");
38
    QSettings Setting("QMK", "Debug-Labels");
39
 
39
 
40
    Setting.beginGroup("Debug-Labels-" + Hardware);
40
    Setting.beginGroup("Debug-Labels-" + Hardware);
41
 
41
 
42
        DebugData.Version  = Setting.value(("Version"), "0").toString();
42
        DebugData.Version  = Setting.value(("Version"), "0").toString();
43
        for (int a=0; a<MAX_DebugData; a++)
43
        for (int a=0; a<MAX_DebugData; a++)
44
        {
44
        {
45
            DebugData.Label[a]  = Setting.value(("Label_" + QString("%1").arg(a)), "-" + DEF_DebugNames[a]).toString();
45
            DebugData.Label[a]  = Setting.value(("Label_" + QString("%1").arg(a)), "-" + DEF_DebugNames[a]).toString();
46
        }
46
        }
47
        DebugData.Show_Plotter = Setting.value("Show_Plotter", QBitArray(Def_View)).value<QBitArray>();
47
        DebugData.Show_Plotter = Setting.value("Show_Plotter", QBitArray(Def_View)).value<QBitArray>();
48
 
48
 
49
    Setting.endGroup();
49
    Setting.endGroup();
50
}
50
}
51
 
51
 
52
void cSettings::write_DebugLabels(int ID)
52
void cSettings::write_DebugLabels(int ID)
53
{
53
{
54
    QString Hardware = HardwareType[ID];
54
    QString Hardware = HardwareType[ID];
55
 
55
 
56
    QSettings Setting("QMK", "Debug-Labels");
56
    QSettings Setting("QMK", "Debug-Labels");
57
 
57
 
58
    Setting.beginGroup("Debug-Labels-" + Hardware);
58
    Setting.beginGroup("Debug-Labels-" + Hardware);
59
 
59
 
60
        Setting.setValue("Version", DebugData.Version);
60
        Setting.setValue("Version", DebugData.Version);
61
        for (int a=0; a<MAX_DebugData; a++)
61
        for (int a=0; a<MAX_DebugData; a++)
62
        {
62
        {
63
            Setting.setValue("Label_" + QString("%1").arg(a), DebugData.Label[a]);
63
            Setting.setValue("Label_" + QString("%1").arg(a), DebugData.Label[a]);
64
        }
64
        }
65
        Setting.setValue("Show_Plotter", QBitArray(DebugData.Show_Plotter));
65
        Setting.setValue("Show_Plotter", QBitArray(DebugData.Show_Plotter));
66
 
66
 
67
    Setting.endGroup();
67
    Setting.endGroup();
68
}
68
}
69
 
69
 
70
void cSettings::read_Settings()
70
void cSettings::read_Settings()
71
{
71
{
72
    QSettings Setting("QMK", QA_NAME);
72
    QSettings Setting("QMK", QA_NAME);
73
 
73
 
74
    Setting.beginGroup("Global");
74
    Setting.beginGroup("Global");
75
        Settings_ID  = Setting.value("Settings ID", Settings_ID).toInt();
75
        Settings_ID  = Setting.value("Settings ID", Settings_ID).toInt();
76
    Setting.endGroup();
76
    Setting.endGroup();
77
 
77
 
78
    Setting.beginGroup("DATA");
78
    Setting.beginGroup("DATA");
79
        DATA.Debug_Intervall  = Setting.value("Debug-Intervall", 500).toInt();
79
//        DATA.Debug_Intervall  = Setting.value("Debug-Intervall", 500).toInt();
80
        DATA.Plotter_Count    = Setting.value("Plotter-Count", 100).toInt();
80
        DATA.Plotter_Count    = Setting.value("Plotter-Count", 100).toInt();
81
    Setting.endGroup();
81
    Setting.endGroup();
82
 
82
 
83
    Setting.beginGroup("GUI");
83
    Setting.beginGroup("GUI");
84
        GUI.isMax       = Setting.value("IsMax",false).toBool();
84
        GUI.isMax       = Setting.value("IsMax",false).toBool();
85
        GUI.Size        = Setting.value("Size", QSize(700, 300)).toSize();
85
        GUI.Size        = Setting.value("Size", QSize(700, 300)).toSize();
86
        GUI.Point       = Setting.value("Point",QPoint(1,1)).toPoint();
86
        GUI.Point       = Setting.value("Point",QPoint(1,1)).toPoint();
87
    Setting.endGroup();
87
    Setting.endGroup();
88
 
88
/*
89
    Setting.beginGroup("SERVER");
89
    Setting.beginGroup("SERVER");
90
        SERVER.Password = Setting.value("Password", QString("")).toString();
90
        SERVER.Password = Setting.value("Password", QString("")).toString();
91
        SERVER.IP_MAX = Setting.value("IP_MAX", 1).toInt();
91
        SERVER.IP_MAX = Setting.value("IP_MAX", 1).toInt();
92
        SERVER.IP_ID  = Setting.value("IP_ID",  0).toInt();
92
        SERVER.IP_ID  = Setting.value("IP_ID",  0).toInt();
93
 
93
 
94
        for (int z = 0; z < SERVER.IP_MAX; z++)
94
        for (int z = 0; z < SERVER.IP_MAX; z++)
95
        {
95
        {
96
            SERVER.IP[z] = Setting.value("IP_" + QString("%1").arg(z), QString("127.0.0.1:64400")).toString();
96
            SERVER.IP[z] = Setting.value("IP_" + QString("%1").arg(z), QString("127.0.0.1:64400")).toString();
97
        }
97
        }
98
    Setting.endGroup();
98
    Setting.endGroup();
-
 
99
*/
99
}
100
}
100
 
101
 
101
void cSettings::write_Settings()
102
void cSettings::write_Settings()
102
{
103
{
103
    QSettings Setting("QMK", QA_NAME);
104
    QSettings Setting("QMK", QA_NAME);
104
 
105
 
105
    Setting.beginGroup("Global");
106
    Setting.beginGroup("Global");
106
        Setting.setValue("Settings ID", Settings_ID);
107
        Setting.setValue("Settings ID", Settings_ID);
107
    Setting.endGroup();
108
    Setting.endGroup();
108
 
109
 
109
    Setting.beginGroup("DATA");
110
    Setting.beginGroup("DATA");
110
        Setting.setValue("Plotter-Count", DATA.Plotter_Count);
111
        Setting.setValue("Plotter-Count", DATA.Plotter_Count);
111
        Setting.setValue("Debug-Intervall", DATA.Debug_Intervall);
112
//        Setting.setValue("Debug-Intervall", DATA.Debug_Intervall);
112
    Setting.endGroup();
113
    Setting.endGroup();
113
 
114
 
114
    Setting.beginGroup("GUI");
115
    Setting.beginGroup("GUI");
115
        Setting.setValue("IsMax", GUI.isMax);
116
        Setting.setValue("IsMax", GUI.isMax);
116
        Setting.setValue("Size", GUI.Size);
117
        Setting.setValue("Size", GUI.Size);
117
        Setting.setValue("Point", GUI.Point);
118
        Setting.setValue("Point", GUI.Point);
118
    Setting.endGroup();
119
    Setting.endGroup();
119
 
120
/*
120
    Setting.beginGroup("SERVER");
121
    Setting.beginGroup("SERVER");
121
        Setting.setValue("Password", SERVER.Password);
122
        Setting.setValue("Password", SERVER.Password);
122
        Setting.setValue("IP_MAX", SERVER.IP_MAX);
123
        Setting.setValue("IP_MAX", SERVER.IP_MAX);
123
        Setting.setValue("IP_ID",  SERVER.IP_ID);
124
        Setting.setValue("IP_ID",  SERVER.IP_ID);
124
 
125
 
125
        for (int z = 0; z < SERVER.IP_MAX; z++)
126
        for (int z = 0; z < SERVER.IP_MAX; z++)
126
        {
127
        {
127
            Setting.setValue("IP_" + QString("%1").arg(z), SERVER.IP[z]);
128
            Setting.setValue("IP_" + QString("%1").arg(z), SERVER.IP[z]);
128
        }
129
        }
129
    Setting.endGroup();
130
    Setting.endGroup();
-
 
131
*/
130
}
132
}
131
 
133
 
132
 
134
 
133
 
135