- // Sort items locally in their respective categories with the category
- // purpose lessThan
- LessThan categoryLessThan(d->proxyModel,
- LessThan::CategoryPurpose);
-
- foreach (const QString &key, d->categories)
- {
- QModelIndexList &indexList = d->categoriesIndexes[key];
-
- qStableSort(indexList.begin(), indexList.end(), categoryLessThan);
- }
-
- d->lastIndex = d->categoriesIndexes[d->categories[d->categories.count() - 1]][d->categoriesIndexes[d->categories[d->categories.count() - 1]].count() - 1];
-
- // Finally, fill data information of items situation. This will help when
- // trying to compute an item place in the viewport
- int i = 0; // position relative to the category beginning
- int j = 0; // number of elements before current
- foreach (const QString &key, d->categories)
- {
- foreach (const QModelIndex &index, d->categoriesIndexes[key])
- {
- struct Private::ElementInfo &elementInfo = d->elementsInfo[index];
-
- elementInfo.relativeOffsetToCategory = i;
-
- d->elementDictionary.insert(d->proxyModel->index(j, 0),
- d->proxyModel->mapFromSource(index));
-
- d->invertedElementDictionary.insert(d->proxyModel->mapFromSource(index),
- d->proxyModel->index(j, 0));
-
- i++;
- j++;
- }
-
- i = 0;
- }
-