Changeset View
Changeset View
Standalone View
Standalone View
krusader/Panel/PanelView/krsort.cpp
Show First 20 Lines • Show All 304 Lines • ▼ Show 20 Line(s) | |||||
305 | void Sorter::addItem(FileItem *fileitem, bool isDummy, int idx, QVariant customData) | 305 | void Sorter::addItem(FileItem *fileitem, bool isDummy, int idx, QVariant customData) | ||
306 | { | 306 | { | ||
307 | _itemStore << SortProps(fileitem, _viewProperties->sortColumn, _viewProperties, isDummy, !descending(), idx, std::move(customData)); | 307 | _itemStore << SortProps(fileitem, _viewProperties->sortColumn, _viewProperties, isDummy, !descending(), idx, std::move(customData)); | ||
308 | _items << &_itemStore.last(); | 308 | _items << &_itemStore.last(); | ||
309 | } | 309 | } | ||
310 | 310 | | |||
311 | void Sorter::sort() | 311 | void Sorter::sort() | ||
312 | { | 312 | { | ||
313 | qStableSort(_items.begin(), _items.end(), | 313 | std::stable_sort(_items.begin(), _items.end(), | ||
314 | descending() ? _greaterThanFunc : _lessThanFunc); | 314 | descending() ? _greaterThanFunc : _lessThanFunc); | ||
315 | } | 315 | } | ||
316 | 316 | | |||
317 | int Sorter::insertIndex(FileItem *fileitem, bool isDummy, QVariant customData) | 317 | int Sorter::insertIndex(FileItem *fileitem, bool isDummy, QVariant customData) | ||
318 | { | 318 | { | ||
319 | SortProps props(fileitem, _viewProperties->sortColumn, _viewProperties, isDummy, !descending(), -1, std::move(customData)); | 319 | SortProps props(fileitem, _viewProperties->sortColumn, _viewProperties, isDummy, !descending(), -1, std::move(customData)); | ||
320 | const QVector<SortProps*>::iterator it = | 320 | const QVector<SortProps*>::iterator it = | ||
321 | qLowerBound(_items.begin(), _items.end(), &props, | 321 | std::lower_bound(_items.begin(), _items.end(), &props, | ||
322 | descending() ? _greaterThanFunc : _lessThanFunc); | 322 | descending() ? _greaterThanFunc : _lessThanFunc); | ||
323 | 323 | | |||
324 | if(it != _items.end()) | 324 | if(it != _items.end()) | ||
325 | return _items.indexOf((*it)); | 325 | return _items.indexOf((*it)); | ||
326 | else | 326 | else | ||
327 | return _items.count(); | 327 | return _items.count(); | ||
328 | } | 328 | } | ||
329 | 329 | | |||
330 | bool Sorter::descending() const | 330 | bool Sorter::descending() const | ||
331 | { | 331 | { | ||
332 | return _viewProperties->sortOptions & KrViewProperties::Descending; | 332 | return _viewProperties->sortOptions & KrViewProperties::Descending; | ||
333 | } | 333 | } | ||
334 | 334 | | |||
335 | } // namespace KrSort | 335 | } // namespace KrSort |