summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-09-28 07:50:57 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-09-28 07:50:57 (GMT)
commitd5efab53e5c4dee50a55241e840a26814d115ad7 (patch)
tree54b598c2b0fdb6af975860047369f3c997b2d0e8 /Swift/QtUI
parent41854ebf8c3376d6ee430efe3a9fdd25610bb2f5 (diff)
downloadswift-d5efab53e5c4dee50a55241e840a26814d115ad7.zip
swift-d5efab53e5c4dee50a55241e840a26814d115ad7.tar.bz2
Select defaults correctly in form widget.
Resolves: #1002
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtFormWidget.cpp22
-rw-r--r--Swift/QtUI/QtMUCConfigurationWindow.cpp6
2 files changed, 15 insertions, 13 deletions
diff --git a/Swift/QtUI/QtFormWidget.cpp b/Swift/QtUI/QtFormWidget.cpp
index 050ff27..2df8d7f 100644
--- a/Swift/QtUI/QtFormWidget.cpp
+++ b/Swift/QtUI/QtFormWidget.cpp
@@ -13,6 +13,7 @@
#include <QTextEdit>
#include <QCheckBox>
#include <QScrollArea>
+#include <qdebug.h>
#include <Swift/QtUI/QtSwiftUtil.h>
#include <Swiften/Base/foreach.h>
@@ -53,22 +54,23 @@ QListWidget* QtFormWidget::createList(FormField::ref field) {
QListWidget* listWidget = new QListWidget(this);
listWidget->setSortingEnabled(false);
listWidget->setSelectionMode(boost::dynamic_pointer_cast<ListMultiFormField>(field) ? QAbstractItemView::MultiSelection : QAbstractItemView::SingleSelection);
- foreach (FormField::Option option, field->getOptions()) {
- listWidget->addItem(option.label.c_str());
- }
boost::shared_ptr<ListMultiFormField> listMultiField = boost::dynamic_pointer_cast<ListMultiFormField>(field);
boost::shared_ptr<ListSingleFormField> listSingleField = boost::dynamic_pointer_cast<ListSingleFormField>(field);
- for (int i = 0; i < listWidget->count(); i++) {
- QListWidgetItem* item = listWidget->item(i);
- bool selected = false;
+ std::vector<bool> selected;
+ foreach (FormField::Option option, field->getOptions()) {
+ listWidget->addItem(option.label.c_str());
if (listSingleField) {
- selected = (item->text() == QString(listSingleField->getValue().c_str()));
+ selected.push_back(option.value == listSingleField->getValue());
}
else if (listMultiField) {
- std::string text = Q2PSTRING(item->text());
- selected = (std::find(listMultiField->getValue().begin(), listMultiField->getValue().end(), text) != listMultiField->getValue().end());
+ std::string text = option.value;
+ selected.push_back(std::find(listMultiField->getValue().begin(), listMultiField->getValue().end(), text) != listMultiField->getValue().end());
}
- item->setSelected(selected);
+
+ }
+ for (int i = 0; i < listWidget->count(); i++) {
+ QListWidgetItem* item = listWidget->item(i);
+ item->setSelected(selected[i]);
}
return listWidget;
}
diff --git a/Swift/QtUI/QtMUCConfigurationWindow.cpp b/Swift/QtUI/QtMUCConfigurationWindow.cpp
index e6be9b7..a8dec2a 100644
--- a/Swift/QtUI/QtMUCConfigurationWindow.cpp
+++ b/Swift/QtUI/QtMUCConfigurationWindow.cpp
@@ -18,9 +18,9 @@ QtMUCConfigurationWindow::QtMUCConfigurationWindow(Form::ref form) {
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(2);
- QLabel* label = new QLabel(this);
- label->setText(tr("Room configuration"));
- layout->addWidget(label);
+ //QLabel* label = new QLabel(this);
+ //label->setText(tr("Room configuration"));
+ //layout->addWidget(label);
formWidget_ = NULL;
formWidget_ = new QtFormWidget(form, this);