summaryrefslogtreecommitdiff
path: root/src/bookmarks/bookmarkowner.cpp
diff options
context:
space:
mode:
authorYoann Laissus <yoann.laissus@gmail.com>2010-09-02 12:20:21 +0200
committerYoann Laissus <yoann.laissus@gmail.com>2010-09-02 12:20:21 +0200
commit8830c32f2c4aea542003f71e14a43c712e2d91e0 (patch)
treebf7a8b859abffc1ecc33898a58a5baeea46dc27f /src/bookmarks/bookmarkowner.cpp
parentThis should improve adblock retrieving by NOT asking for SSL confirmations (diff)
downloadrekonq-8830c32f2c4aea542003f71e14a43c712e2d91e0.tar.xz
A little bunch of fixes :
- Bookmarks saved with KMimeType::iconNameForUrl are now correctly displayed in the BK bar - Folder icons in the BK panel are fixed - Unset the current bookmark after a context menu deletition to avoid some bugs - Cleanup
Diffstat (limited to 'src/bookmarks/bookmarkowner.cpp')
-rw-r--r--src/bookmarks/bookmarkowner.cpp48
1 files changed, 30 insertions, 18 deletions
diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp
index 530ad199..42583c70 100644
--- a/src/bookmarks/bookmarkowner.cpp
+++ b/src/bookmarks/bookmarkowner.cpp
@@ -42,6 +42,7 @@
#include <KBookmarkDialog>
#include <KLocalizedString>
#include <KMessageBox>
+#include <KMimeType>
// Qt Includes
#include <QtGui/QClipboard>
@@ -126,30 +127,36 @@ void BookmarkOwner::setCurrentBookmark(const KBookmark &bookmark)
}
+void BookmarkOwner::unsetCurrentBookmark()
+{
+ m_currentBookmark = KBookmark();
+}
+
+
void BookmarkOwner::openBookmark(const KBookmark &bookmark)
{
- KBookmark selected = bookmark.isNull() ? m_currentBookmark : bookmark;
+ KBookmark selected = (bookmark.isNull() && !m_currentBookmark.isNull()) ? m_currentBookmark : bookmark;
emit openUrl(selected.url(), Rekonq::CurrentTab);
}
void BookmarkOwner::openBookmarkInNewTab(const KBookmark &bookmark)
{
- KBookmark selected = bookmark.isNull() ? m_currentBookmark : bookmark;
+ KBookmark selected = (bookmark.isNull() && !m_currentBookmark.isNull()) ? m_currentBookmark : bookmark;
emit openUrl(selected.url(), Rekonq::NewTab);
}
void BookmarkOwner::openBookmarkInNewWindow(const KBookmark &bookmark)
{
- KBookmark selected = bookmark.isNull() ? m_currentBookmark : bookmark;
+ KBookmark selected = (bookmark.isNull() && !m_currentBookmark.isNull()) ? m_currentBookmark : bookmark;
emit openUrl(selected.url(), Rekonq::NewWindow);
}
void BookmarkOwner::openBookmarkFolder(const KBookmark &bookmark)
{
- KBookmark selected = bookmark.isNull() ? m_currentBookmark : bookmark;
+ KBookmark selected = (bookmark.isNull() && !m_currentBookmark.isNull()) ? m_currentBookmark : bookmark;
if (!selected.isGroup())
return;
@@ -172,9 +179,10 @@ void BookmarkOwner::openBookmarkFolder(const KBookmark &bookmark)
}
-void BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark)
+KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark)
{
- KBookmark selected = bookmark.isNull() ? m_currentBookmark : bookmark;
+ KBookmark selected = (bookmark.isNull() && !m_currentBookmark.isNull()) ? m_currentBookmark : bookmark;
+ KBookmark newBk;
KBookmarkGroup parent;
if (!selected.isNull())
@@ -184,22 +192,24 @@ void BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark)
else
parent = selected.parentGroup();
- KBookmark newBk = parent.addBookmark(currentTitle().replace('&', "&&"), KUrl(currentUrl()));
+ newBk = parent.addBookmark(currentTitle().replace('&', "&&"), KUrl(currentUrl()), KMimeType::iconNameForUrl(currentUrl()));
parent.moveBookmark(newBk, selected);
}
else
{
parent = Application::bookmarkProvider()->rootGroup();
- parent.addBookmark(currentTitle(), KUrl(currentUrl()));
+ newBk = parent.addBookmark(currentTitle(), KUrl(currentUrl()));
}
m_manager->emitChanged(parent);
+ return newBk;
}
-void BookmarkOwner::newBookmarkFolder(const KBookmark &bookmark)
+KBookmarkGroup BookmarkOwner::newBookmarkFolder(const KBookmark &bookmark)
{
- KBookmark selected = bookmark.isNull() ? m_currentBookmark : bookmark;
+ KBookmark selected = (bookmark.isNull() && !m_currentBookmark.isNull()) ? m_currentBookmark : bookmark;
+ KBookmarkGroup newBk;
KBookmarkDialog *dialog = bookmarkDialog(m_manager, QApplication::activeWindow());
QString folderName = i18n("New folder");
@@ -207,11 +217,11 @@ void BookmarkOwner::newBookmarkFolder(const KBookmark &bookmark)
{
if (selected.isGroup())
{
- dialog->createNewFolder(folderName, selected);
+ newBk = dialog->createNewFolder(folderName, selected);
}
else
{
- KBookmark newBk = dialog->createNewFolder(folderName, selected.parentGroup());
+ newBk = dialog->createNewFolder(folderName, selected.parentGroup());
if (!newBk.isNull())
{
KBookmarkGroup parent = newBk.parentGroup();
@@ -222,16 +232,17 @@ void BookmarkOwner::newBookmarkFolder(const KBookmark &bookmark)
}
else
{
- dialog->createNewFolder(folderName);
+ newBk = dialog->createNewFolder(folderName);
}
delete dialog;
+ return newBk;
}
-void BookmarkOwner::newSeparator(const KBookmark &bookmark)
+KBookmark BookmarkOwner::newSeparator(const KBookmark &bookmark)
{
- KBookmark selected = bookmark.isNull() ? m_currentBookmark : bookmark;
+ KBookmark selected = (bookmark.isNull() && !m_currentBookmark.isNull()) ? m_currentBookmark : bookmark;
KBookmark newBk;
if (!selected.isNull())
@@ -254,12 +265,13 @@ void BookmarkOwner::newSeparator(const KBookmark &bookmark)
newBk.setIcon(("edit-clear"));
m_manager->emitChanged(newBk.parentGroup());
+ return newBk;
}
void BookmarkOwner::copyLink(const KBookmark &bookmark)
{
- KBookmark selected = bookmark.isNull() ? m_currentBookmark : bookmark;
+ KBookmark selected = (bookmark.isNull() && !m_currentBookmark.isNull()) ? m_currentBookmark : bookmark;
if (selected.isNull())
return;
@@ -269,7 +281,7 @@ void BookmarkOwner::copyLink(const KBookmark &bookmark)
void BookmarkOwner::editBookmark(KBookmark bookmark)
{
- KBookmark selected = bookmark.isNull() ? m_currentBookmark : bookmark;
+ KBookmark selected = (bookmark.isNull() && !m_currentBookmark.isNull()) ? m_currentBookmark : bookmark;
if (selected.isNull())
return;
@@ -285,7 +297,7 @@ void BookmarkOwner::editBookmark(KBookmark bookmark)
bool BookmarkOwner::deleteBookmark(KBookmark bookmark)
{
- KBookmark selected = bookmark.isNull() ? m_currentBookmark : bookmark;
+ KBookmark selected = (bookmark.isNull() && !m_currentBookmark.isNull()) ? m_currentBookmark : bookmark;
if (selected.isNull())
return false;