]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistcontroller.cpp
Two clicks on file/folder to rename
[dolphin.git] / src / kitemviews / kitemlistcontroller.cpp
index a9ebf97af9a5e44336491ebd3b340ff754544d4f..753d7915d096a75d3789193c9224f0715deb105e 100644 (file)
@@ -583,6 +583,10 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
         // -> remember that the user pressed an item which had been selected already and
         //    clear the selection in mouseReleaseEvent(), unless the items are dragged.
         m_clearSelectionIfItemsAreNotDragged = true;
+
+        if (m_selectionManager->selectedItems().count() == 1 && m_view->isAboveText(m_pressedIndex, m_pressedMousePos)) {
+            emit selectedItemTextPressed(m_pressedIndex);
+        }
     }
 
     if (!shiftPressed) {
@@ -801,6 +805,22 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
         }
     }
 
+    if (event->button() & Qt::RightButton) {
+        m_selectionManager->clearSelection();
+        if (index >= 0) {
+            m_selectionManager->setSelected(index);
+            emit itemContextMenuRequested(index, event->screenPos());
+        } else {
+            const QRectF headerBounds = m_view->headerBoundaries();
+            if (headerBounds.contains(event->pos())) {
+                emit headerContextMenuRequested(event->screenPos());
+            } else {
+                emit viewContextMenuRequested(event->screenPos());
+            }
+        }
+        return true;
+    }
+
     bool emitItemActivated = !(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced) &&
                              (event->button() & Qt::LeftButton) &&
                              index >= 0 && index < m_model->count();
@@ -912,7 +932,7 @@ bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QT
         // Something has been dropped between two items.
         m_view->hideDropIndicator();
         emit aboveItemDropEvent(dropAboveIndex, event);
-    } else {
+    } else if (!event->mimeData()->hasFormat(m_model->blacklistItemDropEventMimeType())) {
         // Something has been dropped on an item or on an empty part of the view.
         emit itemDropEvent(m_view->itemAt(pos), event);
     }
@@ -1168,7 +1188,7 @@ void KItemListController::startDragging()
     const QPixmap pixmap = m_view->createDragPixmap(selectedItems);
     drag->setPixmap(pixmap);
 
-    const QPoint hotSpot(pixmap.width() / 2, 0);
+    const QPoint hotSpot((pixmap.width() / pixmap.devicePixelRatio()) / 2, 0);
     drag->setHotSpot(hotSpot);
 
     drag->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction, Qt::CopyAction);