Not displaying 0 values for int and double columns in table view, but still using a SpinBox delegate when editing.

This commit is contained in:
2026-02-10 11:52:35 +01:00
parent bdc8075324
commit f148ef9cba
7 changed files with 126 additions and 2 deletions

View File

@ -19,6 +19,13 @@ QVariant ModelItem::data(int role) const {
case JsonObjectRole:
return toJsonObject();
break;
case MembershipNumberRole:
case ShareAmountRole:
case Bidding1Role:
case Bidding2Role:
case Bidding3Role:
return getValueButReplaceZeroValueWithEmptyString(role);
break;
default:
return m_values.value(role);
}
@ -95,3 +102,12 @@ QJsonObject ModelItem::toJsonObject() const {
}
return itemObject;
}
QVariant ModelItem::getValueButReplaceZeroValueWithEmptyString(const int role) const {
QVariant localValue = m_values.value(role, QVariant());
if (localValue == 0) {
return QVariant();
} else {
return localValue;
}
}

View File

@ -20,6 +20,8 @@ class ModelItem {
private:
ModelItemValues m_values;
QVariant getValueButReplaceZeroValueWithEmptyString(const int role) const;
};
#endif // MODELITEM_H