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:
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,8 @@ class ModelItem {
|
||||
|
||||
private:
|
||||
ModelItemValues m_values;
|
||||
|
||||
QVariant getValueButReplaceZeroValueWithEmptyString(const int role) const;
|
||||
};
|
||||
|
||||
#endif // MODELITEM_H
|
||||
|
||||
Reference in New Issue
Block a user