summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJon Ander Peñalba <jonan88@gmail.com>2010-10-15 21:03:42 +0200
committerJon Ander Peñalba <jonan88@gmail.com>2010-11-07 11:37:11 +0100
commitbd32f05dab4832528e0c2304d722e5140ffd74e4 (patch)
tree92684124df14f92a6d74bb31df17f73fb976ae34 /src
parentcommit the changes by yurchor on the docbook (diff)
downloadrekonq-bd32f05dab4832528e0c2304d722e5140ffd74e4.tar.xz
BookmarkOwner clean-up and minor bug fixed
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/bookmarkowner.cpp61
-rw-r--r--src/bookmarks/bookmarkowner.h53
2 files changed, 38 insertions, 76 deletions
diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp
index 77af9b1f..820e01b5 100644
--- a/src/bookmarks/bookmarkowner.cpp
+++ b/src/bookmarks/bookmarkowner.cpp
@@ -34,16 +34,14 @@
// Local Includes
#include "application.h"
#include "bookmarkprovider.h"
+#include "mainview.h"
#include "mainwindow.h"
#include "webtab.h"
-#include "mainview.h"
// KDE Includes
-#include <KAction>
#include <KBookmarkDialog>
#include <KLocalizedString>
#include <KMessageBox>
-#include "iconmanager.h"
// Qt Includes
#include <QtGui/QClipboard>
@@ -109,12 +107,6 @@ QString BookmarkOwner::currentUrl() const
}
-bool BookmarkOwner::supportsTabs() const
-{
- return true;
-}
-
-
QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const
{
QList< QPair<QString, QString> > bkList;
@@ -138,13 +130,9 @@ void BookmarkOwner::openBookmark(const KBookmark &bookmark,
Qt::KeyboardModifiers keyboardModifiers)
{
if (keyboardModifiers & Qt::ControlModifier || mouseButtons & Qt::MidButton)
- {
openBookmarkInNewTab(bookmark);
- }
else
- {
openBookmark(bookmark);
- }
}
@@ -171,13 +159,6 @@ void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bookmark)
}
-void BookmarkOwner::openBookmarkFolder(const KBookmark &bookmark)
-{
- if (bookmark.isGroup())
- openFolderinTabs(bookmark.toGroup());
-}
-
-
void BookmarkOwner::openBookmark(const KBookmark &bookmark)
{
emit openUrl(bookmark.url(), Rekonq::CurrentTab);
@@ -196,9 +177,14 @@ void BookmarkOwner::openBookmarkInNewWindow(const KBookmark &bookmark)
}
+void BookmarkOwner::openBookmarkFolder(const KBookmarkGroup &bookmark)
+{
+ openFolderinTabs(bookmark);
+}
+
+
KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark)
{
- KBookmark newBk;
KBookmarkGroup parent;
if (!bookmark.isNull())
@@ -207,16 +193,16 @@ KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark)
parent = bookmark.toGroup();
else
parent = bookmark.parentGroup();
-
- newBk = parent.addBookmark(currentTitle().replace('&', "&&"), KUrl(currentUrl()) );
- parent.moveBookmark(newBk, bookmark);
}
else
{
parent = Application::bookmarkProvider()->rootGroup();
- newBk = parent.addBookmark(currentTitle(), KUrl(currentUrl()));
}
+ KBookmark newBk = parent.addBookmark(currentTitle().replace('&', "&&"), KUrl(currentUrl()));
+ if (!bookmark.isNull())
+ parent.moveBookmark(newBk, bookmark);
+
m_manager->emitChanged(parent);
return newBk;
}
@@ -225,7 +211,7 @@ KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark)
KBookmarkGroup BookmarkOwner::newBookmarkFolder(const KBookmark &bookmark)
{
KBookmarkGroup newBk;
- KBookmarkDialog *dialog = bookmarkDialog(m_manager, QApplication::activeWindow());
+ KBookmarkDialog *dialog = bookmarkDialog(m_manager, 0);
QString folderName = i18n("New folder");
if (!bookmark.isNull())
@@ -276,7 +262,7 @@ KBookmark BookmarkOwner::newSeparator(const KBookmark &bookmark)
newBk = Application::bookmarkProvider()->rootGroup().createNewSeparator();
}
- newBk.setIcon(("edit-clear"));
+ newBk.setIcon("edit-clear");
m_manager->emitChanged(newBk.parentGroup());
return newBk;
@@ -298,8 +284,7 @@ void BookmarkOwner::editBookmark(KBookmark bookmark)
return;
bookmark.setFullText(bookmark.fullText().replace("&&", "&"));
- KBookmarkDialog *dialog = bookmarkDialog(m_manager, QApplication::activeWindow());
-
+ KBookmarkDialog *dialog = bookmarkDialog(m_manager, 0);
dialog->editBookmark(bookmark);
bookmark.setFullText(bookmark.fullText().replace('&', "&&"));
@@ -307,7 +292,7 @@ void BookmarkOwner::editBookmark(KBookmark bookmark)
}
-bool BookmarkOwner::deleteBookmark(KBookmark bookmark)
+bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark)
{
if (bookmark.isNull())
return false;
@@ -333,7 +318,7 @@ bool BookmarkOwner::deleteBookmark(KBookmark bookmark)
}
if (KMessageBox::warningContinueCancel(
- QApplication::activeWindow(),
+ 0,
dialogText,
dialogCaption,
KStandardGuiItem::del(),
@@ -349,9 +334,9 @@ bool BookmarkOwner::deleteBookmark(KBookmark bookmark)
}
-KAction* BookmarkOwner::createAction(const QString &text,
- const QString &icon, const QString &help, const char *slot,
- const KBookmark & bookmark)
+KAction* BookmarkOwner::createAction(const QString &text, const QString &icon,
+ const QString &help, const char *slot,
+ const KBookmark &bookmark)
{
CustomBookmarkAction *act = new CustomBookmarkAction(bookmark, KIcon(icon), text, this);
act->setHelpText(help);
@@ -364,16 +349,12 @@ KAction* BookmarkOwner::createAction(const QString &text,
CustomBookmarkAction::CustomBookmarkAction(const KBookmark &bookmark, const KIcon &icon, const QString &text, QObject *parent)
- : KAction(icon, text, parent)
- , m_bookmark(bookmark)
+ : KAction(icon, text, parent)
+ , m_bookmark(bookmark)
{
connect(this, SIGNAL(triggered()), this, SLOT(onActionTriggered()));
}
-CustomBookmarkAction::~CustomBookmarkAction()
-{
-}
-
void CustomBookmarkAction::onActionTriggered()
{
emit triggered(m_bookmark);
diff --git a/src/bookmarks/bookmarkowner.h b/src/bookmarks/bookmarkowner.h
index 573e4ee0..cbd4bd0e 100644
--- a/src/bookmarks/bookmarkowner.h
+++ b/src/bookmarks/bookmarkowner.h
@@ -35,14 +35,12 @@
#include "rekonq_defines.h"
// KDE Includes
-#include <KBookmarkOwner>
-#include <KIcon>
#include <KAction>
+#include <KBookmarkOwner>
/**
- * Reimplementation of KBookmarkOwner, this class allows to manage
- * bookmarks as actions.
+ * This class allows to manage bookmarks as actions.
*/
class REKONQ_TESTS_EXPORT BookmarkOwner : public QObject, public KBookmarkOwner
{
@@ -72,56 +70,40 @@ public:
*/
KAction* action(const KBookmark &bookmark, const BookmarkAction &bmAction);
+ // @{
/**
- * @return the current page's title.
+ * Funtions to get current information.
*/
virtual QString currentTitle() const;
- /**
- * @return the current page's URL.
- */
virtual QString currentUrl() const;
-
- /**
- * @return whether the owner supports tabs.
- */
- virtual bool supportsTabs() const;
-
- /**
- * @return list of title, URL pairs of the open tabs.
- */
virtual QList< QPair<QString, QString> > currentBookmarkList() const;
+ // @}
+
+ virtual bool supportsTabs() const {return true;}
+ // @{
/**
- * This function is called when a bookmark is selected and belongs to
- * the ancestor class.
- * This method actually emits signal to load bookmark's url.
- *
- * @param bookmark the bookmark to open
- * @param mouseButtons the mouse buttons clicked to select the bookmark
- * @param keyboardModifiers the keyboard modifiers pushed when the bookmark was selected
+ * This functions emit signals that open the selected URLs
*/
virtual void openBookmark(const KBookmark &bookmark,
Qt::MouseButtons mouseButtons,
Qt::KeyboardModifiers keyboardModifiers);
-
- /**
- * Called if the user wants to open every bookmark in this folder in a new tab.
- * The default implementation does nothing.
- * This is only called if supportsTabs() returns true
- */
virtual void openFolderinTabs(const KBookmarkGroup &bookmark);
+ // @}
public Q_SLOTS:
void openBookmark(const KBookmark &bookmark);
void openBookmarkInNewTab(const KBookmark &bookmark);
void openBookmarkInNewWindow(const KBookmark &bookmark);
- void openBookmarkFolder(const KBookmark &bookmark);
+ void openBookmarkFolder(const KBookmarkGroup &bookmark);
+
KBookmark bookmarkCurrentPage(const KBookmark &bookmark = KBookmark());
KBookmarkGroup newBookmarkFolder(const KBookmark &bookmark = KBookmark());
KBookmark newSeparator(const KBookmark &bookmark = KBookmark());
+
void copyLink(const KBookmark &bookmark);
void editBookmark(KBookmark bookmark);
- bool deleteBookmark(KBookmark bookmark);
+ bool deleteBookmark(const KBookmark &bookmark);
Q_SIGNALS:
/**
@@ -132,10 +114,9 @@ Q_SIGNALS:
private:
KAction* createAction(const QString &text, const QString &icon,
- const QString &help, const char *slot,
- const KBookmark &bookmark);
+ const QString &help, const char *slot,
+ const KBookmark &bookmark);
-
KBookmarkManager *m_manager;
};
@@ -149,7 +130,7 @@ class CustomBookmarkAction : public KAction
public:
CustomBookmarkAction(const KBookmark &bookmark, const KIcon &icon, const QString &text, QObject *parent);
- ~CustomBookmarkAction();
+ virtual ~CustomBookmarkAction() {}
Q_SIGNALS:
void triggered(const KBookmark &);