summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJon Ander Peñalba <jonan88@gmail.com>2010-08-17 23:48:10 +0200
committerJon Ander Peñalba <jonan88@gmail.com>2010-08-19 13:10:45 +0200
commitaaa673a3e43ae0d309a9428d3e62d9f350137acd (patch)
tree3bb4f33cf3c7b33bd7617afa27ea32638ac20989 /src
parentBookmarkOwner class moved to it's own file (diff)
downloadrekonq-aaa673a3e43ae0d309a9428d3e62d9f350137acd.tar.xz
BookmarkOwner class clean-up
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/bookmarkowner.cpp230
-rw-r--r--src/bookmarks/bookmarkowner.h52
2 files changed, 128 insertions, 154 deletions
diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp
index 6c55f724..fb7c737e 100644
--- a/src/bookmarks/bookmarkowner.cpp
+++ b/src/bookmarks/bookmarkowner.cpp
@@ -61,17 +61,109 @@ KAction* BookmarkOwner::action(const BookmarkAction &bmAction)
}
-void BookmarkOwner::openBookmark(const KBookmark & bookmark,
+QString BookmarkOwner::currentTitle() const
+{
+ return Application::instance()->mainWindow()->currentTab()->view()->title();
+}
+
+
+QString BookmarkOwner::currentUrl() const
+{
+ return Application::instance()->mainWindow()->currentTab()->url().url();
+}
+
+
+bool BookmarkOwner::supportsTabs() const
+{
+ return true;
+}
+
+
+QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const
+{
+ QList< QPair<QString, QString> > bkList;
+ MainView *view = Application::instance()->mainWindow()->mainView();
+ int tabNumber = view->count();
+
+ for (int i = 0; i < tabNumber; ++i)
+ {
+ QPair<QString, QString> item;
+ item.first = view->webTab(i)->view()->title();
+ item.second = view->webTab(i)->url().url();
+ bkList << item;
+ }
+
+ return bkList;
+}
+
+
+void BookmarkOwner::openBookmark(const KBookmark &bookmark,
Qt::MouseButtons mouseButtons,
Qt::KeyboardModifiers keyboardModifiers)
{
- if (keyboardModifiers & Qt::ControlModifier || mouseButtons == Qt::MidButton)
+ bookmarkSelected(bookmark);
+ if (keyboardModifiers & Qt::ControlModifier || mouseButtons & Qt::MidButton)
{
- emit openUrl(bookmark.url(), Rekonq::NewTab);
+ openBookmarkInNewTab();
}
else
{
- emit openUrl(bookmark.url(), Rekonq::CurrentTab);
+ openBookmark();
+ }
+}
+
+
+void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bookmark)
+{
+ bookmarkSelected(bookmark);
+ openBookmarkFolder();
+}
+
+
+void BookmarkOwner::bookmarkSelected(const KBookmark &bookmark)
+{
+ selected = bookmark;
+}
+
+
+void BookmarkOwner::openBookmark()
+{
+ emit openUrl(selected.url(), Rekonq::CurrentTab);
+}
+
+
+void BookmarkOwner::openBookmarkInNewTab()
+{
+ emit openUrl(selected.url(), Rekonq::NewTab);
+}
+
+
+void BookmarkOwner::openBookmarkInNewWindow()
+{
+ emit openUrl(selected.url(), Rekonq::NewWindow);
+}
+
+
+void BookmarkOwner::openBookmarkFolder()
+{
+ if (!selected.isGroup())
+ return;
+
+ QList<KUrl> urlList = selected.toGroup().groupUrlList();
+
+ if (urlList.length() > 8)
+ {
+ if (KMessageBox::warningContinueCancel(
+ Application::instance()->mainWindow(),
+ i18n("You are about to open %1 tabs.\nAre you sure?", urlList.length()))
+ != KMessageBox::Continue
+ )
+ return;
+ }
+
+ foreach (KUrl url, urlList)
+ {
+ emit openUrl(url, Rekonq::NewFocusedTab);
}
}
@@ -158,6 +250,15 @@ void BookmarkOwner::newSeparator()
}
+void BookmarkOwner::copyLink()
+{
+ if (selected.isNull())
+ return;
+
+ QApplication::clipboard()->setText(selected.url().url());
+}
+
+
void BookmarkOwner::editBookmark()
{
if (selected.isNull())
@@ -190,7 +291,7 @@ bool BookmarkOwner::deleteBookmark()
else if (selected.isSeparator())
{
dialogCaption = i18n("Separator Deletion");
- dialogText = i18n("Are you sure you wish to remove this separator?", name);
+ dialogText = i18n("Are you sure you wish to remove this separator?");
}
else
{
@@ -215,125 +316,6 @@ bool BookmarkOwner::deleteBookmark()
}
-bool BookmarkOwner::supportsTabs() const
-{
- return true;
-}
-
-
-QString BookmarkOwner::currentUrl() const
-{
- return Application::instance()->mainWindow()->currentTab()->url().url();
-}
-
-
-QString BookmarkOwner::currentTitle() const
-{
- return Application::instance()->mainWindow()->currentTab()->view()->title();
-}
-
-
-void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bookmark)
-{
- QList<KUrl> urlList = bookmark.groupUrlList();
-
- if (urlList.length() > 8)
- {
- if ( !(KMessageBox::warningContinueCancel( Application::instance()->mainWindow(),
- i18ncp("%1=Number of tabs. Value is always >=8",
- "You are about to open %1 tabs.\nAre you sure?",
- "You are about to open %1 tabs.\nAre you sure?",
- urlList.length()),
- "",
- KStandardGuiItem::cont(),
- KStandardGuiItem::cancel(),
- "openFolderInTabs_askAgain"
- ) == KMessageBox::Continue)
- )
- return;
- }
-
- QList<KUrl>::iterator url;
- for (url = urlList.begin(); url != urlList.end(); ++url)
- {
- emit openUrl(*url, Rekonq::NewFocusedTab);
- }
-}
-
-
-QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const
-{
- QList< QPair<QString, QString> > bkList;
- int tabNumber = Application::instance()->mainWindow()->mainView()->count();
-
- for (int i = 0; i < tabNumber; i++)
- {
- QPair<QString, QString> item;
- item.first = Application::instance()->mainWindow()->mainView()->webTab(i)->view()->title();
- item.second = Application::instance()->mainWindow()->mainView()->webTab(i)->url().url();
- bkList += item;
- }
- return bkList;
-}
-
-
-void BookmarkOwner::bookmarkSelected(const KBookmark &bookmark)
-{
- selected = bookmark;
-}
-
-
-void BookmarkOwner::openBookmark()
-{
- emit openUrl(selected.url(), Rekonq::CurrentTab);
-}
-
-
-void BookmarkOwner::openBookmarkInNewTab()
-{
- emit openUrl(selected.url(), Rekonq::NewTab);
-}
-
-
-void BookmarkOwner::openBookmarkInNewWindow()
-{
- emit openUrl(selected.url(), Rekonq::NewWindow);
-}
-
-
-void BookmarkOwner::openBookmarkFolder()
-{
- if (!selected.isGroup())
- return;
-
- QList<KUrl> urlList = selected.toGroup().groupUrlList();
-
- if (urlList.length() > 8)
- {
- if (KMessageBox::warningContinueCancel(
- Application::instance()->mainWindow(),
- i18n("You are about to open %1 tabs.\nAre you sure?", urlList.length()))
- != KMessageBox::Continue
- )
- return;
- }
-
- foreach (KUrl url, urlList)
- {
- emit openUrl(url, Rekonq::NewFocusedTab);
- }
-}
-
-
-void BookmarkOwner::copyLink()
-{
- if (selected.isNull())
- return;
-
- QApplication::clipboard()->setText(selected.url().url());
-}
-
-
void BookmarkOwner::setupActions()
{
createAction(OPEN, i18n("Open"), "tab-new",
diff --git a/src/bookmarks/bookmarkowner.h b/src/bookmarks/bookmarkowner.h
index 395edf54..abb65c36 100644
--- a/src/bookmarks/bookmarkowner.h
+++ b/src/bookmarks/bookmarkowner.h
@@ -37,15 +37,14 @@
// KDE Includes
#include <KBookmarkOwner>
+// Forward Declarations
class KAction;
-
/**
* Reimplementation of KBookmarkOwner, this class allows to manage
- * bookmarks as actions
- *
+ * bookmarks as actions.
*/
-class REKONQ_TESTS_EXPORT BookmarkOwner : public QObject , public KBookmarkOwner
+class REKONQ_TESTS_EXPORT BookmarkOwner : public QObject, public KBookmarkOwner
{
Q_OBJECT
@@ -74,6 +73,25 @@ public:
KAction* action(const BookmarkAction &bmAction);
/**
+ * @return the current page's title.
+ */
+ 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;
+
+ /**
* 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.
@@ -86,28 +104,6 @@ public:
Qt::MouseButtons mouseButtons,
Qt::KeyboardModifiers keyboardModifiers);
-
- /**
- * this method, from KBookmarkOwner interface, allows to add the current page
- * to the bookmark list, returning the URL page as QString.
- *
- * @return the current page's URL
- */
- virtual QString currentUrl() const;
-
- /**
- * this method, from KBookmarkOwner interface, allows to add the current page
- * to the bookmark list, returning the title's page as QString.
- *
- * @return the current page's title
- */
- virtual QString currentTitle() const;
-
- /**
- * This function returns whether the owner supports tabs.
- */
- virtual bool supportsTabs() const;
-
/**
* Called if the user wants to open every bookmark in this folder in a new tab.
* The default implementation does nothing.
@@ -115,14 +111,10 @@ public:
*/
virtual void openFolderinTabs(const KBookmarkGroup &bookmark);
- virtual QList< QPair<QString, QString> > currentBookmarkList() const;
-
signals:
/**
* This signal is emitted when an url has to be loaded
- *
* @param url the URL to load
- *
*/
void openUrl(const KUrl &, const Rekonq::OpenType &);