Changeset View
Changeset View
Standalone View
Standalone View
src/widget/tableview/kexitextformatter.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 123 | { | |||
---|---|---|---|---|---|
125 | if (!d->field || d->field->type() == KDbField::Text) { | 125 | if (!d->field || d->field->type() == KDbField::Text) { | ||
126 | return toStringForTextType(value, add, d->field, lengthExceeded); | 126 | return toStringForTextType(value, add, d->field, lengthExceeded); | ||
127 | } | 127 | } | ||
128 | 128 | | |||
129 | if (lengthExceeded) { | 129 | if (lengthExceeded) { | ||
130 | *lengthExceeded = false; | 130 | *lengthExceeded = false; | ||
131 | } | 131 | } | ||
132 | if (d->field->isIntegerType()) { | 132 | if (d->field->isIntegerType()) { | ||
133 | if (value.toInt() == 0) | 133 | if (!add.isEmpty() && value.toInt() == 0) | ||
134 | return add; //eat 0 | 134 | return add; //eat 0 | ||
135 | } | 135 | } | ||
136 | else if (d->field->isFPNumericType()) { | 136 | else if (d->field->isFPNumericType()) { | ||
137 | //! @todo precision! | 137 | //! @todo precision! | ||
138 | //! @todo support 'g' format | 138 | //! @todo support 'g' format | ||
139 | if (value.toDouble() == 0.0) { | 139 | if (value.toDouble() == 0.0) { | ||
140 | return add.isEmpty() ? QString::fromLatin1("0") : add; //eat 0 | 140 | return add.isEmpty() ? QString::fromLatin1("0") : add; //eat 0 | ||
141 | } | 141 | } | ||
Show All 19 Lines | 160 | return d->timeFormatter->toString( | |||
161 | value.toString().isEmpty() | 161 | value.toString().isEmpty() | ||
162 | ? QTime(99, 0, 0) //hack to avoid converting null variant to valid QTime(0,0,0) | 162 | ? QTime(99, 0, 0) //hack to avoid converting null variant to valid QTime(0,0,0) | ||
163 | : value.toTime()); | 163 | : value.toTime()); | ||
164 | case KDbField::DateTime: | 164 | case KDbField::DateTime: | ||
165 | if (value.toString().isEmpty()) | 165 | if (value.toString().isEmpty()) | ||
166 | return add; | 166 | return add; | ||
167 | return KexiDateTimeFormatter::toString( | 167 | return KexiDateTimeFormatter::toString( | ||
168 | *d->dateFormatter, *d->timeFormatter, value.toDateTime()); | 168 | *d->dateFormatter, *d->timeFormatter, value.toDateTime()); | ||
169 | case KDbField::BigInteger: | | |||
170 | if (value.toLongLong() == 0) | | |||
171 | return add; //eat 0 | | |||
172 | break; | | |||
173 | default: | 169 | default: | ||
174 | break; | 170 | break; | ||
175 | } | 171 | } | ||
176 | //default: text | 172 | //default: text | ||
177 | return toStringForTextType(value, add, d->field, lengthExceeded); | 173 | return toStringForTextType(value, add, d->field, lengthExceeded); | ||
178 | } | 174 | } | ||
179 | 175 | | |||
180 | QVariant KexiTextFormatter::fromString(const QString& text, bool *ok) const | 176 | QVariant KexiTextFormatter::fromString(const QString& text, bool *ok) const | ||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |