mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 16:31:21 +00:00
Lazy-load the item data also in Compact View
The recent changes which prevent that all data for each item are saved in a QHash already when loading the folder (see https://git.reviewboard.kde.org/r/112725/), which save both memory and time, do not work yet in Compact View, because KItemListWidgetInformant::itemSizeHint() calls the model's data(int) method for every item, which then initializes the hash. This patch prevents that by accessing the file name directly if only the "Name" is shown in the view, just like it's done in Icons View. REVIEW: 113849
This commit is contained in:
parent
0c76683c36
commit
3dc7c849c0
|
@ -99,12 +99,19 @@ QSizeF KStandardItemListWidgetInformant::itemSizeHint(int index, const KItemList
|
||||||
// to show all roles without horizontal clipping.
|
// to show all roles without horizontal clipping.
|
||||||
qreal maximumRequiredWidth = 0.0;
|
qreal maximumRequiredWidth = 0.0;
|
||||||
|
|
||||||
|
const QList<QByteArray>& visibleRoles = view->visibleRoles();
|
||||||
|
const bool showOnlyTextRole = (visibleRoles.count() == 1) && (visibleRoles.first() == "text");
|
||||||
|
|
||||||
|
if (showOnlyTextRole) {
|
||||||
|
maximumRequiredWidth = option.fontMetrics.width(itemText(index, view));
|
||||||
|
} else {
|
||||||
const QHash<QByteArray, QVariant> values = view->model()->data(index);
|
const QHash<QByteArray, QVariant> values = view->model()->data(index);
|
||||||
foreach (const QByteArray& role, view->visibleRoles()) {
|
foreach (const QByteArray& role, view->visibleRoles()) {
|
||||||
const QString text = roleText(role, values);
|
const QString text = roleText(role, values);
|
||||||
const qreal requiredWidth = option.fontMetrics.width(text);
|
const qreal requiredWidth = option.fontMetrics.width(text);
|
||||||
maximumRequiredWidth = qMax(maximumRequiredWidth, requiredWidth);
|
maximumRequiredWidth = qMax(maximumRequiredWidth, requiredWidth);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qreal width = option.padding * 4 + option.iconSize + maximumRequiredWidth;
|
qreal width = option.padding * 4 + option.iconSize + maximumRequiredWidth;
|
||||||
const qreal maxWidth = option.maxTextSize.width();
|
const qreal maxWidth = option.maxTextSize.width();
|
||||||
|
|
Loading…
Reference in a new issue