History

- Edit -> Model List menu option - Combo items can be JS objects now, write a toString() function for each JS object to describe them

Thijs Wenker committed 12 years ago

Commit eed6e2e1 parent 36e78922 files · +172 −128Browse files

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

Unified · Split

interface/src/scripting/WindowScriptingInterface.cpp+21−7
@@ -265,7 +265,11 @@ QScriptValue WindowScriptingInterface::doPeekNonBlockingFormResult(QScriptValue · 264 unmodified lines
265 _form.setProperty(i, item);265 _form.setProperty(i, item);
266 } else if (item.property("options").isArray()) {266 } else if (item.property("options").isArray()) {
267 c += 1;267 c += 1;
268 item.setProperty("value", _combos.at(c)->currentText());268 item.setProperty("value",
269 _combos.at(c)->currentIndex() < item.property("options").property("length").toInt32() ?
270 item.property("options").property(_combos.at(c)->currentIndex()) :
271 array.engine()->undefinedValue()
272 );
269 _form.setProperty(i, item);273 _form.setProperty(i, item);
270 } else {274 } else {
271 e += 1;275 e += 1;
@@ -318,7 +322,11 @@ QScriptValue WindowScriptingInterface::doGetNonBlockingFormResult(QScriptValue a · 46 unmodified lines
318 _form.setProperty(i, item);322 _form.setProperty(i, item);
319 } else if (item.property("options").isArray()) {323 } else if (item.property("options").isArray()) {
320 c += 1;324 c += 1;
321 item.setProperty("value", _combos.at(c)->currentText());325 item.setProperty("value",
326 _combos.at(c)->currentIndex() < item.property("options").property("length").toInt32() ?
327 item.property("options").property(_combos.at(c)->currentIndex()) :
328 array.engine()->undefinedValue()
329 );
322 _form.setProperty(i, item);330 _form.setProperty(i, item);
323 } else {331 } else {
324 e += 1;332 e += 1;
@@ -349,6 +357,7 @@ QScriptValue WindowScriptingInterface::doGetNonBlockingFormResult(QScriptValue a · 24 unmodified lines
349 _form = QScriptValue();357 _form = QScriptValue();
350 _edits.clear();358 _edits.clear();
351 _directories.clear();359 _directories.clear();
360 _combos.clear();
352 361
353 array = _form;362 array = _form;
354 return (_formResult == QDialog::Accepted); 363 return (_formResult == QDialog::Accepted);
@@ -391,8 +400,12 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal · 36 unmodified lines
391 form.setProperty(i, item);400 form.setProperty(i, item);
392 } else if (item.property("options").isArray()) {401 } else if (item.property("options").isArray()) {
393 c += 1;402 c += 1;
394 item.setProperty("value", _combos.at(c)->currentText());403 item.setProperty("value",
395 _form.setProperty(i, item);404 _combos.at(c)->currentIndex() < item.property("options").property("length").toInt32() ?
405 item.property("options").property(_combos.at(c)->currentIndex()) :
406 form.engine()->undefinedValue()
407 );
408 form.setProperty(i, item);
396 } else {409 } else {
397 e += 1;410 e += 1;
398 bool ok = true;411 bool ok = true;
@@ -418,6 +431,7 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal · 19 unmodified lines
418 }431 }
419 432
420 delete editDialog;433 delete editDialog;
434 _combos.clear();
421 _edits.clear();435 _edits.clear();
422 _directories.clear();436 _directories.clear();
423 return (result == QDialog::Accepted);437 return (result == QDialog::Accepted);
@@ -498,9 +512,9 @@ QDialog* WindowScriptingInterface::createForm(const QString& title, QScriptValue · 74 unmodified lines
498 } else if (item.property("options").isArray()) {512 } else if (item.property("options").isArray()) {
499 QComboBox* combo = new QComboBox();513 QComboBox* combo = new QComboBox();
500 combo->setMinimumWidth(200);514 combo->setMinimumWidth(200);
501 QStringList options = item.property("options").toVariant().toStringList();515 qint32 options_count = item.property("options").property("length").toInt32();// .toJsonArray();
502 for (QStringList::const_iterator it = options.begin(); it != options.end(); it += 1) {516 for (qint32 i = 0; i < options_count; i++) {
503 combo->addItem(*it);517 combo->addItem(item.property("options").property(i).toString());
504 }518 }
505 _combos.push_back(combo);519 _combos.push_back(combo);
506 formLayout->addRow(new QLabel(item.property("label").toString()), combo);520 formLayout->addRow(new QLabel(item.property("label").toString()), combo);