mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Fix a couple of crashes. First was to avoid problem caused by KIconLoader::global()->theme() returning 0 (which according to the API, it can do). Second was to fix the 'lastIndex' member of KCategorizedView::Private being out of date when used. According to the comments this member existed as an optimization. However in the only function where it is used, scrollbar updates are also performed. This will be several orders of magnitude more expensive than the 3 constant-time operations on Qt containers (QHash,QList) which the optimization avoided. So I removed the 'lastIndex' member and moved the calculation to where the data is needed.
svn path=/trunk/KDE/kdebase/apps/; revision=691574
This commit is contained in:
parent
117899b07c
commit
e678566575
3 changed files with 5 additions and 6 deletions
|
@ -199,8 +199,8 @@ void DolphinItemCategorizer::drawCategory(const QModelIndex &index,
|
|||
QPainter *painter) const
|
||||
{
|
||||
QRect starRect = option.rect;
|
||||
int iconSize = KIconLoader::global()->theme()->defaultSize(K3Icon::Small);
|
||||
|
||||
int iconSize = KIconLoader::global()->currentSize(K3Icon::Small);
|
||||
const QString category = categoryForItem(index, sortRole);
|
||||
|
||||
QColor color = option.palette.color(QPalette::Text);
|
||||
|
@ -366,7 +366,7 @@ void DolphinItemCategorizer::drawCategory(const QModelIndex &index,
|
|||
|
||||
int DolphinItemCategorizer::categoryHeight(const QStyleOption &option) const
|
||||
{
|
||||
int iconSize = KIconLoader::global()->theme()->defaultSize(K3Icon::Small);
|
||||
int iconSize = KIconLoader::global()->currentSize(K3Icon::Small);
|
||||
|
||||
return qMax(option.fontMetrics.height() + (iconSize / 4) * 2 + 2, iconSize + (iconSize / 4) * 2 + 2) /* 2 gradient */;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,6 @@ KCategorizedView::Private::Private(KCategorizedView *listView)
|
|||
, isDragging(false)
|
||||
, dragLeftViewport(false)
|
||||
, proxyModel(0)
|
||||
, lastIndex(QModelIndex())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -388,6 +387,9 @@ void KCategorizedView::Private::drawNewCategory(const QModelIndex &index,
|
|||
|
||||
void KCategorizedView::Private::updateScrollbars()
|
||||
{
|
||||
// find the last index in the last category
|
||||
QModelIndex lastIndex = categoriesIndexes.isEmpty() ? QModelIndex() : categoriesIndexes[categories.last()].last();
|
||||
|
||||
int lastItemBottom = cachedRectIndex(lastIndex).top() +
|
||||
listView->spacing() + (listView->gridSize().isEmpty() ? 0 : listView->gridSize().height()) - listView->viewport()->height();
|
||||
|
||||
|
@ -1243,8 +1245,6 @@ void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent,
|
|||
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
|
||||
|
|
|
@ -154,7 +154,6 @@ public:
|
|||
// Attributes for speed reasons
|
||||
KSortFilterProxyModel *proxyModel;
|
||||
QModelIndexList sourceModelIndexList; // in source model
|
||||
QModelIndex lastIndex;
|
||||
};
|
||||
|
||||
#endif // KCATEGORIZEDVIEW_P_H
|
||||
|
|
Loading…
Reference in a new issue