}
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()
{
}
-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()
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();
* 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.
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)
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)
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)),
| QItemSelectionModel::Current);
}
-void DolphinView::openContextMenu(const QPoint& pos, const KUrl& url)
+void DolphinView::openContextMenu(const QPoint& pos)
{
KFileItem* item = 0;
item = fileItem(index);
}
- emit requestContextMenu(item, url);
+ emit requestContextMenu(item, url());
}
void DolphinView::dropUrls(const KUrl::List& urls,
/**
* 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