diff options
Diffstat (limited to 'utils/themeeditor/gui/devicestate.cpp')
-rw-r--r-- | utils/themeeditor/gui/devicestate.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp index 12198f5138..8802bd5e87 100644 --- a/utils/themeeditor/gui/devicestate.cpp +++ b/utils/themeeditor/gui/devicestate.cpp | |||
@@ -30,7 +30,9 @@ | |||
30 | #include <QLabel> | 30 | #include <QLabel> |
31 | #include <QLineEdit> | 31 | #include <QLineEdit> |
32 | #include <QFormLayout> | 32 | #include <QFormLayout> |
33 | #include <QTime> | ||
33 | 34 | ||
35 | #include <cstdlib> | ||
34 | 36 | ||
35 | DeviceState::DeviceState(QWidget *parent) : | 37 | DeviceState::DeviceState(QWidget *parent) : |
36 | QWidget(parent), tabs(this) | 38 | QWidget(parent), tabs(this) |
@@ -227,6 +229,47 @@ QVariant DeviceState::data(QString tag, int paramCount, | |||
227 | else | 229 | else |
228 | return QVariant(); | 230 | return QVariant(); |
229 | } | 231 | } |
232 | else if(tag == "pc") | ||
233 | { | ||
234 | int secs = data("?pc").toInt(); | ||
235 | return secsToString(secs); | ||
236 | } | ||
237 | else if(tag == "pr") | ||
238 | { | ||
239 | int secs = data("?pt").toInt() - data("?pc").toInt(); | ||
240 | if(secs < 0) | ||
241 | secs = 0; | ||
242 | return secsToString(secs); | ||
243 | } | ||
244 | else if(tag == "pt") | ||
245 | { | ||
246 | int secs = data("?pt").toInt(); | ||
247 | return secsToString(secs); | ||
248 | } | ||
249 | else if(tag == "px") | ||
250 | { | ||
251 | int totalTime = data("?pt").toInt(); | ||
252 | int currentTime = data("?pc").toInt(); | ||
253 | return currentTime * 100 / totalTime; | ||
254 | } | ||
255 | else if(tag == "pS") | ||
256 | { | ||
257 | double threshhold = paramCount > 0 | ||
258 | ? std::atof(params[0].data.text) : 10; | ||
259 | if(data("?pc").toDouble() <= threshhold) | ||
260 | return true; | ||
261 | else | ||
262 | return false; | ||
263 | } | ||
264 | else if(tag == "pE") | ||
265 | { | ||
266 | double threshhold = paramCount > 0 | ||
267 | ? std::atof(params[0].data.text) : 10; | ||
268 | if(data("?pt").toDouble() - data("?pc").toDouble() <= threshhold) | ||
269 | return true; | ||
270 | else | ||
271 | return false; | ||
272 | } | ||
230 | 273 | ||
231 | QPair<InputType, QWidget*> found = | 274 | QPair<InputType, QWidget*> found = |
232 | inputs.value(tag, QPair<InputType, QWidget*>(Slide, 0)); | 275 | inputs.value(tag, QPair<InputType, QWidget*>(Slide, 0)); |
@@ -335,3 +378,40 @@ QString DeviceState::directory(QString path, int level) | |||
335 | index = 0; | 378 | index = 0; |
336 | return dirs[index]; | 379 | return dirs[index]; |
337 | } | 380 | } |
381 | |||
382 | QString DeviceState::secsToString(int secs) | ||
383 | { | ||
384 | int hours = 0; | ||
385 | int minutes = 0; | ||
386 | while(secs >= 60) | ||
387 | { | ||
388 | minutes++; | ||
389 | secs -= 60; | ||
390 | } | ||
391 | |||
392 | while(minutes >= 60) | ||
393 | { | ||
394 | hours++; | ||
395 | minutes -= 60; | ||
396 | } | ||
397 | |||
398 | QString retval; | ||
399 | |||
400 | if(hours > 0) | ||
401 | { | ||
402 | retval += QString::number(hours); | ||
403 | if(minutes < 10) | ||
404 | retval += ":0"; | ||
405 | else | ||
406 | retval += ":"; | ||
407 | } | ||
408 | |||
409 | retval += QString::number(minutes); | ||
410 | if(secs < 10) | ||
411 | retval += ":0"; | ||
412 | else | ||
413 | retval += ":"; | ||
414 | |||
415 | retval += QString::number(secs); | ||
416 | return retval; | ||
417 | } | ||