diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-06-10 13:35:45 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-06-10 13:48:34 (GMT) |
commit | 188a4ab62c99dcb113cad1833a0701d84a886e65 (patch) | |
tree | dfa3fae07e5c714a85cb9ed178ec9b5889d0e24d | |
parent | 3e2ee19553c2423e1e76264f3c3eb088cd31747a (diff) | |
download | Qt-188a4ab62c99dcb113cad1833a0701d84a886e65.zip Qt-188a4ab62c99dcb113cad1833a0701d84a886e65.tar.gz Qt-188a4ab62c99dcb113cad1833a0701d84a886e65.tar.bz2 |
Internal documentation for QAbstractItemModelPrivate::canConvertToDouble
Also add QMetaType types as list or recognized numerical types
Reviewed-by: thierry
-rw-r--r-- | src/corelib/kernel/qabstractitemmodel.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 0a84ddb..6d6caf5 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -467,9 +467,17 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel() return qEmptyModel(); } +/*! + \internal + return true if \a value contains a numerical type + + This function is used by our Q{Tree,Widget,Table}WidgetModel classes to sort. + We cannot rely on QVariant::canConvert because this would take strings as double + and then not sort strings correctly +*/ bool QAbstractItemModelPrivate::canConvertToDouble(const QVariant &value) { - switch (value.type()) { + switch (value.userType()) { case QVariant::Bool: case QVariant::Int: case QVariant::UInt: @@ -477,6 +485,12 @@ bool QAbstractItemModelPrivate::canConvertToDouble(const QVariant &value) case QVariant::ULongLong: case QVariant::Double: case QVariant::Char: + case QMetaType::Float: + case QMetaType::Short: + case QMetaType::UShort: + case QMetaType::UChar: + case QMetaType::ULong: + case QMetaType::Long: return true; default: return false; |