forked from nonesense84/QDmi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzusitraindata.cpp
More file actions
208 lines (201 loc) · 7.74 KB
/
Copy pathzusitraindata.cpp
File metadata and controls
208 lines (201 loc) · 7.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include "zusitraindata.h"
#include <QDebug>
//#include <QIntValidator>
zusiTraindata::zusiTraindata(){}
void zusiTraindata::TdeCompeteClicked(){
disableAllButtons();
setAllDataInvalid();
emit newBehavCmpltBtn("Ja", true, false, false, true, true);
}
void zusiTraindata::setLzbAvailable(bool available){
lzbApplicable = available;
emit newBehavVmzBtn(QString::number(enteredVmz), true, enabledVmz, validVmz, lzbApplicable);
emit newBehavZlBtn (QString::number (enteredZl), true, enabledZl, validZl, lzbApplicable);
emit newBehavZlLbl("Zuglänge ", false, false, false, lzbApplicable);
emit newBehavVmzLbl("Höchstgeschwindigkeit ", false, false, false, lzbApplicable);
}
void zusiTraindata::setKeycommand(quint16 command){ // To use in case of using Wachsamtaste
if(validBra && validBrh && validZl && validVmz && command == 0x33){
validated = true;
emit newTraindata(enteredBra, enteredBrh, enteredZl, enteredVmz, validated);
}
}
void zusiTraindata::dataValidButtonPressed(QString buttonText){
if(buttonText == "Ja" || buttonText == "Yes"){
validated = true;
emit newTraindata(enteredBra, enteredBrh, enteredZl, enteredVmz, validated);
finalizeDataEntry();
emit closeDataEntryWindow();
}
else{
finalizeDataEntry(); // FIXME: Maybe the "No" procedure need to be changed in a way, that the window switch back to entry page
emit repeateDataEntry();
}
}
void zusiTraindata::finalizeDataEntry(){
disableAllButtons();
setAllDataInvalid();
transmitAllButtons();
enteredDataString = "";
emit requestKeyboardLayout(0);
emit newBehavCmpltBtn("Ja", true, false, false, true, true);
}
// ======================= Section data comming from keyboard =============================
void zusiTraindata::setTextFromKeyboard(QString text){
if(!(enabledBra || enabledBrh || enabledZl || enabledVmz)) return;
enteredDataString = text;
if(enabledBra){
emit newBehavBraBtn(enteredDataString, true, enabledBra, validBra, true);
}
if(enabledBrh){
emit newBehavBrhBtn(enteredDataString, true, enabledBrh, validBrh, true);
}
if(enabledZl){
emit newBehavZlBtn (enteredDataString, true, enabledZl, validZl, lzbApplicable);
}
if(enabledVmz){
emit newBehavVmzBtn(enteredDataString, true, enabledVmz, validVmz, lzbApplicable);
}
}
// ======================= Section data comming from input fields =============================
void zusiTraindata::setBra(QString BRA, bool btnEnabled){
disableAllButtons();
if(lzbApplicable)
emit requestKeyboardLayout(4);
else
emit requestKeyboardLayout(3);
if(btnEnabled){
enteredBra = static_cast<quint16>(BRA.remove("_").toInt());
if(enteredBra == 0)BRA = BRA.remove("0");
validBra = true;
validated = false;
emit newTraindata(enteredBra, enteredBrh, enteredZl, enteredVmz, validated);
enabledBrh = true;
emit newBehavCmpltBtn("Ja", true, validBra && validBrh && ((validZl && validVmz) | !lzbApplicable), false, true, true);
emit requestDataEntrStrInitials(4, QString::number(enteredBrh));
emit requestKeyboardLayout(0);
}
else{
emit requestDataEntrStrInitials(1, QString::number(enteredBra));
enabledBra = true;
}
enteredDataString = "";
transmitAllButtons();
}
void zusiTraindata::setBrh(QString BRH, bool btnEnabled){
disableAllButtons();
emit requestKeyboardLayout(0);
if(btnEnabled){
enteredBrh = static_cast<quint16>(BRH.remove("_").toInt());
if(enteredBrh == 0)BRH = BRH.remove("0");
validBrh = true;
validated = false;
newTraindata(enteredBra, enteredBrh, enteredZl, enteredVmz, validated);
if(lzbApplicable)enabledZl = true;
emit newBehavCmpltBtn("Ja", true, validBra && validBrh && ((validZl && validVmz) | !lzbApplicable), false, true, true);
emit requestDataEntrStrInitials(3, QString::number(enteredZl));
}
else{
emit requestDataEntrStrInitials(4, QString::number(enteredBrh));
enabledBrh = true;
}
enteredDataString = "";
transmitAllButtons();
}
void zusiTraindata::setZl (QString ZL, bool btnEnabled){
disableAllButtons();
emit requestKeyboardLayout(0);
if(btnEnabled){
enteredZl = static_cast<quint16>(ZL.remove("_").toInt());
validZl = true;
validated = false;
newTraindata(enteredBra, enteredBrh, enteredZl, enteredVmz, validated);
enabledVmz = true;
emit newBehavCmpltBtn("Ja", true, validBra && validBrh && validZl && validVmz, false, true, true);
emit requestDataEntrStrInitials(3, QString::number((enteredVmz)));
}
else{
emit requestDataEntrStrInitials(3, QString::number(enteredZl));
enabledZl = true;
}
enteredDataString = "";
transmitAllButtons();
}
void zusiTraindata::setVmz(QString VMZ, bool btnEnabled){
emit requestKeyboardLayout(0);
disableAllButtons();
if(btnEnabled){
enteredVmz = static_cast<quint16>(VMZ.remove("_").toInt());
validVmz = true;
validated = false;
newTraindata(enteredBra, enteredBrh, enteredZl, enteredVmz, validated);
emit newBehavCmpltBtn("Ja", true, validBra && validBrh && validZl && validVmz, false, true, true);
}
else{
emit requestDataEntrStrInitials(3, QString::number(enteredVmz));
enabledVmz = true;
}
enteredDataString = "";
transmitAllButtons();
}
// ======================= Section "Ersatzdaten" comming from Zusi =============================
void zusiTraindata::setActiveBra(quint16 BRA){
// As long as we are performing the data entry, the mirrored data should not overwright our data:
if(validBra || validBrh || validZl || validVmz) return;
if(BRA != enteredBra){
setAllDataInvalid();
disableAllButtons();
enteredBra = BRA;
transmitAllButtons();
}
}
void zusiTraindata::setActiveBrh(quint16 BRH){
// As long as we are performing the data entry, the mirrored data should not overwright our data:
if(validBra || validBrh || validZl || validVmz) return;
if(BRH != enteredBrh){
setAllDataInvalid();
disableAllButtons();
enteredBrh = BRH;
transmitAllButtons();
}
}
void zusiTraindata::setActiveZl(quint16 ZL){
// As long as we are performing the data entry, the mirrored data should not overwright our data:
if(validBra || validBrh || validZl || validVmz) return;
if(ZL != enteredZl){
setAllDataInvalid();
disableAllButtons();
enteredZl = ZL;
transmitAllButtons();
}
}
void zusiTraindata::setActiveVmz(quint16 VMZ){
// As long as we are performing the data entry, the mirrored data should not overwright our data:
if(validBra || validBrh || validZl || validVmz) return;
if(VMZ != enteredVmz){
setAllDataInvalid();
disableAllButtons();
enteredVmz = VMZ;
transmitAllButtons();
}
}
// ======================= private functions =============================
void zusiTraindata::setAllDataInvalid(){
validBra = false;
validBrh = false;
validZl = false;
validVmz = false;
validated = false;
}
void zusiTraindata::disableAllButtons(){
enabledBra = false;
enabledBrh = false;
enabledZl = false;
enabledVmz = false;
}
void zusiTraindata::transmitAllButtons(){
emit newBehavBraBtn(QString::number(enteredBra), true, enabledBra, validBra, true);
emit newBehavBrhBtn(QString::number(enteredBrh), true, enabledBrh, validBrh, true);
emit newBehavZlBtn (QString::number (enteredZl), true, enabledZl, validZl, lzbApplicable);
emit newBehavVmzBtn(QString::number(enteredVmz), true, enabledVmz, validVmz, lzbApplicable);
}