diff options
author | J-P Nurmi <jpnurmi@gmail.com> | 2009-06-09 20:52:27 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-06-10 13:45:17 (GMT) |
commit | 3e2ee19553c2423e1e76264f3c3eb088cd31747a (patch) | |
tree | e35550582d42ce78f7a0f0110d1b7c88e6ddacdb /src/gui | |
parent | 09faf56a2e44b4dfa1b341ced75803100483834f (diff) | |
download | Qt-3e2ee19553c2423e1e76264f3c3eb088cd31747a.zip Qt-3e2ee19553c2423e1e76264f3c3eb088cd31747a.tar.gz Qt-3e2ee19553c2423e1e76264f3c3eb088cd31747a.tar.bz2 |
Made QListWidgetItem::operator<() check if the data is numerical when comparing.
Merge-request: 631
Reviewed-by: Olivier Goffart <ogoffart@trolltech.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/itemviews/qlistwidget.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index e1e509d..504908f 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -687,7 +687,10 @@ QVariant QListWidgetItem::data(int role) const */ bool QListWidgetItem::operator<(const QListWidgetItem &other) const { - return text() < other.text(); + 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(); } #ifndef QT_NO_DATASTREAM |