From b92fe0b47d519da5fd55ba55ad0838e1ff69195c Mon Sep 17 00:00:00 2001 From: Richard Maudsley <richard.maudsley@isode.com> Date: Mon, 31 Mar 2014 14:25:20 +0100 Subject: Render results forms with multi-values correctly Change-Id: I3b3de9687e8f2f2f6d478a52ffd92e383bcd4b08 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); -- cgit v0.10.2-6-g49f6