diff options
-rw-r--r-- | src/corelib/kernel/qabstractitemmodel.cpp | 17 | ||||
-rw-r--r-- | src/corelib/kernel/qabstractitemmodel_p.h | 1 | ||||
-rw-r--r-- | src/gui/itemviews/qtablewidget.cpp | 20 | ||||
-rw-r--r-- | src/gui/itemviews/qtablewidget_p.h | 1 | ||||
-rw-r--r-- | src/gui/itemviews/qtreewidget.cpp | 25 | ||||
-rw-r--r-- | src/gui/itemviews/qtreewidget_p.h | 1 |
6 files changed, 20 insertions, 45 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 935c0aa..0a84ddb 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -467,6 +467,23 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel() return qEmptyModel(); } +bool QAbstractItemModelPrivate::canConvertToDouble(const QVariant &value) +{ + switch (value.type()) { + case QVariant::Bool: + case QVariant::Int: + case QVariant::UInt: + case QVariant::LongLong: + case QVariant::ULongLong: + case QVariant::Double: + case QVariant::Char: + return true; + default: + return false; + } + return false; +} + void QAbstractItemModelPrivate::removePersistentIndexData(QPersistentModelIndexData *data) { if (data->index.isValid()) { diff --git a/src/corelib/kernel/qabstractitemmodel_p.h b/src/corelib/kernel/qabstractitemmodel_p.h index 27f1b28..70c35cb 100644 --- a/src/corelib/kernel/qabstractitemmodel_p.h +++ b/src/corelib/kernel/qabstractitemmodel_p.h @@ -89,6 +89,7 @@ public: void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last); void columnsRemoved(const QModelIndex &parent, int first, int last); static QAbstractItemModel *staticEmptyModel(); + static bool canConvertToDouble(const QVariant &value); inline QModelIndex createIndex(int row, int column, void *data = 0) const { return q_func()->createIndex(row, column, data); diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/gui/itemviews/qtablewidget.cpp index 8cb2e55..072e435 100644 --- a/src/gui/itemviews/qtablewidget.cpp +++ b/src/gui/itemviews/qtablewidget.cpp @@ -530,24 +530,6 @@ void QTableModel::sort(int column, Qt::SortOrder order) emit layoutChanged(); } -bool QTableModel::canConvertToDouble(const QVariant &value) -{ - switch (value.type()) { - case QVariant::Bool: - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::Double: - case QVariant::Char: - return true; - default: - return false; - } - return false; -} - - /* \internal @@ -1410,7 +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 (QTableModel::canConvertToDouble(v1) && QTableModel::canConvertToDouble(v2)) + if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) return v1.toDouble() < v2.toDouble(); return v1.toString() < v2.toString(); } diff --git a/src/gui/itemviews/qtablewidget_p.h b/src/gui/itemviews/qtablewidget_p.h index 2e1dab6..d8bfcc5 100644 --- a/src/gui/itemviews/qtablewidget_p.h +++ b/src/gui/itemviews/qtablewidget_p.h @@ -144,7 +144,6 @@ public: const QPair<QTableWidgetItem*,int> &right); static bool itemGreaterThan(const QPair<QTableWidgetItem*,int> &left, const QPair<QTableWidgetItem*,int> &right); - static bool canConvertToDouble(const QVariant &value); void ensureSorted(int column, Qt::SortOrder order, int start, int end); QVector<QTableWidgetItem*> columnItems(int column) const; diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 1c87580..5604f8d 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -695,29 +695,6 @@ bool QTreeModel::itemGreaterThan(const QPair<QTreeWidgetItem*,int> &left, } /*! - \internal - - Returns true if the type of the variant \a value - can be casted as double. -*/ -bool QTreeModel::canConvertToDouble(const QVariant &value) -{ - switch (value.type()) { - case QVariant::Bool: - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::Double: - case QVariant::Char: - return true; - default: - return false; - } - return false; -} - -/*! \internal */ QList<QTreeWidgetItem*>::iterator QTreeModel::sortedInsertionIterator( @@ -1812,7 +1789,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 (QTreeModel::canConvertToDouble(v1) && QTreeModel::canConvertToDouble(v2)) + if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) return v1.toDouble() < v2.toDouble(); return v1.toString() < v2.toString(); } diff --git a/src/gui/itemviews/qtreewidget_p.h b/src/gui/itemviews/qtreewidget_p.h index 96f734d..a089cf5 100644 --- a/src/gui/itemviews/qtreewidget_p.h +++ b/src/gui/itemviews/qtreewidget_p.h @@ -116,7 +116,6 @@ public: const QPair<QTreeWidgetItem*,int> &right); static bool itemGreaterThan(const QPair<QTreeWidgetItem*,int> &left, const QPair<QTreeWidgetItem*,int> &right); - static bool canConvertToDouble(const QVariant &value); static QList<QTreeWidgetItem*>::iterator sortedInsertionIterator( const QList<QTreeWidgetItem*>::iterator &begin, const QList<QTreeWidgetItem*>::iterator &end, |