diff options
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/bookmarkowner.cpp | 48 | ||||
-rw-r--r-- | src/bookmarks/bookmarkowner.h | 7 | ||||
-rw-r--r-- | src/bookmarks/bookmarkprovider.cpp | 17 | ||||
-rw-r--r-- | src/bookmarks/bookmarkprovider.h | 3 | ||||
-rw-r--r-- | src/bookmarks/bookmarkscontextmenu.cpp | 48 | ||||
-rw-r--r-- | src/bookmarks/bookmarkscontextmenu.h | 2 | ||||
-rw-r--r-- | src/bookmarks/bookmarkstoolbar.cpp | 3 | ||||
-rw-r--r-- | src/bookmarks/bookmarkstreemodel.cpp | 5 |
8 files changed, 71 insertions, 62 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; diff --git a/src/bookmarks/bookmarkowner.h b/src/bookmarks/bookmarkowner.h index e0c2a8ad..5bc46e63 100644 --- a/src/bookmarks/bookmarkowner.h +++ b/src/bookmarks/bookmarkowner.h @@ -120,14 +120,15 @@ signals: public slots: void setCurrentBookmark(const KBookmark &bookmark); + void unsetCurrentBookmark(); void openBookmark(const KBookmark &bookmark = KBookmark()); void openBookmarkInNewTab(const KBookmark &bookmark = KBookmark()); void openBookmarkInNewWindow(const KBookmark &bookmark = KBookmark()); void openBookmarkFolder(const KBookmark &bookmark = KBookmark()); - void bookmarkCurrentPage(const KBookmark &bookmark = KBookmark()); - void newBookmarkFolder(const KBookmark &bookmark = KBookmark()); - void newSeparator(const KBookmark &bookmark = KBookmark()); + KBookmark bookmarkCurrentPage(const KBookmark &bookmark = KBookmark()); + KBookmarkGroup newBookmarkFolder(const KBookmark &bookmark = KBookmark()); + KBookmark newSeparator(const KBookmark &bookmark = KBookmark()); void copyLink(const KBookmark &bookmark = KBookmark()); void editBookmark(KBookmark bookmark = KBookmark()); bool deleteBookmark(KBookmark bookmark = KBookmark()); diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp index f5021916..cc11e463 100644 --- a/src/bookmarks/bookmarkprovider.cpp +++ b/src/bookmarks/bookmarkprovider.cpp @@ -35,11 +35,11 @@ #include "bookmarkspanel.h" #include "bookmarkstoolbar.h" #include "bookmarkowner.h" +#include <iconmanager.h> // KDE Includes #include <KActionCollection> #include <KStandardDirs> -#include <KMimeType> // Qt Includes #include <QtCore/QFile> @@ -79,14 +79,14 @@ BookmarkProvider::BookmarkProvider(QObject *parent) m_manager = KBookmarkManager::managerForFile(bookfile.path(), "rekonq"); connect(m_manager, SIGNAL(changed(const QString &, const QString &)), - this, SLOT(slotBookmarksChanged(const QString &, const QString &))); + this, SLOT(slotBookmarksChanged())); // setup menu m_owner = new BookmarkOwner(m_manager, this); connect(m_owner, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&)), this, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&))); - KAction *a = KStandardAction::addBookmark(this, SLOT(slotAddBookmark()), this); + KAction *a = KStandardAction::addBookmark(bookmarkOwner(), SLOT(bookmarkCurrentPage()), this); m_actionCollection->addAction(QL1S("rekonq_add_bookmark"), a); kDebug() << "Loading Bookmarks Manager... DONE!"; @@ -195,7 +195,7 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url) } -void BookmarkProvider::slotBookmarksChanged(const QString& /*groupAddress*/, const QString& /*caller*/) +void BookmarkProvider::slotBookmarksChanged() { foreach(BookmarkToolBar *bookmarkToolBar, m_bookmarkToolBars) { @@ -235,6 +235,7 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) { KBookmarkAction *action = new KBookmarkAction(bookmark, m_owner, this); action->setIconText(action->iconText().replace('&', "&&")); + action->setIcon(KIcon(Application::iconManager()->iconForUrl(bookmark.url()))); connect(action, SIGNAL(hovered()), toolBar, SLOT(actionHovered())); toolBar->toolBar()->addAction(action); toolBar->toolBar()->widgetForAction(action)->installEventFilter(toolBar); @@ -243,14 +244,6 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) } -void BookmarkProvider::slotAddBookmark() -{ - QString url = bookmarkOwner()->currentUrl(); - rootGroup().addBookmark(bookmarkOwner()->currentTitle(), url, KMimeType::favIconForUrl( KUrl(url) ) ); - bookmarkManager()->emitChanged(); -} - - void BookmarkProvider::slotPanelChanged() { foreach (BookmarksPanel *panel, m_bookmarkPanels) diff --git a/src/bookmarks/bookmarkprovider.h b/src/bookmarks/bookmarkprovider.h index 36724d75..2f2b7abe 100644 --- a/src/bookmarks/bookmarkprovider.h +++ b/src/bookmarks/bookmarkprovider.h @@ -130,11 +130,10 @@ public slots: * @param caller caller that modified the bookmarks * @see KBookmarkManager::changed */ - void slotBookmarksChanged(const QString &groupAddress, const QString &caller); + void slotBookmarksChanged(); void fillBookmarkBar(BookmarkToolBar *toolBar); private slots: - void slotAddBookmark(); void slotPanelChanged(); private: diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp index da986fd2..8f1a570c 100644 --- a/src/bookmarks/bookmarkscontextmenu.cpp +++ b/src/bookmarks/bookmarkscontextmenu.cpp @@ -33,37 +33,37 @@ BookmarksContextMenu::BookmarksContextMenu(const KBookmark &bookmark, KBookmarkManager *manager, BookmarkOwner *owner, QWidget *parent) : KBookmarkContextMenu(bookmark, manager, owner, parent) - , bmOwner(owner) + , m_bmOwner(owner) { - bmOwner->setCurrentBookmark(bookmark); + m_bmOwner->setCurrentBookmark(bookmark); } BookmarksContextMenu::~BookmarksContextMenu() { + m_bmOwner->unsetCurrentBookmark(); } void BookmarksContextMenu::addBookmarkActions() { - addAction(bmOwner->action(BookmarkOwner::OPEN)); - addAction(bmOwner->action(BookmarkOwner::OPEN_IN_TAB)); - addAction(bmOwner->action(BookmarkOwner::OPEN_IN_WINDOW)); + addAction(m_bmOwner->action(BookmarkOwner::OPEN_IN_TAB)); + addAction(m_bmOwner->action(BookmarkOwner::OPEN_IN_WINDOW)); addSeparator(); - addAction(bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); - addAction(bmOwner->action(BookmarkOwner::NEW_FOLDER)); - addAction(bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); + addAction(m_bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); + addAction(m_bmOwner->action(BookmarkOwner::NEW_FOLDER)); + addAction(m_bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); addSeparator(); - addAction(bmOwner->action(BookmarkOwner::COPY)); + addAction(m_bmOwner->action(BookmarkOwner::COPY)); addSeparator(); - addAction(bmOwner->action(BookmarkOwner::EDIT)); - addAction(bmOwner->action(BookmarkOwner::DELETE)); + addAction(m_bmOwner->action(BookmarkOwner::EDIT)); + addAction(m_bmOwner->action(BookmarkOwner::DELETE)); } @@ -82,39 +82,39 @@ void BookmarksContextMenu::addFolderActions() if (!child.isNull()) { - addAction(bmOwner->action(BookmarkOwner::OPEN_FOLDER)); + addAction(m_bmOwner->action(BookmarkOwner::OPEN_FOLDER)); addSeparator(); } } - addAction(bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); - addAction(bmOwner->action(BookmarkOwner::NEW_FOLDER)); - addAction(bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); + addAction(m_bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); + addAction(m_bmOwner->action(BookmarkOwner::NEW_FOLDER)); + addAction(m_bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); addSeparator(); - addAction(bmOwner->action(BookmarkOwner::EDIT)); - addAction(bmOwner->action(BookmarkOwner::DELETE)); + addAction(m_bmOwner->action(BookmarkOwner::EDIT)); + addAction(m_bmOwner->action(BookmarkOwner::DELETE)); } void BookmarksContextMenu::addSeparatorActions() { - addAction(bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); - addAction(bmOwner->action(BookmarkOwner::NEW_FOLDER)); - addAction(bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); + addAction(m_bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); + addAction(m_bmOwner->action(BookmarkOwner::NEW_FOLDER)); + addAction(m_bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); addSeparator(); - addAction(bmOwner->action(BookmarkOwner::DELETE)); + addAction(m_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)); + addAction(m_bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); + addAction(m_bmOwner->action(BookmarkOwner::NEW_FOLDER)); + addAction(m_bmOwner->action(BookmarkOwner::NEW_SEPARATOR)); } diff --git a/src/bookmarks/bookmarkscontextmenu.h b/src/bookmarks/bookmarkscontextmenu.h index a6691fdd..d669eef6 100644 --- a/src/bookmarks/bookmarkscontextmenu.h +++ b/src/bookmarks/bookmarkscontextmenu.h @@ -47,7 +47,7 @@ private: void addSeparatorActions(); void addNullActions(); - BookmarkOwner *bmOwner; + BookmarkOwner *m_bmOwner; }; #endif // BOOKMARKS_CONTEXT_MENU_H diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp index ddb70a65..26b9de39 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -30,6 +30,7 @@ #include "bookmarkstoolbar.moc" // Local Includes +#include "iconmanager.h" #include "bookmarkscontextmenu.h" #include "mainwindow.h" #include "application.h" @@ -66,7 +67,6 @@ BookmarkMenu::~BookmarkMenu() KMenu * BookmarkMenu::contextMenu(QAction *act) { - KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(act); if (!action) return 0; @@ -91,6 +91,7 @@ QAction * BookmarkMenu::actionForBookmark(const KBookmark &bookmark) else { KBookmarkAction *action = new KBookmarkAction(bookmark, owner(), this); + action->setIcon(KIcon(Application::iconManager()->iconForUrl(bookmark.url()))); connect(action, SIGNAL(hovered()), this, SLOT(actionHovered())); return action; } diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp index 254a914f..4e85c422 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -69,7 +69,10 @@ QVariant BtmItem::data(int role) const // return KIcon(m_kbm.icon()); // but I cannot let it work :( // I really cannot understand how let this work properly... - return Application::iconManager()->iconForUrl(KUrl(m_kbm.url())); + if (m_kbm.isGroup() || m_kbm.isSeparator()) + return KIcon(m_kbm.icon()); + else + return Application::iconManager()->iconForUrl(KUrl(m_kbm.url())); } if (role == Qt::UserRole) |