Beter whitespace

master
Jos van den Oever 2018-05-13 02:27:16 +02:00
parent c87339ed6a
commit 4dba74acbd
4 changed files with 11 additions and 9 deletions

View File

@ -815,10 +815,10 @@ QVariant TimeSeries::cos(int row) const
bool TimeSeries::setCos(int row, const QVariant& value)
{
bool set = false;
if (!value.canConvert(qMetaTypeId<float>())) {
return false;
}
bool set = false;
set = time_series_set_data_cos(m_d, row, value.value<float>());
if (set) {
QModelIndex index = createIndex(row, 0, row);
@ -836,10 +836,10 @@ QVariant TimeSeries::sin(int row) const
bool TimeSeries::setSin(int row, const QVariant& value)
{
bool set = false;
if (!value.canConvert(qMetaTypeId<float>())) {
return false;
}
bool set = false;
set = time_series_set_data_sin(m_d, row, value.value<float>());
if (set) {
QModelIndex index = createIndex(row, 0, row);
@ -857,10 +857,10 @@ QVariant TimeSeries::time(int row) const
bool TimeSeries::setTime(int row, const QVariant& value)
{
bool set = false;
if (!value.canConvert(qMetaTypeId<float>())) {
return false;
}
bool set = false;
set = time_series_set_data_time(m_d, row, value.value<float>());
if (set) {
QModelIndex index = createIndex(row, 0, row);

View File

@ -162,6 +162,7 @@ void writeModelGetterSetter(QTextStream& cpp, const QString& index,
cpp << QString("bool %1::set%2(const QModelIndex& index, const QVariant& value)\n{\n")
.arg(o.name, upperInitial(ip.name));
}
cpp << QString(" if (!value.canConvert(qMetaTypeId<%1>())) {\n return false;\n }\n").arg(ip.type.name);
cpp << " bool set = false;\n";
if (ip.optional) {
QString test = "!value.isValid()";
@ -173,10 +174,9 @@ void writeModelGetterSetter(QTextStream& cpp, const QString& index,
.arg(lcname, snakeCase(ip.name), idx) << endl;
cpp << " } else\n";
}
cpp << QString(" if (!value.canConvert(qMetaTypeId<%1>())) {\n return false;\n }\n").arg(ip.type.name);
QString val = QString("value.value<%1>()").arg(ip.type.name);
if (ip.type.isComplex()) {
cpp << QString(" const %1 s = %2;").arg(ip.type.name, val);
cpp << QString(" const %1 s = %2;\n").arg(ip.type.name, val);
if (ip.type.name == "QString") {
val = "s.utf16(), s.length()";
} else {

View File

@ -110,11 +110,12 @@ QVariant Persons::userName(int row) const
bool Persons::setUserName(int row, const QVariant& value)
{
bool set = false;
if (!value.canConvert(qMetaTypeId<QString>())) {
return false;
}
const QString s = value.value<QString>(); set = persons_set_data_user_name(m_d, row, s.utf16(), s.length());
bool set = false;
const QString s = value.value<QString>();
set = persons_set_data_user_name(m_d, row, s.utf16(), s.length());
if (set) {
QModelIndex index = createIndex(row, 0, row);
emit dataChanged(index, index);

View File

@ -126,11 +126,12 @@ QVariant Persons::userName(const QModelIndex& index) const
bool Persons::setUserName(const QModelIndex& index, const QVariant& value)
{
bool set = false;
if (!value.canConvert(qMetaTypeId<QString>())) {
return false;
}
const QString s = value.value<QString>(); set = persons_set_data_user_name(m_d, index.internalId(), s.utf16(), s.length());
bool set = false;
const QString s = value.value<QString>();
set = persons_set_data_user_name(m_d, index.internalId(), s.utf16(), s.length());
if (set) {
emit dataChanged(index, index);
}