Changeset View
Changeset View
Standalone View
Standalone View
src/ksortablelist.h
Show All 18 Lines | |||||
19 | 19 | | |||
20 | #ifndef KSORTABLELIST_H | 20 | #ifndef KSORTABLELIST_H | ||
21 | #define KSORTABLELIST_H | 21 | #define KSORTABLELIST_H | ||
22 | 22 | | |||
23 | #include <kcompletion_export.h> | 23 | #include <kcompletion_export.h> | ||
24 | 24 | | |||
25 | #include <QPair> | 25 | #include <QPair> | ||
26 | #include <QList> | 26 | #include <QList> | ||
27 | #include <algorithm> | ||||
27 | 28 | | |||
28 | /** | 29 | /** | ||
29 | * \class KSortableItem ksortablelist.h <KSortableItem> | 30 | * \class KSortableItem ksortablelist.h <KSortableItem> | ||
30 | * | 31 | * | ||
31 | * KSortableItem is a QPair that provides several operators | 32 | * KSortableItem is a QPair that provides several operators | ||
32 | * for sorting. | 33 | * for sorting. | ||
33 | * @see KSortableList | 34 | * @see KSortableList | ||
34 | */ | 35 | */ | ||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Line(s) | 191 | { | |||
191 | return QList<KSortableItem<T, Key> >::operator[](i).value(); | 192 | return QList<KSortableItem<T, Key> >::operator[](i).value(); | ||
192 | } | 193 | } | ||
193 | 194 | | |||
194 | /** | 195 | /** | ||
195 | * Sorts the KSortableItems. | 196 | * Sorts the KSortableItems. | ||
196 | */ | 197 | */ | ||
197 | void sort() | 198 | void sort() | ||
198 | { | 199 | { | ||
199 | qSort(*this); | 200 | std::sort(this->begin(), this->end()); | ||
200 | } | 201 | } | ||
201 | }; | 202 | }; | ||
202 | 203 | | |||
203 | #ifdef Q_CC_MSVC | 204 | #ifdef Q_CC_MSVC | ||
204 | template<class T, class K> | 205 | template<class T, class K> | ||
205 | inline uint qHash(const KSortableItem<T, K> &) | 206 | inline uint qHash(const KSortableItem<T, K> &) | ||
206 | { | 207 | { | ||
207 | Q_ASSERT(0); | 208 | Q_ASSERT(0); | ||
208 | return 0; | 209 | return 0; | ||
209 | } | 210 | } | ||
210 | #endif | 211 | #endif | ||
211 | 212 | | |||
212 | #endif // KSORTABLELIST_H | 213 | #endif // KSORTABLELIST_H |