diff options
author | Jon Ander Peñalba <jonan88@gmail.com> | 2010-08-17 22:32:35 +0200 |
---|---|---|
committer | Jon Ander Peñalba <jonan88@gmail.com> | 2010-08-19 12:53:52 +0200 |
commit | 63dac5edf257b0c5bdee44212769da132220c0a0 (patch) | |
tree | 43584d8a98d0f69fad2da476da2b70bda38fa45c | |
parent | Minor improvements in the insertion and deletion of bookmarks code (diff) | |
download | rekonq-63dac5edf257b0c5bdee44212769da132220c0a0.tar.xz |
Create and store all bookmark actions in BookmarkOwner
-rw-r--r-- | src/bookmarks/bookmarksmanager.cpp | 43 | ||||
-rw-r--r-- | src/bookmarks/bookmarksmanager.h | 28 |
2 files changed, 71 insertions, 0 deletions
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp index c9a79fa8..c4fa68a1 100644 --- a/src/bookmarks/bookmarksmanager.cpp +++ b/src/bookmarks/bookmarksmanager.cpp @@ -57,7 +57,15 @@ BookmarkOwner::BookmarkOwner(QObject *parent) : QObject(parent) , KBookmarkOwner() + , actions(QVector<KAction*>(NUM_ACTIONS)) { + setupActions(); +} + + +KAction* BookmarkOwner::action(const BookmarkAction &bmAction) +{ + return static_cast<KAction*>(actions.at(bmAction)); } @@ -277,6 +285,41 @@ QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const } +void BookmarkOwner::setupActions() +{ + createAction(OPEN, i18n("Open"), "tab-new", + i18n("Open bookmark in current tab"), SLOT(openBookmark())); + createAction(OPEN_IN_TAB, i18n("Open in New Tab"), "tab-new", + i18n("Open bookmark in new tab"), SLOT(openBookmarkInNewTab())); + createAction(OPEN_IN_WINDOW, i18n("Open in New Window"), "window-new", + i18n("Open bookmark in new window"), SLOT(openBookmarkInNewWindow())); + createAction(OPEN_FOLDER, i18n("Open Folder in Tabs"), "tab-new", + i18n("Open all the bookmarks in folder in tabs"), SLOT(openBookmarkGroup())); + createAction(BOOKMARK_PAGE, i18n("Add Bookmark"), "bookmark-new", + i18n("Bookmark current page"), SLOT(bookmarkCurrentPage())); + createAction(NEW_FOLDER, i18n("New Folder"), "folder-new", + i18n("Create a new bookmark folder"), SLOT(newBookmarkGroup())); + createAction(NEW_SEPARATOR, i18n("New Separator"), "edit-clear", + i18n("Create a new bookmark separatork"), SLOT(newSeparator())); + createAction(COPY, i18n("Copy Link"), "edit-copy", + i18n("Copy the bookmark's link address"), SLOT(copyLink())); + createAction(EDIT, i18n("Edit"), "configure", + i18n("Edit the bookmark"), SLOT(editBookmark())); + createAction(DELETE, i18n("Delete"), "edit-delete", + i18n("Delete the bookmark"), SLOT(deleteBookmark())); +} + + +void BookmarkOwner::createAction(const BookmarkAction &action, const QString &text, + const QString &icon, const QString &help, const char *slot) +{ + KAction *act = new KAction(KIcon(icon), text, this); + act->setHelpText(help); + actions[action] = act; + connect(act, SIGNAL(triggered()), this, slot); +} + + // ------------------------------------------------------------------------------------------------------ diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h index 19bfe5d2..af2cb158 100644 --- a/src/bookmarks/bookmarksmanager.h +++ b/src/bookmarks/bookmarksmanager.h @@ -77,6 +77,26 @@ public: BookmarkOwner(QObject *parent = 0); virtual ~BookmarkOwner() {} + enum BookmarkAction + { + OPEN = 0, + OPEN_IN_TAB, + OPEN_IN_WINDOW, + OPEN_FOLDER, + BOOKMARK_PAGE, + NEW_FOLDER, + NEW_SEPARATOR, + COPY, + EDIT, + DELETE, + NUM_ACTIONS + }; + + /** + * @return the action or 0 if it doesn't exist. + */ + KAction* action(const BookmarkAction &bmAction); + /** * This function is called when a bookmark is selected and belongs to * the ancestor class. @@ -158,6 +178,14 @@ signals: * */ void openUrl(const KUrl &, const Rekonq::OpenType &); + +private: + QVector<KAction*> actions; + + void setupActions(); + void createAction(const BookmarkAction &action, + const QString &text, const QString &icon, + const QString &help, const char *slot); }; |