Commit e407be3a authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Merge branch 'development' of campcloud.informatik.tu-muenchen.de:berge/campvis into development

parents 779ab835 4e793774
......@@ -53,14 +53,9 @@ namespace campvis {
_combobox->addItems(sl);
dc->s_dataAdded.connect(this, &DataNamePropertyWidget::onDataAdded);
int idx = _combobox->findText(QString::fromStdString(property->getValue()));
if (idx != -1)
_combobox->setCurrentIndex(idx);
else
_combobox->setEditText(QString::fromStdString(property->getValue()));
setCurrentComboBoxText(QString::fromStdString(property->getValue()));
}
addWidget(_combobox);
connect(_combobox, SIGNAL(editTextChanged(const QString&)), this, SLOT(onTextChanged(const QString&)));
}
......@@ -80,13 +75,28 @@ namespace campvis {
void DataNamePropertyWidget::updateWidgetFromProperty() {
DataNameProperty* prop = static_cast<DataNameProperty*>(_property);
QString qs = QString::fromStdString(prop->getValue());
if (_lineEdit->text() != qs) {
if (prop->getAccessInfo() == DataNameProperty::READ) {
_combobox->blockSignals(true);
setCurrentComboBoxText(qs);
_combobox->blockSignals(false);
}
else if (_lineEdit->text() != qs) {
_lineEdit->blockSignals(true);
_lineEdit->setText(qs);
_lineEdit->blockSignals(false);
}
}
void DataNamePropertyWidget::setCurrentComboBoxText(const QString& text) {
int idx = _combobox->findText(text);
if (idx != -1)
_combobox->setCurrentIndex(idx);
else
_combobox->setEditText(text);
}
void DataNamePropertyWidget::onTextChanged(const QString& text) {
DataNameProperty* prop = static_cast<DataNameProperty*>(_property);
++_ignorePropertyUpdates;
......
......@@ -45,7 +45,7 @@ namespace campvis {
* Widget for a DataNameProperty
*/
class DataNamePropertyWidget : public AbstractPropertyWidget {
Q_OBJECT;
Q_OBJECT
public:
/**
......@@ -72,6 +72,16 @@ namespace campvis {
void onTextChanged(const QString& text);
private:
/**
* Set the combo box's current text to the provided value.
*
* If \c text can already be found in the combo box, the corresponding item is made active. Otherwise, \c text
* is set as the contents of the combo box's text edit.
*
* \param text text to be set in the combo box
*/
void setCurrentComboBoxText(const QString& text);
QLineEdit* _lineEdit;
QComboBox* _combobox;
DataContainer* _dc;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment