From 8f7c3619ec734bbf31ae81315a6548db9cbd19aa Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Wed, 4 Sep 2013 21:34:03 +0200 Subject: Try to avoid calling the model's data method if only "text" is needed Currently, KStandardItemListWidgetInformant::itemSizeHint() calls the model's data(int) method for every single item, but the full data is actually only needed for the size calculation in Compact View. In Details View, no data is needed at all to determine the size required for the item, and in Icons View, only the name is needed. This patch makes it possible for subclasses of KStandardItemListWidgetInformant to provide an alternative way to obtain the "text", and implements this in the subclass KFileItemListWidgetInformant. The final goal is to achieve that the QHash which contains all data for a file item is only created if it is really needed, e.g., because the view needs access to the data for displaying the item on the screen. REVIEW: 112253 --- src/kitemviews/kfileitemlistwidget.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/kitemviews/kfileitemlistwidget.cpp') diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index 3a7724134..688a4da08 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -18,6 +18,8 @@ ***************************************************************************/ #include "kfileitemlistwidget.h" +#include "kfileitemmodel.h" +#include "kitemlistview.h" #include #include @@ -35,6 +37,15 @@ KFileItemListWidgetInformant::~KFileItemListWidgetInformant() { } +QString KFileItemListWidgetInformant::itemText(int index, const KItemListView* view) const +{ + Q_ASSERT(qobject_cast(view->model())); + KFileItemModel* fileItemModel = static_cast(view->model()); + + const KFileItem item = fileItemModel->fileItem(index); + return item.text(); +} + QString KFileItemListWidgetInformant::roleText(const QByteArray& role, const QHash& values) const { -- cgit v1.3