diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-17 12:51:37 +0200 |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-17 12:52:07 +0200 |
commit | dc2771eb57702a0daf5164b0f9ad569c9fe0e5ba (patch) | |
tree | 7de557caf7a4d7bfb52aaf68572f81c0cdba01da /src/gui | |
parent | 213e2c937b667dba7e4996b0857ae5791c6d5fc8 (diff) | |
download | qt4-tools-dc2771eb57702a0daf5164b0f9ad569c9fe0e5ba.tar.gz |
Better handling of qreal with QVariant
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/itemviews/qlistwidget.cpp | 4 | ||||
-rw-r--r-- | src/gui/itemviews/qstyleditemdelegate.cpp | 2 | ||||
-rw-r--r-- | src/gui/itemviews/qtablewidget.cpp | 4 | ||||
-rw-r--r-- | src/gui/itemviews/qtreewidget.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qcssparser.cpp | 2 |
5 files changed, 5 insertions, 11 deletions
diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index 2792bbd0e8..a1f8288497 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -708,9 +708,7 @@ QVariant QListWidgetItem::data(int role) const bool QListWidgetItem::operator<(const QListWidgetItem &other) const { const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); - if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) - return v1.toDouble() < v2.toDouble(); - return v1.toString() < v2.toString(); + return QAbstractItemModelPrivate::variantLessThan(v1, v2); } #ifndef QT_NO_DATASTREAM diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index f7c7d12604..a8ea218fdc 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -270,7 +270,7 @@ QString QStyledItemDelegate::displayText(const QVariant &value, const QLocale& l switch (value.userType()) { case QMetaType::Float: case QVariant::Double: - text = locale.toString(value.toDouble()); + text = locale.toString(value.toReal()); break; case QVariant::Int: case QVariant::LongLong: diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/gui/itemviews/qtablewidget.cpp index fea81e56fc..de8ebde3cc 100644 --- a/src/gui/itemviews/qtablewidget.cpp +++ b/src/gui/itemviews/qtablewidget.cpp @@ -1392,9 +1392,7 @@ QVariant QTableWidgetItem::data(int role) const bool QTableWidgetItem::operator<(const QTableWidgetItem &other) const { const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); - if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) - return v1.toDouble() < v2.toDouble(); - return v1.toString() < v2.toString(); + return QAbstractItemModelPrivate::variantLessThan(v1, v2); } #ifndef QT_NO_DATASTREAM diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 1ab69df1a2..f48e393eeb 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -1790,9 +1790,7 @@ bool QTreeWidgetItem::operator<(const QTreeWidgetItem &other) const int column = view ? view->sortColumn() : 0; const QVariant v1 = data(column, Qt::DisplayRole); const QVariant v2 = other.data(column, Qt::DisplayRole); - if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) - return v1.toDouble() < v2.toDouble(); - return v1.toString() < v2.toString(); + return QAbstractItemModelPrivate::variantLessThan(v1, v2); } #ifndef QT_NO_DATASTREAM diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 181ec7e8cc..f11104f136 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -793,7 +793,7 @@ static BrushData parseBrushValue(const Value &v, const QPalette &pal) if (attr.compare(QLatin1String("spread"), Qt::CaseInsensitive) == 0) { spread = spreads.indexOf(value.variant.toString()); } else { - vars[attr] = value.variant.toString().toDouble(); + vars[attr] = value.variant.toReal(); } } parser.skipSpace(); |