summaryrefslogtreecommitdiff
path: root/src/bookmarks/bookmarkstoolbar.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-04-28 00:04:20 +0200
committerAndrea Diamantini <adjam7@gmail.com>2011-04-28 00:04:20 +0200
commit339f1fe47ae8f6dcd799a674cdab65693a810d5f (patch)
treeaac7c2cbae17b06f87d419022ae918b85d3a5c27 /src/bookmarks/bookmarkstoolbar.cpp
parentLetting rekonq URL popup behaves as Chrome's and Firefox4 ones (diff)
downloadrekonq-339f1fe47ae8f6dcd799a674cdab65693a810d5f.tar.xz
- A new option to set/unset the current bookmark bar folder in the context menu
- Fix drag and drop with a custom folder - Fix a regression which affects BK bar drag and drop (5a53d2bf91dd) Patch by Yoann Laissus, reviewed by me :)
Diffstat (limited to 'src/bookmarks/bookmarkstoolbar.cpp')
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp86
1 files changed, 47 insertions, 39 deletions
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp
index 3667503b..57d56fff 100644
--- a/src/bookmarks/bookmarkstoolbar.cpp
+++ b/src/bookmarks/bookmarkstoolbar.cpp
@@ -223,11 +223,12 @@ void BookmarkToolBar::hideMenu()
bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event)
{
- if (m_currentMenu && m_currentMenu->isVisible() && !m_currentMenu->rect().contains(m_currentMenu->mapFromGlobal(QCursor::pos())))
+ // To switch root folders as in a menubar
+ if (m_currentMenu && m_currentMenu->isVisible() && event->type() == QEvent::MouseMove
+ && !m_currentMenu->rect().contains(m_currentMenu->mapFromGlobal(QCursor::pos())))
{
- // To switch root folders as in a menubar
KBookmarkActionMenu* act = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(toolBar()->mapFromGlobal(QCursor::pos())));
- if (event->type() == QEvent::MouseMove && act && m_currentMenu && act->menu() != m_currentMenu)
+ if (act && act->menu() != m_currentMenu)
{
m_currentMenu->hide();
QPoint pos = toolBar()->mapToGlobal(toolBar()->widgetForAction(act)->pos());
@@ -237,9 +238,6 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event)
return QObject::eventFilter(watched, event);
}
- if (watched != toolBar())
- return QObject::eventFilter(watched, event);
-
switch (event->type())
{
case QEvent::Show:
@@ -342,7 +340,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event)
{
QDropEvent *dropEvent = static_cast<QDropEvent*>(event);
KBookmark bookmark;
- KBookmarkGroup root = rApp->bookmarkProvider()->rootGroup();
+ KBookmarkGroup root = rApp->bookmarkProvider()->bookmarkManager()->toolbar();
if (dropEvent->mimeData()->hasFormat("application/rekonq-bookmark"))
{
@@ -428,49 +426,59 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event)
}
break;
- case QEvent::MouseButtonPress: // drag handling
- {
- QPoint pos = toolBar()->mapFromGlobal(QCursor::pos());
- KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(pos));
+ default:
+ break;
+ }
- if (action)
+ // These events need to be handled only for Bookmark actions and not the bar
+ if (watched != toolBar())
+ {
+ switch (event->type())
+ {
+ case QEvent::MouseButtonPress: // drag handling
{
- m_dragAction = toolBar()->actionAt(pos);
- m_startDragPos = pos;
+ QPoint pos = toolBar()->mapFromGlobal(QCursor::pos());
+ KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(pos));
+
+ if (action)
+ {
+ m_dragAction = toolBar()->actionAt(pos);
+ m_startDragPos = pos;
- // The menu is displayed only when the mouse button is released
- if (action->bookmark().isGroup())
- return true;
+ // The menu is displayed only when the mouse button is released
+ if (action->bookmark().isGroup())
+ return true;
+ }
}
- }
- break;
+ break;
- case QEvent::MouseMove:
- {
- int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength();
- if (!m_currentMenu && distance >= QApplication::startDragDistance())
+ case QEvent::MouseMove:
{
- startDrag();
+ int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength();
+ if (!m_currentMenu && distance >= QApplication::startDragDistance())
+ {
+ startDrag();
+ }
}
- }
- break;
-
- case QEvent::MouseButtonRelease:
- {
- int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength();
- KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(m_startDragPos));
+ break;
- if (action && action->bookmark().isGroup() && distance < QApplication::startDragDistance())
+ case QEvent::MouseButtonRelease:
{
- KBookmarkActionMenu *menu = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(m_startDragPos));
- QPoint actionPos = toolBar()->mapToGlobal(toolBar()->widgetForAction(menu)->pos());
- menu->menu()->popup(QPoint(actionPos.x(), actionPos.y() + toolBar()->widgetForAction(menu)->height()));
+ int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength();
+ KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(m_startDragPos));
+
+ if (action && action->bookmark().isGroup() && distance < QApplication::startDragDistance())
+ {
+ KBookmarkActionMenu *menu = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(m_startDragPos));
+ QPoint actionPos = toolBar()->mapToGlobal(toolBar()->widgetForAction(menu)->pos());
+ menu->menu()->popup(QPoint(actionPos.x(), actionPos.y() + toolBar()->widgetForAction(menu)->height()));
+ }
}
- }
- break;
+ break;
- default:
- break;
+ default:
+ break;
+ }
}
return QObject::eventFilter(watched, event);