summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-03-31 13:25:20 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-03-31 13:29:52 (GMT)
commitb92fe0b47d519da5fd55ba55ad0838e1ff69195c (patch)
treef0ef2e0c818309fdffbd3ad004ef940aacf8817f /Swift
parent723176efd7532edbce9a27a3433bb63186568327 (diff)
downloadswift-b92fe0b47d519da5fd55ba55ad0838e1ff69195c.zip
swift-b92fe0b47d519da5fd55ba55ad0838e1ff69195c.tar.bz2
Render results forms with multi-values correctly
Change-Id: I3b3de9687e8f2f2f6d478a52ffd92e383bcd4b08
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtFormWidget.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/Swift/QtUI/QtFormWidget.cpp b/Swift/QtUI/QtFormWidget.cpp
index 117696d..874c8a1 100644
--- a/Swift/QtUI/QtFormWidget.cpp
+++ b/Swift/QtUI/QtFormWidget.cpp
@@ -58,16 +58,23 @@ QListWidget* QtFormWidget::createList(FormField::ref field) {
listWidget->setSortingEnabled(false);
listWidget->setSelectionMode(field->getType() == FormField::ListMultiType ? QAbstractItemView::MultiSelection : QAbstractItemView::SingleSelection);
std::vector<bool> selected;
- foreach (FormField::Option option, field->getOptions()) {
- listWidget->addItem(option.label.c_str());
- if (field->getType() == FormField::ListSingleType) {
- selected.push_back(!field->getValues().empty() && option.value == field->getValues()[0]);
+ /* if this is an editable form, use the 'options' list, otherwise use the 'values' list */
+ if (form_->getType() != Form::FormType) {
+ foreach (const std::string& value, field->getValues()) {
+ listWidget->addItem(P2QSTRING(value));
+ selected.push_back(false);
}
- else if (field->getType() == FormField::ListMultiType) {
- std::string text = option.value;
- selected.push_back(std::find(field->getValues().begin(), field->getValues().end(), text) != field->getValues().end());
+ } else {
+ foreach (FormField::Option option, field->getOptions()) {
+ listWidget->addItem(option.label.c_str());
+ if (field->getType() == FormField::ListSingleType) {
+ selected.push_back(!field->getValues().empty() && option.value == field->getValues()[0]);
+ }
+ else if (field->getType() == FormField::ListMultiType) {
+ std::string text = option.value;
+ selected.push_back(std::find(field->getValues().begin(), field->getValues().end(), text) != field->getValues().end());
+ }
}
-
}
for (int i = 0; i < listWidget->count(); i++) {
QListWidgetItem* item = listWidget->item(i);