+/**
+ * Helper class for KFileItemModel::sort().
+ */
+class KFileItemModelLessThan
+{
+public:
+ KFileItemModelLessThan(const KFileItemModel* model, const QCollator& collator) :
+ m_model(model),
+ m_collator(collator)
+ {
+ }
+
+ KFileItemModelLessThan(const KFileItemModelLessThan& other) :
+ m_model(other.m_model),
+ m_collator()
+ {
+ m_collator.setCaseSensitivity(other.m_collator.caseSensitivity());
+ m_collator.setIgnorePunctuation(other.m_collator.ignorePunctuation());
+ m_collator.setLocale(other.m_collator.locale());
+ m_collator.setNumericMode(other.m_collator.numericMode());
+ }
+
+ ~KFileItemModelLessThan() = default;
+ //We do not delete m_model as the pointer was passed from outside ant it will be deleted elsewhere.
+
+ KFileItemModelLessThan& operator=(const KFileItemModelLessThan& other)
+ {
+ m_model = other.m_model;
+ m_collator = other.m_collator;
+ return *this;
+ }
+
+ bool operator()(const KFileItemModel::ItemData* a, const KFileItemModel::ItemData* b) const
+ {
+ return m_model->lessThan(a, b, m_collator);
+ }
+
+private:
+ const KFileItemModel* m_model;
+ QCollator m_collator;
+};
+