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

List:       kde-commits
Subject:    KDE/kdebase/apps/plasma/applets/folderview
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2008-06-12 12:13:09
Message-ID: 1213272789.687251.10067.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 819860 by aseigo:

drop within a folderview.

p.s. bugzilla has all the wrong granularity in bug reports.

BUG:163597


 M  +27 -16    folderview.cpp  


--- trunk/KDE/kdebase/apps/plasma/applets/folderview/folderview.cpp #819859:819860
@@ -857,12 +857,27 @@
 void FolderView::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
 {
     const QModelIndex index = indexAt(event->pos());
+    QRectF dirtyRect = visualRect(m_hoveredIndex);
+    m_hoveredIndex = QModelIndex();
+
     if (index.isValid()) {
-        QRectF dirtyRect = visualRect(index) | visualRect(m_hoveredIndex);
-        m_hoveredIndex = index;
-        update(dirtyRect);
+        dirtyRect |= visualRect(index);
+        bool onOurself = false;
+
+        foreach (const QModelIndex &selected, m_selectionModel->selectedIndexes()) {
+            if (selected == index) {
+                onOurself = true;
+                break;
+            }
+        }
+
+        if (!onOurself) {
+            m_hoveredIndex = index;
+            dirtyRect |= visualRect(index);
+        }
     }
 
+    update(dirtyRect);
     event->accept();
 }
 
@@ -872,27 +887,23 @@
     // Normally we'd do this by checking if the source widget matches the target widget
     // in the drag and drop operation, but since two QGraphicsItems can be part of the
     // same widget, we can't use that method here.
-    if (!m_dragInProgress) {
-        KFileItem item;
-        const QModelIndex index = indexAt(event->pos());
-        if (index.isValid()) {
-            item = m_model->itemForIndex(index);
-            if (!item.acceptsDrops()) {
-                item = KFileItem();
-            }
+    KFileItem item;
+    if (m_hoveredIndex.isValid()) {
+        item = m_model->itemForIndex(m_hoveredIndex);
+        if (!item.acceptsDrops()) {
+            item = KFileItem();
         }
+    }
 
+    if (!m_dragInProgress || !item.isNull()) {
         QDropEvent ev(event->screenPos(), event->dropAction(), event->mimeData(),
                       event->buttons(), event->modifiers());
-        kDebug() << "dropping to" << m_url << "with" << view() << event->modifiers();
+        //kDebug() << "dropping to" << m_url << "with" << view() << event->modifiers();
         KonqOperations::doDrop(item, m_url, &ev, event->widget());
-        kDebug() << "all done!";
+        //kDebug() << "all done!";
         return;
     }
 
-    // ### We should check if the items were dropped on a child item that
-    //     accepts drops.
-
     // If we get to this point, the drag was started from within the applet,
     // so instead of moving/copying/linking the dropped URL's to the folder,
     // we'll move the items in the view.
[prev in list] [next in list] [prev in thread] [next in thread] 

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