m_groups.clear();
+ if (m_naturalSorting) {
+ // Natural sorting of items can be very slow. However, it becomes much
+ // faster if the input sequence is already mostly sorted. Therefore, we
+ // first sort 'newItems' according to the QStrings returned by
+ // KFileItem::text() using QString::operator<(), which is quite fast.
+ parallelMergeSort(newItems.begin(), newItems.end(), nameLessThan, QThread::idealThreadCount());
+ }
+
sort(newItems.begin(), newItems.end());
#ifdef KFILEITEMMODEL_DEBUG
QHash<QByteArray, QVariant> retrieveData(const KFileItem& item, const ItemData* parent) const;
+ /**
+ * @return True if \a a has a KFileItem whose text is 'less than' the one
+ * of \a b according to QString::operator<(const QString&).
+ */
+ static bool nameLessThan(const ItemData* a, const ItemData* b);
+
/**
* @return True if the item-data \a a should be ordered before the item-data
* \b. The item-data may have different parent-items.
friend class DolphinPart; // Accesses m_dirLister
};
+inline bool KFileItemModel::nameLessThan(const ItemData* a, const ItemData* b)
+{
+ return a->item.text() < b->item.text();
+}
+
+
inline bool KFileItemModel::isChildItem(int index) const
{
if (m_itemData.at(index)->parent) {