]> cloud.milkyroute.net Git - dolphin.git/commitdiff
don't pass a custom viewport URL to the context menu anymore, as this cannot work...
authorPeter Penz <peter.penz19@gmail.com>
Wed, 20 Jun 2007 20:48:36 +0000 (20:48 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 20 Jun 2007 20:48:36 +0000 (20:48 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=678175

src/dolphincolumnview.cpp
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphindetailsview.cpp
src/dolphiniconsview.cpp
src/dolphinview.cpp
src/dolphinview.h

index 2941cab87e4f2bb5108c7e6cd55506d3027bf64d..81337cb20c296bbecfba385e6b045aef1f09bc49 100644 (file)
@@ -231,8 +231,15 @@ void ColumnWidget::contextMenuEvent(QContextMenuEvent* event)
     }
 
     QListView::contextMenuEvent(event);
-    const QPoint pos = m_view->viewport()->mapFromGlobal(event->globalPos());
-    m_view->m_controller->triggerContextMenuRequest(pos, m_url);
+
+    const QModelIndex index = indexAt(event->pos());
+    const KUrl& navigatorUrl = m_view->m_controller->url();
+    if (index.isValid() || (m_url == navigatorUrl)) {
+        // Only open a context menu above an item or if the mouse is above
+        // the active column.
+        const QPoint pos = m_view->viewport()->mapFromGlobal(event->globalPos());
+        m_view->m_controller->triggerContextMenuRequest(pos);
+    }
 }
 
 void ColumnWidget::activate()
index 413152522f5fa509f708aff401ee5e211107f8a0..1831c15c33670dca59475ee9341d427d229d122c 100644 (file)
@@ -34,10 +34,10 @@ DolphinController::~DolphinController()
 {
 }
 
-void DolphinController::triggerContextMenuRequest(const QPoint& pos, const KUrl& url)
+void DolphinController::triggerContextMenuRequest(const QPoint& pos)
 {
     emit activated();
-    emit requestContextMenu(pos, url);
+    emit requestContextMenu(pos);
 }
 
 void DolphinController::triggerActivation()
index c45c559806e353eb1edf52308d8069a488214a65..aa0eab22fabbcc4d7fd5cafa0317dcc401a53af5 100644 (file)
@@ -60,7 +60,7 @@ public:
     inline void setUrl(const KUrl& url);
     inline const KUrl& url() const;
 
-    void triggerContextMenuRequest(const QPoint& pos, const KUrl& url);
+    void triggerContextMenuRequest(const QPoint& pos);
 
     void triggerActivation();
 
@@ -116,10 +116,8 @@ signals:
      *                  context menu should be opened. It is recommended
      *                  to get the corresponding model index from
      *                  this position.
-     * @param url       URL of the viewport, if there is no valid model
-     *                  index on the given position.
      */
-    void requestContextMenu(const QPoint& pos, const KUrl& url);
+    void requestContextMenu(const QPoint& pos);
 
     /**
      * Is emitted if the view has been activated by e. g. a mouse click.
index 3672fe18c0209271d72165606899214f40634b8b..ba82fc901ae1f8dabc750684ea74aadab4bac3ad 100644 (file)
@@ -150,7 +150,7 @@ QStyleOptionViewItem DolphinDetailsView::viewOptions() const
 void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
 {
     QTreeView::contextMenuEvent(event);
-    m_controller->triggerContextMenuRequest(event->pos(), m_controller->url());
+    m_controller->triggerContextMenuRequest(event->pos());
 }
 
 void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
index 4a3bdfbbe0ce5adfc979748311b8af61b4d2e6f4..d2bac6b13a15e6ffe027c8e4bb3e532f81f7dc9e 100644 (file)
@@ -103,7 +103,7 @@ QStyleOptionViewItem DolphinIconsView::viewOptions() const
 void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
 {
     KListView::contextMenuEvent(event);
-    m_controller->triggerContextMenuRequest(event->pos(), m_controller->url());
+    m_controller->triggerContextMenuRequest(event->pos());
 }
 
 void DolphinIconsView::mousePressEvent(QMouseEvent* event)
index eb702393ad306cd6720f6c0585097cdbb2f210be..4964010c52357f1664b24c5939524ddaf41d602c 100644 (file)
@@ -89,8 +89,8 @@ DolphinView::DolphinView(QWidget* parent,
 
     m_controller = new DolphinController(this);
     m_controller->setUrl(url);
-    connect(m_controller, SIGNAL(requestContextMenu(const QPoint&, const KUrl&)),
-            this, SLOT(openContextMenu(const QPoint&, const KUrl&)));
+    connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
+            this, SLOT(openContextMenu(const QPoint&)));
     connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const QModelIndex&, QWidget*)),
             this, SLOT(dropUrls(const KUrl::List&, const QModelIndex&, QWidget*)));
     connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
@@ -698,7 +698,7 @@ void DolphinView::changeSelection(const KFileItemList& selection)
                                          | QItemSelectionModel::Current);
 }
 
-void DolphinView::openContextMenu(const QPoint& pos, const KUrl& url)
+void DolphinView::openContextMenu(const QPoint& pos)
 {
     KFileItem* item = 0;
 
@@ -707,7 +707,7 @@ void DolphinView::openContextMenu(const QPoint& pos, const KUrl& url)
         item = fileItem(index);
     }
 
-    emit requestContextMenu(item, url);
+    emit requestContextMenu(item, url());
 }
 
 void DolphinView::dropUrls(const KUrl::List& urls,
index 0d8ffea190d3154203387abd44f289d2bd2b5824..1a240be7a12b1997089076b62a68cbc54d2ca104 100644 (file)
@@ -413,12 +413,9 @@ private slots:
     /**
      * Opens the context menu on position \a pos. The position
      * is used to check whether the context menu is related to an
-     * item or to the viewport. If the context menu should be
-     * opened on the viewport, the URL \a url should be taken
-     * as viewport URL (the viewport URL can be different from
-     * DolphinView::url() for e. g. the column view).
+     * item or to the viewport.
      */
-    void openContextMenu(const QPoint& pos, const KUrl& url);
+    void openContextMenu(const QPoint& pos);
 
     /**
      * Drops the URLs \a urls to the index \a index. \a source