Allow to enter empty values in PropertyFloatList and PropertyIntegerList - issue #2535

This commit is contained in:
Yorik van Havre 2016-04-29 23:00:11 -03:00
parent 9ee892eb35
commit a38a78f6d6
No known key found for this signature in database
GPG Key ID: 4C7794EF1595A813
2 changed files with 27 additions and 23 deletions

View File

@ -1151,9 +1151,10 @@ public:
QStringList lines; QStringList lines;
if (edit) { if (edit) {
QString inputText = edit->toPlainText(); QString inputText = edit->toPlainText();
if (!inputText.isEmpty()) // let pass empty input, regardless of the type, so user can void the value
lines = inputText.split(QString::fromLatin1("\n")); lines = inputText.split(QString::fromLatin1("\n"));
} }
if (!lines.isEmpty()) {
if (type == 1) { // floats if (type == 1) { // floats
bool ok; bool ok;
int line=1; int line=1;
@ -1176,7 +1177,7 @@ public:
} }
} }
} }
}
QDialog::accept(); QDialog::accept();
} }
}; };

View File

@ -2091,7 +2091,6 @@ QVariant PropertyFloatListItem::toString(const QVariant& prop) const
list.append(QLatin1String("...")); list.append(QLatin1String("..."));
} }
QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(","))); QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(",")));
return QVariant(text); return QVariant(text);
} }
@ -2120,6 +2119,8 @@ void PropertyFloatListItem::setValue(const QVariant& value)
str << *it << ","; str << *it << ",";
} }
str << "]"; str << "]";
if (data == QString::fromUtf8("[,]"))
data = QString::fromUtf8("[]");
setPropertyValue(data); setPropertyValue(data);
} }
@ -2193,6 +2194,8 @@ void PropertyIntegerListItem::setValue(const QVariant& value)
str << *it << ","; str << *it << ",";
} }
str << "]"; str << "]";
if (data == QString::fromUtf8("[,]"))
data = QString::fromUtf8("[]");
setPropertyValue(data); setPropertyValue(data);
} }