]> cloud.milkyroute.net Git - dolphin.git/commitdiff
when requesting a context menu provide a URL for the viewport, because in the column...
authorPeter Penz <peter.penz19@gmail.com>
Tue, 19 Jun 2007 18:58:30 +0000 (18:58 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 19 Jun 2007 18:58:30 +0000 (18:58 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=677704

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

index 32a8553f9c6bfd65efc1feb36f1f5fff61bd7607..3251f56c2ee5842cdac23898a33766144ce223fc 100644 (file)
@@ -64,6 +64,7 @@ protected:
     virtual void dropEvent(QDropEvent* event);
     virtual void mousePressEvent(QMouseEvent* event);
     virtual void paintEvent(QPaintEvent* event);
+    virtual void contextMenuEvent(QContextMenuEvent* event);
 
 private:
     /** Used by ColumnWidget::setActive(). */
@@ -215,6 +216,12 @@ void ColumnWidget::paintEvent(QPaintEvent* event)
     }
 }
 
+void ColumnWidget::contextMenuEvent(QContextMenuEvent* event)
+{
+    QListView::contextMenuEvent(event);
+    m_columnView->m_controller->triggerContextMenuRequest(event->pos(), m_url);
+}
+
 void ColumnWidget::activate()
 {
     const QColor bgColor = KColorScheme(KColorScheme::View).background();
@@ -338,12 +345,6 @@ QAbstractItemView* DolphinColumnView::createColumn(const QModelIndex& index)
     return view;
 }
 
-void DolphinColumnView::contextMenuEvent(QContextMenuEvent* event)
-{
-    QColumnView::contextMenuEvent(event);
-    m_controller->triggerContextMenuRequest(event->pos());
-}
-
 void DolphinColumnView::mousePressEvent(QMouseEvent* event)
 {
     m_controller->triggerActivation();
index 266e5ee976b76e89f977a21c3a1f421f07c5e256..06f9b887fc3f8c9650ce76d4e5293e068f44fdef 100644 (file)
@@ -41,7 +41,6 @@ public:
 
 protected:
     virtual QAbstractItemView* createColumn(const QModelIndex& index);
-    virtual void contextMenuEvent(QContextMenuEvent* event);
     virtual void mousePressEvent(QMouseEvent* event);
     virtual void dragEnterEvent(QDragEnterEvent* event);
     virtual void dropEvent(QDropEvent* event);
index 1831c15c33670dca59475ee9341d427d229d122c..413152522f5fa509f708aff401ee5e211107f8a0 100644 (file)
@@ -34,10 +34,10 @@ DolphinController::~DolphinController()
 {
 }
 
-void DolphinController::triggerContextMenuRequest(const QPoint& pos)
+void DolphinController::triggerContextMenuRequest(const QPoint& pos, const KUrl& url)
 {
     emit activated();
-    emit requestContextMenu(pos);
+    emit requestContextMenu(pos, url);
 }
 
 void DolphinController::triggerActivation()
index aa0eab22fabbcc4d7fd5cafa0317dcc401a53af5..c45c559806e353eb1edf52308d8069a488214a65 100644 (file)
@@ -60,7 +60,7 @@ public:
     inline void setUrl(const KUrl& url);
     inline const KUrl& url() const;
 
-    void triggerContextMenuRequest(const QPoint& pos);
+    void triggerContextMenuRequest(const QPoint& pos, const KUrl& url);
 
     void triggerActivation();
 
@@ -116,8 +116,10 @@ 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);
+    void requestContextMenu(const QPoint& pos, const KUrl& url);
 
     /**
      * Is emitted if the view has been activated by e. g. a mouse click.
index ba82fc901ae1f8dabc750684ea74aadab4bac3ad..3672fe18c0209271d72165606899214f40634b8b 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->triggerContextMenuRequest(event->pos(), m_controller->url());
 }
 
 void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
index d2bac6b13a15e6ffe027c8e4bb3e532f81f7dc9e..4a3bdfbbe0ce5adfc979748311b8af61b4d2e6f4 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->triggerContextMenuRequest(event->pos(), m_controller->url());
 }
 
 void DolphinIconsView::mousePressEvent(QMouseEvent* event)
index acd51d7d7bc50c556ef1cd52872218b0af8cd7f6..f3758ce25675947ad2b07d8f820deca1136105f2 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&)),
-            this, SLOT(openContextMenu(const QPoint&)));
+    connect(m_controller, SIGNAL(requestContextMenu(const QPoint&, const KUrl&)),
+            this, SLOT(openContextMenu(const QPoint&, const KUrl&)));
     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)),
@@ -697,7 +697,7 @@ void DolphinView::changeSelection(const KFileItemList& selection)
                                          | QItemSelectionModel::Current);
 }
 
-void DolphinView::openContextMenu(const QPoint& pos)
+void DolphinView::openContextMenu(const QPoint& pos, const KUrl& url)
 {
     KFileItem* item = 0;
 
@@ -706,7 +706,7 @@ void DolphinView::openContextMenu(const QPoint& pos)
         item = fileItem(index);
     }
 
-    emit requestContextMenu(item, url());
+    emit requestContextMenu(item, url);
 }
 
 void DolphinView::dropUrls(const KUrl::List& urls,
index 1a240be7a12b1997089076b62a68cbc54d2ca104..0d8ffea190d3154203387abd44f289d2bd2b5824 100644 (file)
@@ -413,9 +413,12 @@ 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.
+     * 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).
      */
-    void openContextMenu(const QPoint& pos);
+    void openContextMenu(const QPoint& pos, const KUrl& url);
 
     /**
      * Drops the URLs \a urls to the index \a index. \a source