From 03f8c373c51e03c076290550d8011b558e757406 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Mon, 2 Dec 2013 23:14:20 +0100 Subject: 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 --- src/kitemviews/kstandarditemlistwidget.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index 302150fec..acdf839ac 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -99,11 +99,18 @@ QSizeF KStandardItemListWidgetInformant::itemSizeHint(int index, const KItemList // to show all roles without horizontal clipping. qreal maximumRequiredWidth = 0.0; - const QHash 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& visibleRoles = view->visibleRoles(); + const bool showOnlyTextRole = (visibleRoles.count() == 1) && (visibleRoles.first() == "text"); + + if (showOnlyTextRole) { + maximumRequiredWidth = option.fontMetrics.width(itemText(index, view)); + } else { + const QHash 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; -- cgit v1.3 From c4c999d2431285a8c49f43130773ae562dc06b8b Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Tue, 3 Dec 2013 19:00:28 +0100 Subject: Fix Bug 328262 - rename bug if you cancel when folder already exists Only connect the renamingFailed signal if there is no item with the new name in the model yet. BUG: 328262 FIXED-IN: 4.11.5 REVIEW: 114228 --- src/views/dolphinview.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 20bc9f522..db9d8d22f 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1492,7 +1492,9 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con } KonqOperations* op = KonqOperations::renameV2(this, oldUrl, newName); - if (op) { + if (op && !newNameExistsAlready) { + // Only connect the renamingFailed signal if there is no item with the new name + // in the model yet, see bug 328262. connect(op, SIGNAL(renamingFailed(KUrl,KUrl)), SLOT(slotRenamingFailed(KUrl,KUrl))); } } -- cgit v1.3