diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks/bookmarkowner.cpp | 49 | ||||
-rw-r--r-- | src/bookmarks/bookmarkowner.h | 7 | ||||
-rw-r--r-- | src/bookmarks/bookmarkprovider.cpp | 17 | ||||
-rw-r--r-- | src/bookmarks/bookmarkprovider.h | 4 | ||||
-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 | ||||
-rw-r--r-- | src/urlbar/urlbar.cpp | 5 |
9 files changed, 75 insertions, 65 deletions
diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp index f1d4df1f..f9e64d68 100644 --- a/src/bookmarks/bookmarkowner.cpp +++ b/src/bookmarks/bookmarkowner.cpp @@ -43,6 +43,7 @@ #include <KBookmarkDialog> #include <KLocalizedString> #include <KMessageBox> +#include "iconmanager.h" // Qt Includes #include <QtGui/QClipboard> @@ -127,30 +128,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; @@ -173,9 +180,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()) @@ -185,22 +193,25 @@ 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()), + Application::iconManager()->iconForUrl(currentUrl()).name()); 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"); @@ -208,11 +219,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(); @@ -223,16 +234,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()) @@ -255,12 +267,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; @@ -270,7 +283,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; @@ -286,7 +299,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 795ccbf0..febff3b0 100644 --- a/src/bookmarks/bookmarkowner.h +++ b/src/bookmarks/bookmarkowner.h @@ -114,14 +114,15 @@ public: public Q_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 ccf60641..8089fb6d 100644 --- a/src/bookmarks/bookmarkprovider.cpp +++ b/src/bookmarks/bookmarkprovider.cpp @@ -36,11 +36,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> @@ -80,14 +80,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!"; @@ -196,7 +196,7 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url) } -void BookmarkProvider::slotBookmarksChanged(const QString& /*groupAddress*/, const QString& /*caller*/) +void BookmarkProvider::slotBookmarksChanged() { foreach(BookmarkToolBar *bookmarkToolBar, m_bookmarkToolBars) { @@ -236,6 +236,7 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) { KBookmarkAction *action = new KBookmarkAction(bookmark, m_owner, this); action->setIconText(action->iconText().replace('&', "&&")); + action->setIcon(Application::iconManager()->iconForUrl(bookmark.url())); connect(action, SIGNAL(hovered()), toolBar, SLOT(actionHovered())); toolBar->toolBar()->addAction(action); toolBar->toolBar()->widgetForAction(action)->installEventFilter(toolBar); @@ -244,14 +245,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 6f2d8b8e..3f7a5c52 100644 --- a/src/bookmarks/bookmarkprovider.h +++ b/src/bookmarks/bookmarkprovider.h @@ -54,6 +54,7 @@ class KUrl; class QAction; class QPoint; + /** * This class represent the interface to rekonq bookmarks system. * All rekonq needs (Bookmarks Menu, Bookmarks Toolbar) is provided @@ -123,11 +124,10 @@ public Q_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 Q_SLOTS: - void slotAddBookmark(); void slotPanelChanged(); Q_SIGNALS: 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..77bff7e6 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(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 7a1193e4..796208a9 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -70,7 +70,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) diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index f1729d53..25c7b748 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -42,11 +42,11 @@ #include "webview.h" #include "completionwidget.h" #include "bookmarkprovider.h" +#include "bookmarkowner.h" #include "bookmarkwidget.h" #include "iconmanager.h" // KDE Includes -#include <KBookmarkManager> #include <KCompletionBox> #include <KStandardDirs> @@ -356,8 +356,7 @@ void UrlBar::showBookmarkInfo(const QPoint &pos) if (bookmark.isNull()) { - bookmark = Application::bookmarkProvider()->rootGroup().addBookmark(_tab->view()->title(), _tab->url()); - Application::bookmarkProvider()->bookmarkManager()->emitChanged(); + bookmark = Application::bookmarkProvider()->bookmarkOwner()->bookmarkCurrentPage(); } BookmarkWidget *widget = new BookmarkWidget(bookmark, window()); |