diff options
Diffstat (limited to 'src/bookmarks/bookmarkscontextmenu.cpp')
-rw-r--r-- | src/bookmarks/bookmarkscontextmenu.cpp | 183 |
1 files changed, 31 insertions, 152 deletions
diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp index eaf4a9d9..8f64ee4b 100644 --- a/src/bookmarks/bookmarkscontextmenu.cpp +++ b/src/bookmarks/bookmarkscontextmenu.cpp @@ -30,93 +30,40 @@ // Local Includes #include "bookmarksmanager.h" -// KDE Includes -#include <KActionCollection> -// Qt Includes -#include <QClipboard> - - -BookmarksContextMenu::BookmarksContextMenu(const KBookmark & bookmark, KBookmarkManager *manager, KBookmarkOwner *owner, QWidget *parent) +BookmarksContextMenu::BookmarksContextMenu(const KBookmark &bookmark, KBookmarkManager *manager, BookmarkOwner *owner, QWidget *parent) : KBookmarkContextMenu(bookmark, manager, owner, parent) - , m_ac(new KActionCollection(this)) + , bmOwner(owner) { - setupActions(); + bmOwner->bookmarkSelected(bookmark); } BookmarksContextMenu::~BookmarksContextMenu() { - delete m_ac; -} - - -void BookmarksContextMenu::setupActions() -{ - KAction* action; - - action = new KAction(KIcon("tab-new"), i18n("Open"), this); - connect(action, SIGNAL(triggered()), this, SLOT(openInCurrentTab())); - m_ac->addAction("open", action); - - action = new KAction(KIcon("tab-new"), i18n("Open in New Tab"), this); - connect(action, SIGNAL(triggered()), this, SLOT(openInNewTab())); - m_ac->addAction("open_tab", action); - - action = new KAction(KIcon("window-new"), i18n("Open in New Window"), this); - connect(action, SIGNAL(triggered()), this, SLOT(openInNewWindow())); - m_ac->addAction("open_window", action); - - action = new KAction(KIcon("bookmark-new"), i18n("Add Bookmark Here"), this); - connect(action, SIGNAL(triggered()), this, SLOT(bookmarkCurrentPage())); - m_ac->addAction("bookmark_page", action); - - action = new KAction(KIcon("folder-new"), i18n("New Bookmark Folder"), this); - connect(action, SIGNAL(triggered()), this, SLOT(newBookmarkGroup())); - m_ac->addAction("folder_new", action); - - action = new KAction(KIcon("edit-clear"), i18n("New Separator"), this); - connect(action, SIGNAL(triggered()), this, SLOT(newSeparator())); - m_ac->addAction("separator_new", action); - - action = new KAction(KIcon("edit-copy"), i18n("Copy Link Address"), this); - connect(action, SIGNAL(triggered()), this, SLOT(copyToClipboard())); - m_ac->addAction("copy", action); - - action = new KAction(KIcon("edit-delete"), i18n("Delete Bookmark"), this); - connect(action, SIGNAL(triggered()), this, SLOT(deleteBookmark())); - m_ac->addAction("delete", action); - - action = new KAction(KIcon("configure"), i18n("Properties"), this); - connect(action, SIGNAL(triggered()), this, SLOT(editBookmark())); - m_ac->addAction("properties", action); - - action = new KAction(KIcon("tab-new"), i18n("Open Folder in Tabs"), this); - connect(action, SIGNAL(triggered()), this, SLOT(openFolderInTabs())); - m_ac->addAction("open_all", action); } void BookmarksContextMenu::addBookmarkActions() { - addAction(m_ac->action("open")); - addAction(m_ac->action("open_tab")); - addAction(m_ac->action("open_window")); + addAction(bmOwner->action(BookmarkOwner::OPEN)); + addAction(bmOwner->action(BookmarkOwner::OPEN_IN_TAB)); + addAction(bmOwner->action(BookmarkOwner::OPEN_IN_WINDOW)); addSeparator(); - addAction(m_ac->action("bookmark_page")); - addAction(m_ac->action("folder_new")); - addAction(m_ac->action("separator_new")); + addAction(bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); + addAction(bmOwner->action(BookmarkOwner::NEW_FOLDER)); + addAction(bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); addSeparator(); - addAction(m_ac->action("copy")); + addAction(bmOwner->action(BookmarkOwner::COPY)); addSeparator(); - addAction(m_ac->action("delete")); - addAction(m_ac->action("properties")); + addAction(bmOwner->action(BookmarkOwner::EDIT)); + addAction(bmOwner->action(BookmarkOwner::DELETE)); } @@ -124,30 +71,38 @@ void BookmarksContextMenu::addFolderActions() { if (!bookmark().toGroup().first().isNull()) { - addAction(m_ac->action("open_all")); + addAction(bmOwner->action(BookmarkOwner::OPEN_FOLDER)); addSeparator(); } - addAction(m_ac->action("bookmark_page")); - addAction(m_ac->action("folder_new")); - addAction(m_ac->action("separator_new")); + addAction(bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); + addAction(bmOwner->action(BookmarkOwner::NEW_FOLDER)); + addAction(bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); addSeparator(); - addAction(m_ac->action("delete")); - addAction(m_ac->action("properties")); + addAction(bmOwner->action(BookmarkOwner::EDIT)); + addAction(bmOwner->action(BookmarkOwner::DELETE)); } void BookmarksContextMenu::addSeparatorActions() { - addAction(m_ac->action("bookmark_page")); - addAction(m_ac->action("folder_new")); - addAction(m_ac->action("separator_new")); + addAction(bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); + addAction(bmOwner->action(BookmarkOwner::NEW_FOLDER)); + addAction(bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); addSeparator(); - addAction(m_ac->action("delete")); + addAction(bmOwner->action(BookmarkOwner::DELETE)); +} + + +void BookmarksContextMenu::addNullActions() +{ + addAction(bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); + addAction(bmOwner->action(BookmarkOwner::NEW_FOLDER)); + addAction(bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); } @@ -157,92 +112,16 @@ void BookmarksContextMenu::addActions() { addFolderActions(); } - else if (bookmark().isSeparator()) { addSeparatorActions(); } - else if (bookmark().isNull()) { - addAction(m_ac->action("bookmark_page")); - addAction(m_ac->action("folder_new")); - addAction(m_ac->action("separator_new")); + addNullActions(); } - else { addBookmarkActions(); } } - - -void BookmarksContextMenu::openInCurrentTab() -{ - Application::instance()->loadUrl(bookmark().url()); -} - - -void BookmarksContextMenu::openInNewTab() -{ - Application::instance()->loadUrl(bookmark().url(), Rekonq::NewTab); -} - - -void BookmarksContextMenu::openInNewWindow() -{ - Application::instance()->loadUrl(bookmark().url(), Rekonq::NewWindow); -} - - -void BookmarksContextMenu::copyToClipboard() -{ - if (bookmark().isNull()) - return; - - QClipboard *cb = QApplication::clipboard(); - cb->setText(bookmark().url().url()); -} - - -void BookmarksContextMenu::deleteBookmark() -{ - KBookmark bm = bookmark(); - Application::bookmarkProvider()->bookmarkOwner()->deleteBookmark(bm); -} - - -void BookmarksContextMenu::editBookmark() -{ - KBookmark bm = bookmark(); - Application::bookmarkProvider()->bookmarkOwner()->editBookmark(bm); -} - - -void BookmarksContextMenu::openFolderInTabs() -{ - if (bookmark().isGroup()) - owner()->openFolderinTabs(bookmark().toGroup()); -} - - -void BookmarksContextMenu::newBookmarkGroup() -{ - KBookmark bm = bookmark(); - Application::bookmarkProvider()->bookmarkOwner()->newBookmarkFolder(bm); -} - - -void BookmarksContextMenu::newSeparator() -{ - KBookmark bm = bookmark(); - Application::bookmarkProvider()->bookmarkOwner()->newSeparator(bm); -} - - -void BookmarksContextMenu::bookmarkCurrentPage() -{ - KBookmark bm = bookmark(); - Application::bookmarkProvider()->bookmarkOwner()->bookmarkPage(bm); -} - |