mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +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
92cb6b3a18
commit
03f8c373c5
|
@ -99,11 +99,18 @@ QSizeF KStandardItemListWidgetInformant::itemSizeHint(int index, const KItemList
|
|||
// to show all roles without horizontal clipping.
|
||||
qreal maximumRequiredWidth = 0.0;
|
||||
|
||||
const QHash<QByteArray, QVariant> values = view->model()->data(index);
|
||||
foreach (const QByteArray& role, view->visibleRoles()) {
|
||||
const QString text = roleText(role, values);
|
||||
const qreal requiredWidth = option.fontMetrics.width(text);
|
||||
maximumRequiredWidth = qMax(maximumRequiredWidth, requiredWidth);
|
||||
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);
|
||||
foreach (const QByteArray& role, view->visibleRoles()) {
|
||||
const QString text = roleText(role, values);
|
||||
const qreal requiredWidth = option.fontMetrics.width(text);
|
||||
maximumRequiredWidth = qMax(maximumRequiredWidth, requiredWidth);
|
||||
}
|
||||
}
|
||||
|
||||
qreal width = option.padding * 4 + option.iconSize + maximumRequiredWidth;
|
||||
|
|
Loading…
Reference in a new issue