fix several bugs in LabelEditor to handle PropertyStringList
This commit is contained in:
@@ -1296,8 +1296,6 @@ LabelEditor::LabelEditor (QWidget * parent)
|
||||
lineEdit = new QLineEdit(this);
|
||||
layout->addWidget(lineEdit);
|
||||
|
||||
connect(lineEdit, SIGNAL(textChanged(const QString &)),
|
||||
this, SIGNAL(textChanged(const QString &)));
|
||||
connect(lineEdit, SIGNAL(textChanged(const QString &)),
|
||||
this, SLOT(validateText(const QString &)));
|
||||
|
||||
@@ -1331,8 +1329,7 @@ void LabelEditor::setText(const QString& s)
|
||||
{
|
||||
this->plainText = s;
|
||||
|
||||
QStringList list = this->plainText.split(QString::fromLatin1("\n"));
|
||||
QString text = QString::fromLatin1("[%1]").arg(list.join(QLatin1String(",")));
|
||||
QString text = QString::fromLatin1("[%1]").arg(this->plainText);
|
||||
lineEdit->setText(text);
|
||||
}
|
||||
|
||||
@@ -1353,10 +1350,7 @@ void LabelEditor::changeText()
|
||||
connect(buttonBox, SIGNAL(rejected()), &dlg, SLOT(reject()));
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
QString inputText = edit->toPlainText();
|
||||
this->plainText = inputText;
|
||||
|
||||
QStringList list = this->plainText.split(QString::fromLatin1("\n"));
|
||||
QString text = QString::fromLatin1("[%1]").arg(list.join(QLatin1String(",")));
|
||||
QString text = QString::fromLatin1("[%1]").arg(inputText);
|
||||
lineEdit->setText(text);
|
||||
}
|
||||
}
|
||||
@@ -1364,10 +1358,12 @@ void LabelEditor::changeText()
|
||||
/**
|
||||
* Validates if the input of the lineedit is a valid list.
|
||||
*/
|
||||
void LabelEditor::validateText(const QString& s)
|
||||
void LabelEditor::validateText(const QString& text)
|
||||
{
|
||||
if ( s.startsWith(QLatin1String("[")) && s.endsWith(QLatin1String("]")) )
|
||||
this->plainText = s.mid(1,s.size()-2).replace(QLatin1String(","),QLatin1String("\n"));
|
||||
if (text.startsWith(QLatin1String("[")) && text.endsWith(QLatin1String("]"))) {
|
||||
this->plainText = text.mid(1, text.size()-2);
|
||||
Q_EMIT textChanged(this->plainText);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2161,6 +2161,7 @@ QVariant PropertyStringListItem::toString(const QVariant& prop) const
|
||||
list = list.mid(0, 10);
|
||||
list.append(QLatin1String("..."));
|
||||
}
|
||||
|
||||
QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(",")));
|
||||
text.replace(QString::fromUtf8("'"),QString::fromUtf8("\\'"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user