[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdelibs] kdeui/itemviews: 1) Make the delegate work always on the model's index, do not go back to
From:       Andras Mantia <amantia () kde ! org>
Date:       2013-08-22 15:08:00
Message-ID: E1VCWUS-0007iJ-TL () scm ! kde ! org
[Download RAW message or body]

Git commit 7e60cb9c4887888f8676a1a7a10f3d911f369ae3 by Andras Mantia.
Committed on 22/08/2013 at 14:54.
Pushed by amantia into branch 'master'.

1) Make the delegate work always on the model's index, do not go back to the source \
index, if the model is a proxy (that idea fails anyway with a proxy chain) 2) If the \
option.rect is empty, don't create or update widgets 3) If the option.rect is not in \
the view's rectangle, do not create the widgets. This makes sure that only visible \
widgets are created.

M  +12   -12   kdeui/itemviews/kwidgetitemdelegatepool.cpp
M  +1    -1    kdeui/itemviews/kwidgetitemdelegatepool_p.h

http://commits.kde.org/kdelibs/7e60cb9c4887888f8676a1a7a10f3d911f369ae3

diff --git a/kdeui/itemviews/kwidgetitemdelegatepool.cpp \
b/kdeui/itemviews/kwidgetitemdelegatepool.cpp index 2ca52a0..8121c9c 100644
--- a/kdeui/itemviews/kwidgetitemdelegatepool.cpp
+++ b/kdeui/itemviews/kwidgetitemdelegatepool.cpp
@@ -86,7 +86,9 @@ KWidgetItemDelegatePool::~KWidgetItemDelegatePool()
 
 QList<QWidget*> KWidgetItemDelegatePool::findWidgets(const QPersistentModelIndex \
                &idx,
                                                      const QStyleOptionViewItem \
                &option,
-                                                     UpdateWidgetsEnum \
updateWidgets) const +                                                     \
UpdateWidgetsEnum updateWidgets, +                                                    \
bool includeNotVisible +                                                    ) const
 {
     QList<QWidget*> result;
 
@@ -94,13 +96,13 @@ QList<QWidget*> KWidgetItemDelegatePool::findWidgets(const \
QPersistentModelIndex  return result;
     }
 
-    QModelIndex index;
-    if (const QAbstractProxyModel *proxyModel = qobject_cast<const \
                QAbstractProxyModel*>(idx.model())) {
-        index = proxyModel->mapToSource(idx);
-    } else {
-        index = idx;
+    if (!includeNotVisible && option.rect.isEmpty()) {
+         return result;
     }
 
+    QModelIndex index = idx;
+
+
     if (!index.isValid()) {
         return result;
     }
@@ -108,6 +110,9 @@ QList<QWidget*> KWidgetItemDelegatePool::findWidgets(const \
QPersistentModelIndex  if (d->usedWidgets.contains(index)) {
         result = d->usedWidgets[index];
     } else {
+        if (!d->delegate->itemView()->rect().contains(option.rect))
+             return result;
+
         // ### KDE5 This sets a property on the delegate because we can't add an \
                argument to createItemWidgets
         d->delegate->setProperty("goya:creatingWidgetForIndex", \
QVariant::fromValue(index));  result = d->delegate->createItemWidgets();
@@ -142,12 +147,7 @@ QList<QWidget*> KWidgetItemDelegatePool::invalidIndexesWidgets() \
const  QList<QWidget*> result;
     foreach (QWidget *widget, d->widgetInIndex.keys()) {
         const QAbstractProxyModel *proxyModel = qobject_cast<const \
                QAbstractProxyModel*>(d->delegate->d->model);
-        QModelIndex index;
-        if (proxyModel) {
-            index = proxyModel->mapFromSource(d->widgetInIndex[widget]);
-        } else {
-            index = d->widgetInIndex[widget];
-        }
+        QModelIndex index = d->widgetInIndex[widget];
         if (!index.isValid()) {
             result << widget;
         }
diff --git a/kdeui/itemviews/kwidgetitemdelegatepool_p.h \
b/kdeui/itemviews/kwidgetitemdelegatepool_p.h index 46bd38b..f632d40 100644
--- a/kdeui/itemviews/kwidgetitemdelegatepool_p.h
+++ b/kdeui/itemviews/kwidgetitemdelegatepool_p.h
@@ -64,7 +64,7 @@ public:
       * @internal
       */
     QList<QWidget*> findWidgets(const QPersistentModelIndex &index, const \
                QStyleOptionViewItem &option,
-                                UpdateWidgetsEnum updateWidgets = UpdateWidgets) \
const; +                                UpdateWidgetsEnum updateWidgets = \
UpdateWidgets, bool includeNotVisible = false) const;  
     /**
       * @internal


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic