diff options
author | Jon Ander Peñalba <jonan88@gmail.com> | 2010-08-17 21:44:27 +0200 |
---|---|---|
committer | Jon Ander Peñalba <jonan88@gmail.com> | 2010-08-19 12:53:51 +0200 |
commit | 3aa717e2c5e91f50648740e6c11e0657d77976fc (patch) | |
tree | eb3e1a7ad649ec8e22e44d80c22a4566ccc83e51 /src/bookmarks/bookmarksmanager.cpp | |
parent | Merge branch 'master' of gitorious.org:rekonq/mainline (diff) | |
download | rekonq-3aa717e2c5e91f50648740e6c11e0657d77976fc.tar.xz |
All insertion and deletion of bookmarks code moved to the same place (BookmarkOwner)
Diffstat (limited to 'src/bookmarks/bookmarksmanager.cpp')
-rw-r--r-- | src/bookmarks/bookmarksmanager.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp index 221a6db1..d50e9e77 100644 --- a/src/bookmarks/bookmarksmanager.cpp +++ b/src/bookmarks/bookmarksmanager.cpp @@ -41,6 +41,7 @@ // KDE Includes #include <KActionCollection> #include <KBookmarkAction> +#include <KBookmarkDialog> #include <KBookmarkGroup> #include <KToolBar> #include <KMenu> @@ -75,6 +76,105 @@ void BookmarkOwner::openBookmark(const KBookmark & bookmark, } +void BookmarkOwner::bookmarkPage(KBookmark &position) +{ + BookmarkOwner *owner = Application::bookmarkProvider()->bookmarkOwner(); + KBookmarkGroup parent = Application::bookmarkProvider()->rootGroup(); + + if (!position.isNull()) + { + parent = position.parentGroup(); + + if (position.isGroup()) + parent = position.toGroup(); + + KBookmark newBk = parent.addBookmark(owner->currentTitle().replace('&', "&&"), KUrl(owner->currentUrl())); + parent.moveBookmark(newBk, position.parentGroup().previous(position)); + } + + else + { + parent.addBookmark(owner->currentTitle(), KUrl(owner->currentUrl())); + } + + Application::bookmarkProvider()->bookmarkManager()->emitChanged(parent); +} + + +void BookmarkOwner::newBookmarkFolder(KBookmark &position) +{ + BookmarkOwner *owner = Application::bookmarkProvider()->bookmarkOwner(); + KBookmarkManager *manager = Application::bookmarkProvider()->bookmarkManager(); + + KBookmarkDialog *dialog = owner->bookmarkDialog(manager, QApplication::activeWindow()); + + if (!position.isNull()) + { + if (position.isGroup()) + { + dialog->createNewFolder("New folder", position); + } + + else + { + KBookmark newBk; + newBk = dialog->createNewFolder("New folder", position.parentGroup()); + if (!newBk.isNull()) + { + position.parentGroup().moveBookmark(newBk, position); + manager->emitChanged(newBk.parentGroup()); + } + } + } + else + { + dialog->createNewFolder("New folder"); + } + + delete dialog; +} + + +void BookmarkOwner::newSeparator(KBookmark &position) +{ + KBookmark newBk; + + if (!position.isNull()) + { + if (position.isGroup()) + newBk = position.toGroup().createNewSeparator(); + else + newBk = position.parentGroup().createNewSeparator(); + } + + else + { + newBk = Application::bookmarkProvider()->rootGroup().createNewSeparator(); + } + + KBookmarkGroup parent = newBk.parentGroup(); + newBk.setIcon(("edit-clear")); + parent.addBookmark(newBk); + + if (!position.isNull()) + parent.moveBookmark(newBk, position); + + Application::bookmarkProvider()->bookmarkManager()->emitChanged(newBk.parentGroup()); +} + + +void BookmarkOwner::editBookmark(KBookmark &bookmark) +{ + BookmarkOwner *owner = Application::bookmarkProvider()->bookmarkOwner(); + KBookmarkManager *manager = Application::bookmarkProvider()->bookmarkManager(); + bookmark.setFullText(bookmark.fullText().replace("&&", "&")); + KBookmarkDialog *dialog = owner->bookmarkDialog(manager, QApplication::activeWindow()); + dialog->editBookmark(bookmark); + bookmark.setFullText(bookmark.fullText().replace('&', "&&")); + delete dialog; +} + + bool BookmarkOwner::deleteBookmark(KBookmark &bookmark) { QString name = QString(bookmark.fullText()).replace("&&", "&"); |