Reorganise Dolphin's sorting code

Review Request #108386 - Created Jan. 13, 2013 and submitted

Frank Reininghaus
At the moment, the sorting code is more complicated than it needs to be:

1. Some functionality that is provided by Qt and/or the STL is duplicated. It seems that it had been overlooked that all Qt/STL functions that require a 'lessThan' comparison function can in fact be used even if the comparison function is a member of a class with the trick

class KFileItemModelLessThan
    KFileItemModelLessThan(const KFileItemModel* model) :

    bool operator()(const KFileItemModel::ItemData* a, const KFileItemModel::ItemData* b) const
        return m_model->lessThan(a, b);

    const KFileItemModel* m_model;

and then:

KFileItemModelLessThan lessThan(model);

2. KFileItemModel-specific code and the parallel sorting implementation are mixed in the same file.

With this commit [1], I try to resolve these issues. People who need parallel sorting in other contexts where comparisons are expensive and reentrant can now just use the templates in kfileitemmodelsortalgorithm.h. Moreover, it's very easy now to replace the sort function by std::sort, std::stable_sort and others for benchmarking and other experiments.

Does anyone see a problem with this approach or a bug that I might have introduced accidentally? If not, I'll push that to master in a few days.

[1] In fact, I did it in three smaller steps:
Sorting still works OK.
Mark Gaiser
Emmanuel Pescosta
Commit Hook
Frank Reininghaus
Review request changed

Status: Closed (submitted)