]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphindetailsview.cpp
performance improvement when selecting items
[dolphin.git] / src / dolphindetailsview.cpp
index 08eef4307c57cf8d0c2ba3c2c3e7feb579dae833..501108c012419b27a3591b9de15e86608a9460a7 100644 (file)
@@ -252,7 +252,6 @@ void DolphinDetailsView::mouseMoveEvent(QMouseEvent* event)
             // case QTreeView does no selection at all, which is not the wanted behavior
             // in Dolphin -> select all items within the elastic band rectangle
             clearSelection();
-            setState(DragSelectingState);
 
             const int nameColumnWidth = header()->sectionSize(DolphinModel::Name);
             QRect selRect = elasticBandRect();
@@ -300,7 +299,6 @@ void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
 
     m_expandingTogglePressed = false;
     if (m_showElasticBand) {
-        setState(NoState);
         updateElasticBand();
         m_showElasticBand = false;
     }
@@ -308,7 +306,7 @@ void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
 
 void DolphinDetailsView::startDrag(Qt::DropActions supportedActions)
 {
-    DragAndDropHelper::startDrag(this, supportedActions);
+    DragAndDropHelper::startDrag(this, supportedActions, m_controller);
     m_showElasticBand = false;
 }
 
@@ -476,8 +474,8 @@ void DolphinDetailsView::setSelection(const QRect &rect, QItemSelectionModel::Se
         // Choose a sensible startIndex - a parentless index in the 
         // name column, as close to the top of the rect as we 
         // can find.
-        QRect normalisedRect = rect.normalized();
-        QModelIndex startIndex = QTreeView::indexAt(normalisedRect.topLeft());
+        const QRect normalizedRect = rect.normalized();
+        QModelIndex startIndex = QTreeView::indexAt(normalizedRect.topLeft());
         if (startIndex.isValid()) {
             while (startIndex.parent().isValid()) {
                 startIndex = startIndex.parent();
@@ -488,7 +486,7 @@ void DolphinDetailsView::setSelection(const QRect &rect, QItemSelectionModel::Se
         }
         startIndex = model()->index(startIndex.row(), KDirModel::Name);
         clearSelection();
-        setSelectionRecursive(startIndex, normalisedRect, command);
+        setSelectionRecursive(startIndex, normalizedRect, command);
     }
 }
 
@@ -756,6 +754,7 @@ void DolphinDetailsView::setSelectionRecursive(const QModelIndex& startIndex,
         return;
     }
     
+    QItemSelection selection;
     // rect is assumed to be in viewport coordinates and normalized.
     // Move down through the siblings of startIndex, exploring the children
     // of any expanded nodes.
@@ -772,18 +771,19 @@ void DolphinDetailsView::setSelectionRecursive(const QModelIndex& startIndex,
             }
         }
 
-        QRect itemContentRect = nameColumnRect(currIndex);
+        const QRect itemContentRect = nameColumnRect(currIndex);
         if (itemContentRect.top() > rect.bottom()) {
             // All remaining items will be below itemContentRect, so we may cull.
-            return;
+            break;
         }
 
         if (itemContentRect.intersects(rect)) {
-            selectionModel()->select(currIndex, QItemSelectionModel::Select);   
+            selection.select(currIndex, currIndex);
         }
 
         currIndex = belowIndex;
     } while (currIndex.isValid());
+    selectionModel()->select(selection,  QItemSelectionModel::Select);
 }
 
 #include "dolphindetailsview.moc"