summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/bookmarkowner.cpp31
-rw-r--r--src/bookmarks/bookmarkowner.h6
-rw-r--r--src/bookmarks/bookmarkscontextmenu.cpp19
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp86
4 files changed, 102 insertions, 40 deletions
diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp
index bfca6ef3..da006801 100644
--- a/src/bookmarks/bookmarkowner.cpp
+++ b/src/bookmarks/bookmarkowner.cpp
@@ -89,6 +89,12 @@ KAction* BookmarkOwner::createAction(const KBookmark &bookmark, const BookmarkAc
case DELETE:
return createAction(i18n("Delete"), "edit-delete",
i18n("Delete the bookmark"), SLOT(deleteBookmark(const KBookmark &)), bookmark);
+ case SET_TOOLBAR_FOLDER:
+ return createAction(i18n("Set as toolbar folder"), "bookmark-toolbar",
+ "", SLOT(setToolBarFolder(KBookmark)), bookmark);
+ case UNSET_TOOLBAR_FOLDER:
+ return createAction(i18n("Unset this folder as the toolbar folder"), "bookmark-toolbar",
+ "", SLOT(unsetToolBarFolder()), bookmark);
default:
return 0;
}
@@ -332,6 +338,31 @@ bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark)
}
+void BookmarkOwner::setToolBarFolder(KBookmark bookmark)
+{
+ if (!bookmark.isGroup())
+ return;
+
+ unsetToolBarFolder();
+ bookmark.internalElement().setAttribute("toolbar", "yes");
+ bookmark.setIcon("bookmark-toolbar");
+
+ m_manager->emitChanged();
+}
+
+
+void BookmarkOwner::unsetToolBarFolder()
+{
+ KBookmarkGroup toolbar = m_manager->toolbar();
+ if (!toolbar.isNull())
+ {
+ toolbar.internalElement().setAttribute("toolbar", "no");
+ toolbar.setIcon("");
+ }
+ m_manager->emitChanged();
+}
+
+
KAction* BookmarkOwner::createAction(const QString &text, const QString &icon,
const QString &help, const char *slot,
const KBookmark &bookmark)
diff --git a/src/bookmarks/bookmarkowner.h b/src/bookmarks/bookmarkowner.h
index 8f0cd3b8..a414963b 100644
--- a/src/bookmarks/bookmarkowner.h
+++ b/src/bookmarks/bookmarkowner.h
@@ -61,7 +61,9 @@ public:
COPY,
EDIT,
DELETE,
- NUM_ACTIONS
+ NUM_ACTIONS,
+ SET_TOOLBAR_FOLDER,
+ UNSET_TOOLBAR_FOLDER
};
/**
@@ -106,6 +108,8 @@ public Q_SLOTS:
void copyLink(const KBookmark &bookmark);
void editBookmark(KBookmark bookmark);
bool deleteBookmark(const KBookmark &bookmark);
+ void setToolBarFolder(KBookmark bookmark = KBookmark());
+ void unsetToolBarFolder();
Q_SIGNALS:
/**
diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp
index a55f7777..25cb9f24 100644
--- a/src/bookmarks/bookmarkscontextmenu.cpp
+++ b/src/bookmarks/bookmarkscontextmenu.cpp
@@ -29,6 +29,11 @@
// Local Includes
#include "bookmarkowner.h"
+#include "bookmarkprovider.h"
+#include "application.h"
+
+// KDE Includes
+#include <KBookmarkManager>
BookmarksContextMenu::BookmarksContextMenu(const KBookmark &bookmark, KBookmarkManager *manager, BookmarkOwner *owner, QWidget *parent)
@@ -64,6 +69,15 @@ void BookmarksContextMenu::addFolderActions()
{
KBookmarkGroup group = bookmark().toGroup();
+ if (bookmark().internalElement().attributeNode("toolbar").value() == "yes")
+ {
+ addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER));
+ }
+ else
+ {
+ addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::SET_TOOLBAR_FOLDER));
+ }
+
if (!group.first().isNull())
{
KBookmark child = group.first();
@@ -105,6 +119,11 @@ void BookmarksContextMenu::addSeparatorActions()
void BookmarksContextMenu::addNullActions()
{
+ KBookmarkManager *manager = rApp->bookmarkProvider()->bookmarkManager();
+ if (manager->toolbar().hasParent())
+ {
+ addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER));
+ }
addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE));
addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER));
addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR));
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);