SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
SWGCWKeyerSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGCWKeyerSettings.h"
15 
16 #include "SWGHelpers.h"
17 
18 #include <QJsonDocument>
19 #include <QJsonArray>
20 #include <QObject>
21 #include <QDebug>
22 
23 namespace SWGSDRangel {
24 
26  init();
27  this->fromJson(*json);
28 }
29 
31  sample_rate = 0;
32  m_sample_rate_isSet = false;
33  wpm = 0;
34  m_wpm_isSet = false;
35  mode = 0;
36  m_mode_isSet = false;
37  text = nullptr;
38  m_text_isSet = false;
39  loop = 0;
40  m_loop_isSet = false;
41  keyboard_iambic = 0;
43  dot_key = 0;
44  m_dot_key_isSet = false;
47  dash_key = 0;
48  m_dash_key_isSet = false;
51 }
52 
54  this->cleanup();
55 }
56 
57 void
59  sample_rate = 0;
60  m_sample_rate_isSet = false;
61  wpm = 0;
62  m_wpm_isSet = false;
63  mode = 0;
64  m_mode_isSet = false;
65  text = new QString("");
66  m_text_isSet = false;
67  loop = 0;
68  m_loop_isSet = false;
69  keyboard_iambic = 0;
71  dot_key = 0;
72  m_dot_key_isSet = false;
75  dash_key = 0;
76  m_dash_key_isSet = false;
79 }
80 
81 void
83 
84 
85 
86  if(text != nullptr) {
87  delete text;
88  }
89 
90 
91 
92 
93 
94 
95 }
96 
99  QByteArray array (json.toStdString().c_str());
100  QJsonDocument doc = QJsonDocument::fromJson(array);
101  QJsonObject jsonObject = doc.object();
102  this->fromJsonObject(jsonObject);
103  return this;
104 }
105 
106 void
108  ::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", "");
109 
110  ::SWGSDRangel::setValue(&wpm, pJson["wpm"], "qint32", "");
111 
112  ::SWGSDRangel::setValue(&mode, pJson["mode"], "qint32", "");
113 
114  ::SWGSDRangel::setValue(&text, pJson["text"], "QString", "QString");
115 
116  ::SWGSDRangel::setValue(&loop, pJson["loop"], "qint32", "");
117 
118  ::SWGSDRangel::setValue(&keyboard_iambic, pJson["keyboardIambic"], "qint32", "");
119 
120  ::SWGSDRangel::setValue(&dot_key, pJson["dotKey"], "qint32", "");
121 
122  ::SWGSDRangel::setValue(&dot_key_modifiers, pJson["dotKeyModifiers"], "qint32", "");
123 
124  ::SWGSDRangel::setValue(&dash_key, pJson["dashKey"], "qint32", "");
125 
126  ::SWGSDRangel::setValue(&dash_key_modifiers, pJson["dashKeyModifiers"], "qint32", "");
127 
128 }
129 
130 QString
132 {
133  QJsonObject* obj = this->asJsonObject();
134 
135  QJsonDocument doc(*obj);
136  QByteArray bytes = doc.toJson();
137  delete obj;
138  return QString(bytes);
139 }
140 
141 QJsonObject*
143  QJsonObject* obj = new QJsonObject();
145  obj->insert("sampleRate", QJsonValue(sample_rate));
146  }
147  if(m_wpm_isSet){
148  obj->insert("wpm", QJsonValue(wpm));
149  }
150  if(m_mode_isSet){
151  obj->insert("mode", QJsonValue(mode));
152  }
153  if(text != nullptr && *text != QString("")){
154  toJsonValue(QString("text"), text, obj, QString("QString"));
155  }
156  if(m_loop_isSet){
157  obj->insert("loop", QJsonValue(loop));
158  }
160  obj->insert("keyboardIambic", QJsonValue(keyboard_iambic));
161  }
162  if(m_dot_key_isSet){
163  obj->insert("dotKey", QJsonValue(dot_key));
164  }
166  obj->insert("dotKeyModifiers", QJsonValue(dot_key_modifiers));
167  }
168  if(m_dash_key_isSet){
169  obj->insert("dashKey", QJsonValue(dash_key));
170  }
172  obj->insert("dashKeyModifiers", QJsonValue(dash_key_modifiers));
173  }
174 
175  return obj;
176 }
177 
178 qint32
180  return sample_rate;
181 }
182 void
184  this->sample_rate = sample_rate;
185  this->m_sample_rate_isSet = true;
186 }
187 
188 qint32
190  return wpm;
191 }
192 void
194  this->wpm = wpm;
195  this->m_wpm_isSet = true;
196 }
197 
198 qint32
200  return mode;
201 }
202 void
204  this->mode = mode;
205  this->m_mode_isSet = true;
206 }
207 
208 QString*
210  return text;
211 }
212 void
214  this->text = text;
215  this->m_text_isSet = true;
216 }
217 
218 qint32
220  return loop;
221 }
222 void
224  this->loop = loop;
225  this->m_loop_isSet = true;
226 }
227 
228 qint32
230  return keyboard_iambic;
231 }
232 void
234  this->keyboard_iambic = keyboard_iambic;
235  this->m_keyboard_iambic_isSet = true;
236 }
237 
238 qint32
240  return dot_key;
241 }
242 void
244  this->dot_key = dot_key;
245  this->m_dot_key_isSet = true;
246 }
247 
248 qint32
250  return dot_key_modifiers;
251 }
252 void
254  this->dot_key_modifiers = dot_key_modifiers;
255  this->m_dot_key_modifiers_isSet = true;
256 }
257 
258 qint32
260  return dash_key;
261 }
262 void
264  this->dash_key = dash_key;
265  this->m_dash_key_isSet = true;
266 }
267 
268 qint32
270  return dash_key_modifiers;
271 }
272 void
274  this->dash_key_modifiers = dash_key_modifiers;
275  this->m_dash_key_modifiers_isSet = true;
276 }
277 
278 
279 bool
281  bool isObjectUpdated = false;
282  do{
283  if(m_sample_rate_isSet){ isObjectUpdated = true; break;}
284  if(m_wpm_isSet){ isObjectUpdated = true; break;}
285  if(m_mode_isSet){ isObjectUpdated = true; break;}
286  if(text != nullptr && *text != QString("")){ isObjectUpdated = true; break;}
287  if(m_loop_isSet){ isObjectUpdated = true; break;}
288  if(m_keyboard_iambic_isSet){ isObjectUpdated = true; break;}
289  if(m_dot_key_isSet){ isObjectUpdated = true; break;}
290  if(m_dot_key_modifiers_isSet){ isObjectUpdated = true; break;}
291  if(m_dash_key_isSet){ isObjectUpdated = true; break;}
292  if(m_dash_key_modifiers_isSet){ isObjectUpdated = true; break;}
293  }while(false);
294  return isObjectUpdated;
295 }
296 }
297 
virtual void fromJsonObject(QJsonObject &json) override
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual SWGCWKeyerSettings * fromJson(QString &jsonString) override
virtual QJsonObject * asJsonObject() override
void setKeyboardIambic(qint32 keyboard_iambic)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setSampleRate(qint32 sample_rate)
void setDashKeyModifiers(qint32 dash_key_modifiers)
virtual QString asJson() override
void setDotKeyModifiers(qint32 dot_key_modifiers)