diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-04-27 16:02:10 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-04-27 16:02:10 (GMT) |
commit | 74df18dda93f154339af1137e8676337233b4a61 (patch) | |
tree | c10364de0d828a2b397bcb46408ff3d7bf66b331 /Swift/QtUI/QtFormWidget.cpp | |
parent | 9e57b31133edad6a543da05aca54ee94d589b090 (diff) | |
download | swift-contrib-74df18dda93f154339af1137e8676337233b4a61.zip swift-contrib-74df18dda93f154339af1137e8676337233b4a61.tar.bz2 |
Don't allow editing of AdHoc result forms.
Resolves: #1090
Diffstat (limited to 'Swift/QtUI/QtFormWidget.cpp')
-rw-r--r-- | Swift/QtUI/QtFormWidget.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Swift/QtUI/QtFormWidget.cpp b/Swift/QtUI/QtFormWidget.cpp index 2df8d7f..158bc9d 100644 --- a/Swift/QtUI/QtFormWidget.cpp +++ b/Swift/QtUI/QtFormWidget.cpp @@ -241,4 +241,34 @@ Form::ref QtFormWidget::getCompletedForm() { return result; } +template<class T> void QtFormWidget::setEnabled(QWidget* rawWidget, bool editable) { + T* widget = qobject_cast<T*>(rawWidget); + if (widget) { + widget->setEnabled(editable); + } +} + +template<class T> void QtFormWidget::setEditable(QWidget* rawWidget, bool editable) { + T* widget = qobject_cast<T*>(rawWidget); + if (widget) { + widget->setReadOnly(!editable); + } +} + +void QtFormWidget::setEditable(bool editable) { + if (!form_) { + return; + } + foreach (boost::shared_ptr<FormField> field, form_->getFields()) { + QWidget* widget = NULL; + if (field) { + widget = fields_[field->getName()]; + } + setEnabled<QCheckBox>(widget, editable); + setEnabled<QListWidget>(widget, editable); + setEditable<QTextEdit>(widget, editable); + setEditable<QLineEdit>(widget, editable); + } +} + } |