From da92d338b73522158bd38b63ffca500854e49208 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 5 Sep 2016 13:25:32 -0300 Subject: [PATCH] Allow to edit PropertyLists directly in the property editor - fixes #2535,#2689 --- src/Gui/Widgets.cpp | 11 +++++++++++ src/Gui/Widgets.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 3016b24e04..9e3e3a7c67 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 097034a4e0..7de00fbeca 100644 --- a/src/Gui/Widgets.h +++ b/src/Gui/Widgets.h @@ -397,6 +397,7 @@ public: public Q_SLOTS: virtual void setText(const QString &); virtual void setButtonText (const QString &); + virtual void validateText (const QString &); Q_SIGNALS: void textChanged(const QString &);