summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoann Laissus <yoann.laissus@gmail.com>2010-08-22 14:09:41 +0200
committerYoann Laissus <yoann.laissus@gmail.com>2010-08-22 14:09:41 +0200
commitc18a4bf0e5561ec97ef299a0992f267905021c66 (patch)
tree175dad967c505246892de49ca03bc3a6a7deacd8
parentrekonq 0.5.80 AKA 0.6 beta (diff)
downloadrekonq-c18a4bf0e5561ec97ef299a0992f267905021c66.tar.xz
- Move the BK bar context menu slot and connection to BookmarkContextMenu
- The context menu now works without selected bookmark in the BK bar
-rw-r--r--src/bookmarks/bookmarkprovider.cpp20
-rw-r--r--src/bookmarks/bookmarkprovider.h6
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp16
-rw-r--r--src/bookmarks/bookmarkstoolbar.h1
4 files changed, 17 insertions, 26 deletions
diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp
index 41704f58..7bfb608b 100644
--- a/src/bookmarks/bookmarkprovider.cpp
+++ b/src/bookmarks/bookmarkprovider.cpp
@@ -109,8 +109,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 +181,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 64e9c3b9..bc307965 100644
--- a/src/bookmarks/bookmarkstoolbar.cpp
+++ b/src/bookmarks/bookmarkstoolbar.cpp
@@ -166,6 +166,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);
@@ -189,6 +191,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();