diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 3016b24e04a5..9e3e3a7c67f8 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -1197,6 +1197,8 @@ LabelEditor::LabelEditor (QWidget * parent) connect(lineEdit, SIGNAL(textChanged(const QString &)), this, SIGNAL(textChanged(const QString &))); + connect(lineEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(validateText(const QString &))); button = new QPushButton(QLatin1String("..."), this); button->setFixedWidth(2*button->fontMetrics().width(QLatin1String(" ... "))); @@ -1250,6 +1252,15 @@ void LabelEditor::changeText() } } +/** + * Validates if the input of the lineedit is a valid list. + */ +void LabelEditor::validateText(const QString& s) +{ + if ( s.startsWith(QString::fromUtf8("[")) && s.endsWith(QString::fromUtf8("]")) ) + this->plainText = s.mid(1,s.size()-2).replace(QString::fromUtf8(","),QString::fromUtf8("\n")); +} + /** * Sets the browse button's text to \a txt. */ diff --git a/src/Gui/Widgets.h b/src/Gui/Widgets.h index 097034a4e03e..7de00fbecaea 100644 --- a/src/Gui/Widgets.h +++ b/src/Gui/Widgets.h @@ -397,6 +397,7 @@ class GuiExport LabelEditor : public QWidget public Q_SLOTS: virtual void setText(const QString &); virtual void setButtonText (const QString &); + virtual void validateText (const QString &); Q_SIGNALS: void textChanged(const QString &);