mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 15:13:41 +02:00
combo boxes ported to new form code
This commit is contained in:
parent
dd47b7afc6
commit
63e6839142
2 changed files with 20 additions and 0 deletions
|
@ -220,6 +220,7 @@ QScriptValue WindowScriptingInterface::doGetNonBlockingFormResult(QScriptValue a
|
|||
if (_formResult == QDialog::Accepted) {
|
||||
int e = -1;
|
||||
int d = -1;
|
||||
int c = -1;
|
||||
for (int i = 0; i < _form.property("length").toInt32(); ++i) {
|
||||
QScriptValue item = _form.property(i);
|
||||
QScriptValue value = item.property("value");
|
||||
|
@ -235,6 +236,10 @@ QScriptValue WindowScriptingInterface::doGetNonBlockingFormResult(QScriptValue a
|
|||
value = _directories.at(d)->property("path").toString();
|
||||
item.setProperty("directory", value);
|
||||
_form.setProperty(i, item);
|
||||
} else if (item.property("options").isArray()) {
|
||||
c += 1;
|
||||
item.setProperty("value", _combos.at(c)->currentText());
|
||||
_form.setProperty(i, item);
|
||||
} else {
|
||||
e += 1;
|
||||
bool ok = true;
|
||||
|
@ -288,6 +293,7 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal
|
|||
if (result == QDialog::Accepted) {
|
||||
int e = -1;
|
||||
int d = -1;
|
||||
int c = -1;
|
||||
for (int i = 0; i < form.property("length").toInt32(); ++i) {
|
||||
QScriptValue item = form.property(i);
|
||||
QScriptValue value = item.property("value");
|
||||
|
@ -303,6 +309,10 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal
|
|||
value = _directories.at(d)->property("path").toString();
|
||||
item.setProperty("directory", value);
|
||||
form.setProperty(i, item);
|
||||
} else if (item.property("options").isArray()) {
|
||||
c += 1;
|
||||
item.setProperty("value", _combos.at(c)->currentText());
|
||||
_form.setProperty(i, item);
|
||||
} else {
|
||||
e += 1;
|
||||
bool ok = true;
|
||||
|
@ -405,6 +415,15 @@ QDialog* WindowScriptingInterface::createForm(const QString& title, QScriptValue
|
|||
|
||||
} else if (item.property("type").toString() == "header") {
|
||||
formLayout->addRow(new QLabel(item.property("label").toString()));
|
||||
} else if (item.property("options").isArray()) {
|
||||
QComboBox* combo = new QComboBox();
|
||||
combo->setMinimumWidth(200);
|
||||
QStringList options = item.property("options").toVariant().toStringList();
|
||||
for (QStringList::const_iterator it = options.begin(); it != options.end(); it += 1) {
|
||||
combo->addItem(*it);
|
||||
}
|
||||
_combos.push_back(combo);
|
||||
formLayout->addRow(new QLabel(item.property("label").toString()), combo);
|
||||
} else {
|
||||
QLineEdit* edit = new QLineEdit(item.property("value").toString());
|
||||
edit->setMinimumWidth(200);
|
||||
|
|
|
@ -71,6 +71,7 @@ private:
|
|||
QScriptValue _form;
|
||||
bool _nonBlockingFormActive;
|
||||
int _formResult;
|
||||
QVector<QComboBox*> _combos;
|
||||
QVector<QLineEdit*> _edits;
|
||||
QVector<QPushButton*> _directories;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue