diff options
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/bookmarkprovider.cpp | 21 | ||||
-rw-r--r-- | src/bookmarks/bookmarkprovider.h | 6 | ||||
-rw-r--r-- | src/bookmarks/bookmarkstoolbar.cpp | 16 | ||||
-rw-r--r-- | src/bookmarks/bookmarkstoolbar.h | 1 |
4 files changed, 17 insertions, 27 deletions
diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp index 41704f58..f07c5164 100644 --- a/src/bookmarks/bookmarkprovider.cpp +++ b/src/bookmarks/bookmarkprovider.cpp @@ -33,7 +33,6 @@ // Local Includes #include "application.h" #include "bookmarkspanel.h" -#include "bookmarkscontextmenu.h" #include "bookmarkstoolbar.h" #include "bookmarkowner.h" @@ -109,8 +108,6 @@ void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar) kDebug() << "new bookmark bar..."; m_bookmarkToolBars.append(toolbar); - toolbar->toolBar()->setContextMenuPolicy(Qt::CustomContextMenu); - connect(toolbar->toolBar(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(contextMenu(const QPoint&))); kDebug() << "new bookmark bar... DONE!"; } @@ -183,24 +180,6 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url) } -void BookmarkProvider::contextMenu(const QPoint &point) -{ - if (m_bookmarkToolBars.isEmpty()) - return; - - KToolBar *bookmarkToolBar = m_bookmarkToolBars.at(0)->toolBar(); - if (!bookmarkToolBar) - return; - - KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface*>(bookmarkToolBar->actionAt(point)); - if (!action) - return; - - BookmarksContextMenu menu(action->bookmark(), bookmarkManager(), bookmarkOwner()); - menu.exec(bookmarkToolBar->mapToGlobal(point)); -} - - void BookmarkProvider::slotBookmarksChanged(const QString& /*groupAddress*/, const QString& /*caller*/) { foreach(BookmarkToolBar *bookmarkToolBar, m_bookmarkToolBars) diff --git a/src/bookmarks/bookmarkprovider.h b/src/bookmarks/bookmarkprovider.h index e21bd227..36724d75 100644 --- a/src/bookmarks/bookmarkprovider.h +++ b/src/bookmarks/bookmarkprovider.h @@ -123,12 +123,6 @@ signals: public slots: /** - * @short Opens the context menu on given position - * @param point Point on which you want to open this menu - */ - void contextMenu(const QPoint &point); - - /** * @short Waits for signal that the group with the address has been modified by the caller. * Waits for signal that the group (or any of its children) with the address * @p groupAddress (e.g. "/4/5") has been modified by the caller @p caller. diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp index 68529bd1..ddb70a65 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -167,6 +167,8 @@ BookmarkToolBar::BookmarkToolBar(KToolBar *toolBar, QObject *parent) , m_dropAction(0) , m_filled(false) { + toolBar->setContextMenuPolicy(Qt::CustomContextMenu); + connect(toolBar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString, QString)), this, SLOT(hideMenu())); toolBar->setAcceptDrops(true); toolBar->installEventFilter(this); @@ -190,6 +192,20 @@ KToolBar* BookmarkToolBar::toolBar() } +void BookmarkToolBar::contextMenu(const QPoint &point) +{ + KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface*>(toolBar()->actionAt(point)); + KBookmark bookmark; + if (action) + bookmark = action->bookmark(); + + BookmarksContextMenu menu(bookmark, + Application::bookmarkProvider()->bookmarkManager(), + Application::bookmarkProvider()->bookmarkOwner()); + menu.exec(toolBar()->mapToGlobal(point)); +} + + void BookmarkToolBar::menuDisplayed() { qApp->installEventFilter(this); diff --git a/src/bookmarks/bookmarkstoolbar.h b/src/bookmarks/bookmarkstoolbar.h index 54a430e3..b1e2a555 100644 --- a/src/bookmarks/bookmarkstoolbar.h +++ b/src/bookmarks/bookmarkstoolbar.h @@ -91,6 +91,7 @@ protected: bool eventFilter(QObject *watched, QEvent *event); private slots: + void contextMenu(const QPoint &); void actionHovered(); void menuDisplayed(); void menuHidden(); |