stringpropertywidget.cpp 1.1 KB
Newer Older
schultezub's avatar
schultezub committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "stringpropertywidget.h"

namespace TUMVis {
    StringPropertyWidget::StringPropertyWidget(StringProperty* property, QWidget* parent /*= 0*/)
        : AbstractPropertyWidget(property, parent)
        , _lineEdit(0)
    {
        _lineEdit = new QLineEdit(QString::fromStdString(property->getValue()));
        
        addWidget(_lineEdit);

        connect(_lineEdit, SIGNAL(textChanged(const QString&)), this, SIGNAL(onTextChanged(const QString&)));
    }

    StringPropertyWidget::~StringPropertyWidget() {

    }

    void StringPropertyWidget::updateWidgetFromProperty() {
        StringProperty* prop = static_cast<StringProperty*>(_property);
        QString qs = QString::fromStdString(prop->getValue());
        if (_lineEdit->text() != qs) {
            _lineEdit->blockSignals(true);
            _lineEdit->setText(qs);
            _lineEdit->blockSignals(false);
        }
    }

    void StringPropertyWidget::onTextChanged(const QString& text) {
        StringProperty* prop = static_cast<StringProperty*>(_property);
        prop->setValue(text.toStdString());
    }
}