summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qabstractitemdelegate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/itemviews/qabstractitemdelegate.cpp')
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index d532221092..3268fda2fc 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -58,6 +58,7 @@
#endif
#include <qapplication.h>
#include <qvalidator.h>
+#include <qjsonvalue.h>
#include <private/qtextengine_p.h>
#include <private/qabstractitemdelegate_p.h>
@@ -585,18 +586,26 @@ QString QAbstractItemDelegatePrivate::textForRole(Qt::ItemDataRole role, const Q
case QVariant::Time:
text = locale.toString(value.toTime(), formatType);
break;
- case QVariant::DateTime: {
- const QDateTime dateTime = value.toDateTime();
- text = locale.toString(dateTime.date(), formatType)
- + QLatin1Char(' ')
- + locale.toString(dateTime.time(), formatType);
- break; }
- default:
- text = value.toString();
+ case QVariant::DateTime:
+ text = locale.toString(value.toDateTime(), formatType);
+ break;
+ default: {
+ if (value.canConvert<QJsonValue>()) {
+ const QJsonValue val = value.toJsonValue();
+ if (val.isBool())
+ text = QVariant(val.toBool()).toString();
+ else if (val.isDouble())
+ text = locale.toString(val.toDouble(), 'g', precision);
+ else if (val.isString())
+ text = val.toString();
+ } else {
+ text = value.toString();
+ }
if (role == Qt::DisplayRole)
text.replace(QLatin1Char('\n'), QChar::LineSeparator);
break;
}
+ }
return text;
}