History

add checkbox support in scripting interface

Stojce Slavkovski committed 12 years ago

Commit 06da1bd1 parent 3f3e6ea4 files · +37 −11Browse files

Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 4 files). Show all

Unified · Split

interface/src/scripting/WindowScriptingInterface.cpp+26−0
@@ -248,6 +248,7 @@ QScriptValue WindowScriptingInterface::doPeekNonBlockingFormResult(QScriptValue · 247 unmodified lines
248248 int e = -1;
249249 int d = -1;
250250 int c = -1;
251+ int h = -1;
251252 for (int i = 0; i < _form.property("length").toInt32(); ++i) {
252253 QScriptValue item = _form.property(i);
253254 QScriptValue value = item.property("value");
@@ -271,6 +272,11 @@ QScriptValue WindowScriptingInterface::doPeekNonBlockingFormResult(QScriptValue · 17 unmodified lines
271272 array.engine()->undefinedValue()
272273 );
273274 _form.setProperty(i, item);
275+ } else if (item.property("type").toString() == "checkbox") {
276+ h++;
277+ value = _checks.at(h)->checkState() == Qt::Checked;
278+ item.setProperty("value", value);
279+ _form.setProperty(i, item);
274280 } else {
275281 e += 1;
276282 bool ok = true;
@@ -305,6 +311,7 @@ QScriptValue WindowScriptingInterface::doGetNonBlockingFormResult(QScriptValue a · 28 unmodified lines
305311 int e = -1;
306312 int d = -1;
307313 int c = -1;
314+ int h = -1;
308315 for (int i = 0; i < _form.property("length").toInt32(); ++i) {
309316 QScriptValue item = _form.property(i);
310317 QScriptValue value = item.property("value");
@@ -328,6 +335,11 @@ QScriptValue WindowScriptingInterface::doGetNonBlockingFormResult(QScriptValue a · 17 unmodified lines
328335 array.engine()->undefinedValue()
329336 );
330337 _form.setProperty(i, item);
338+ } else if (item.property("type").toString() == "checkbox") {
339+ h++;
340+ value = _checks.at(h)->checkState() == Qt::Checked;
341+ item.setProperty("value", value);
342+ _form.setProperty(i, item);
331343 } else {
332344 e += 1;
333345 bool ok = true;
@@ -358,6 +370,7 @@ QScriptValue WindowScriptingInterface::doGetNonBlockingFormResult(QScriptValue a · 24 unmodified lines
358370 _edits.clear();
359371 _directories.clear();
360372 _combos.clear();
373+ _checks.clear();
361374
362375 array = _form;
363376 return (_formResult == QDialog::Accepted);
@@ -383,6 +396,7 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal · 19 unmodified lines
383396 int e = -1;
384397 int d = -1;
385398 int c = -1;
399+ int h = -1;
386400 for (int i = 0; i < form.property("length").toInt32(); ++i) {
387401 QScriptValue item = form.property(i);
388402 QScriptValue value = item.property("value");
@@ -406,6 +420,11 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal · 17 unmodified lines
406420 form.engine()->undefinedValue()
407421 );
408422 form.setProperty(i, item);
423+ } else if (item.property("type").toString() == "checkbox") {
424+ h++;
425+ value = _checks.at(h)->checkState() == Qt::Checked;
426+ item.setProperty("value", value);
427+ form.setProperty(i, item);
409428 } else {
410429 e += 1;
411430 bool ok = true;
@@ -432,6 +451,7 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal · 20 unmodified lines
432451
433452 delete editDialog;
434453 _combos.clear();
454+ _checks.clear();
435455 _edits.clear();
436456 _directories.clear();
437457 return (result == QDialog::Accepted);
@@ -518,6 +538,12 @@ QDialog* WindowScriptingInterface::createForm(const QString& title, QScriptValue · 80 unmodified lines
518538 }
519539 _combos.push_back(combo);
520540 formLayout->addRow(new QLabel(item.property("label").toString()), combo);
541+ } else if (item.property("type").toString() == "checkbox") {
542+ QCheckBox* check = new QCheckBox();
543+ check->setTristate(false);
544+ check->setCheckState(item.property("value").toString() == "true" ? Qt::Checked : Qt::Unchecked);
545+ _checks.push_back(check);
546+ formLayout->addRow(new QLabel(item.property("label").toString()), check);
521547 } else {
522548 QLineEdit* edit = new QLineEdit(item.property("value").toString());
523549 edit->setMinimumWidth(200);