KSortableList Class

template <typename T, typename Key = int> class KSortableList

KSortableList is a QList which associates a key with each item in the list. This key is used for sorting when calling sort(). More...

Header: #include <KSortableList>
CMake: find_package(KF6 REQUIRED COMPONENTS Completion)
target_link_libraries(mytarget PRIVATE KF6::Completion)
Inherits: QList

Public Functions

void insert(Key i, const T &t)
void sort()
T &operator[](Key i)
const T &operator[](Key i) const

Detailed Description

This allows to temporarily calculate a key and use it for sorting, without having to store that key in the items, or calculate that key many times for the same item during sorting if that calculation is expensive.

Member Function Documentation

void KSortableList::insert(Key i, const T &t)

Insert a KSortableItem with the given values.

i the first value

t the second value

void KSortableList::sort()

Sorts the KSortableItems.

T &KSortableList::operator[](Key i)

Returns the first value of the KSortableItem at the given position.

const T &KSortableList::operator[](Key i) const

Returns the first value of the KSortableItem at the given position.