summaryrefslogtreecommitdiff
path: root/src/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/bookmarkmanager.cpp353
-rw-r--r--src/bookmarks/bookmarkmanager.h172
-rw-r--r--src/bookmarks/bookmarkowner.cpp428
-rw-r--r--src/bookmarks/bookmarkowner.h159
-rw-r--r--src/bookmarks/bookmarkscontextmenu.cpp164
-rw-r--r--src/bookmarks/bookmarkscontextmenu.h57
-rw-r--r--src/bookmarks/bookmarkspanel.cpp169
-rw-r--r--src/bookmarks/bookmarkspanel.h93
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp624
-rw-r--r--src/bookmarks/bookmarkstoolbar.h115
-rw-r--r--src/bookmarks/bookmarkstreemodel.cpp407
-rw-r--r--src/bookmarks/bookmarkstreemodel.h116
12 files changed, 0 insertions, 2857 deletions
diff --git a/src/bookmarks/bookmarkmanager.cpp b/src/bookmarks/bookmarkmanager.cpp
deleted file mode 100644
index 33f3c662..00000000
--- a/src/bookmarks/bookmarkmanager.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "bookmarkmanager.h"
-#include "bookmarkmanager.moc"
-
-// Local Includes
-#include "application.h"
-#include "bookmarkspanel.h"
-#include "bookmarkstoolbar.h"
-#include "bookmarkowner.h"
-#include "iconmanager.h"
-#include "mainwindow.h"
-#include "webtab.h"
-
-// KDE Includes
-#include <KActionCollection>
-#include <KStandardDirs>
-
-// Qt Includes
-#include <QtCore/QFile>
-
-
-BookmarkManager::BookmarkManager(QObject *parent)
- : QObject(parent)
- , m_manager(0)
- , m_owner(0)
- , m_actionCollection(new KActionCollection(this))
-{
- m_manager = KBookmarkManager::userBookmarksManager();
- const QString bookmarksFile = KStandardDirs::locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml"));
-
- if (!QFile::exists(bookmarksFile))
- {
- kDebug() << "copying of defaultbookmarks.xbel ...";
-
- QString bookmarksDefaultPath = KStandardDirs::locate("appdata" , "defaultbookmarks.xbel");
- KBookmarkManager *tempManager = KBookmarkManager::managerForExternalFile(bookmarksDefaultPath);
-
- copyBookmarkGroup(tempManager->root(), rootGroup());
- m_manager->emitChanged();
- delete tempManager;
- }
-
- connect(m_manager, SIGNAL(changed(QString, QString)), this, SLOT(slotBookmarksChanged()));
-
- // setup menu
- m_owner = new BookmarkOwner(m_manager, this);
- connect(m_owner, SIGNAL(openUrl(KUrl, Rekonq::OpenType)),
- this, SIGNAL(openUrl(KUrl, Rekonq::OpenType)));
-
- // bookmarks loading
- connect(this, SIGNAL(openUrl(KUrl, Rekonq::OpenType)), rApp, SLOT(loadUrl(KUrl, Rekonq::OpenType)));
-}
-
-
-BookmarkManager::~BookmarkManager()
-{
- delete m_manager;
-}
-
-
-KActionMenu* BookmarkManager::bookmarkActionMenu(QWidget *parent)
-{
- KMenu *menu = new KMenu(parent);
- KActionMenu *bookmarkActionMenu = new KActionMenu(menu);
- bookmarkActionMenu->setMenu(menu);
- bookmarkActionMenu->setText(i18n("&Bookmarks"));
- BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menu, m_actionCollection);
- bMenu->setParent(menu);
-
- return bookmarkActionMenu;
-}
-
-
-void BookmarkManager::registerBookmarkBar(BookmarkToolBar *toolbar)
-{
- if (m_bookmarkToolBars.contains(toolbar))
- return;
-
- m_bookmarkToolBars.append(toolbar);
-}
-
-
-void BookmarkManager::removeBookmarkBar(BookmarkToolBar *toolbar)
-{
- m_bookmarkToolBars.removeOne(toolbar);
-}
-
-
-void BookmarkManager::registerBookmarkPanel(BookmarksPanel *panel)
-{
- if (panel && !m_bookmarkPanels.contains(panel))
- {
- m_bookmarkPanels.append(panel);
- connect(panel, SIGNAL(expansionChanged()), this, SLOT(slotPanelChanged()));
- }
-}
-
-
-void BookmarkManager::removeBookmarkPanel(BookmarksPanel *panel)
-{
- if (!panel)
- return;
-
- m_bookmarkPanels.removeOne(panel);
- panel->disconnect(this);
-
- if (m_bookmarkPanels.isEmpty())
- emitChanged();
-}
-
-
-QAction* BookmarkManager::actionByName(const QString &name)
-{
- QAction *action = m_actionCollection->action(name);
- if (action)
- return action;
- return new QAction(this);
-}
-
-
-KBookmarkGroup BookmarkManager::rootGroup()
-{
- return m_manager->root();
-}
-
-
-QList<KBookmark> BookmarkManager::find(const QString &text)
-{
- QList<KBookmark> list;
-
- KBookmarkGroup root = rootGroup();
- if (!root.isNull())
- for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark))
- find(&list, bookmark, text);
-
- return list;
-}
-
-
-KBookmark BookmarkManager::bookmarkForUrl(const KUrl &url)
-{
- KBookmarkGroup root = rootGroup();
- if (root.isNull())
- return KBookmark();
-
- return bookmarkForUrl(root, url);
-}
-
-
-void BookmarkManager::slotBookmarksChanged()
-{
- Q_FOREACH(BookmarkToolBar * bookmarkToolBar, m_bookmarkToolBars)
- {
- if (bookmarkToolBar)
- {
- bookmarkToolBar->toolBar()->clear();
- fillBookmarkBar(bookmarkToolBar);
- }
- }
-
- // this update about:bookmarks page...
- if (rApp->mainWindow()
- && rApp->mainWindow()->currentTab()
- && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")
- )
- rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab);
-
- emit bookmarksUpdated();
-}
-
-
-void BookmarkManager::fillBookmarkBar(BookmarkToolBar *toolBar)
-{
- KBookmarkGroup root = m_manager->toolbar();
- if (root.isNull())
- return;
-
- for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark))
- {
- if (bookmark.isGroup())
- {
- KBookmarkActionMenu *menuAction = new KBookmarkActionMenu(bookmark.toGroup(), this);
- menuAction->setDelayed(false);
- BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menuAction->menu(), bookmark.address());
- bMenu->setParent(menuAction->menu());
-
- connect(menuAction->menu(), SIGNAL(aboutToShow()), toolBar, SLOT(menuDisplayed()));
- connect(menuAction->menu(), SIGNAL(aboutToHide()), toolBar, SLOT(menuHidden()));
-
- toolBar->toolBar()->addAction(menuAction);
- toolBar->toolBar()->widgetForAction(menuAction)->installEventFilter(toolBar);
- }
- else if (bookmark.isSeparator())
- {
- toolBar->toolBar()->addSeparator();
- }
- else
- {
- KBookmarkAction *action = new KBookmarkAction(bookmark, m_owner, this);
- action->setIcon(rApp->iconManager()->iconForUrl(KUrl(bookmark.url())));
- connect(action, SIGNAL(hovered()), toolBar, SLOT(actionHovered()));
- toolBar->toolBar()->addAction(action);
- toolBar->toolBar()->widgetForAction(action)->installEventFilter(toolBar);
- }
- }
-}
-
-
-void BookmarkManager::slotPanelChanged()
-{
- Q_FOREACH(BookmarksPanel * panel, m_bookmarkPanels)
- {
- if (panel && panel != sender())
- panel->loadFoldedState();
- }
- if (rApp->mainWindow()
- && rApp->mainWindow()->currentTab()
- && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")
- )
- rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab);
-}
-
-
-void BookmarkManager::find(QList<KBookmark> *list, const KBookmark &bookmark, const QString &text)
-{
- if (bookmark.isGroup())
- {
- KBookmarkGroup group = bookmark.toGroup();
- for (KBookmark bm = group.first(); !bm.isNull(); bm = group.next(bm))
- find(list, bm, text);
- }
- else
- {
- QStringList words = text.split(' ');
- bool matches = true;
- Q_FOREACH(const QString & word, words)
- {
- if (!bookmark.url().url().contains(word, Qt::CaseInsensitive)
- && !bookmark.fullText().contains(word, Qt::CaseInsensitive))
- {
- matches = false;
- break;
- }
- }
- if (matches)
- *list << bookmark;
- }
-}
-
-
-KBookmark BookmarkManager::bookmarkForUrl(const KBookmark &bookmark, const KUrl &url)
-{
- KBookmark found;
-
- if (bookmark.isGroup())
- {
- KBookmarkGroup group = bookmark.toGroup();
- KBookmark bookmark = group.first();
-
- while (!bookmark.isNull() && found.isNull())
- {
- found = bookmarkForUrl(bookmark, url);
- bookmark = group.next(bookmark);
- }
- }
- else if (!bookmark.isSeparator() && bookmark.url() == url)
- {
- found = bookmark;
- }
-
- return found;
-}
-
-
-void BookmarkManager::copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup)
-{
- KBookmark bookmark = groupToCopy.first();
- while (!bookmark.isNull())
- {
- if (bookmark.isGroup())
- {
- KBookmarkGroup newDestGroup = destGroup.createNewFolder(bookmark.text());
- if (bookmark.toGroup().isToolbarGroup())
- {
- newDestGroup.internalElement().setAttribute("toolbar", "yes");
- newDestGroup.setIcon("bookmark-toolbar");
- }
- copyBookmarkGroup(bookmark.toGroup(), newDestGroup);
- }
- else if (bookmark.isSeparator())
- {
- destGroup.createNewSeparator();
- }
- else
- {
- destGroup.addBookmark(bookmark.text(), bookmark.url());
- }
- bookmark = groupToCopy.next(bookmark);
- }
-}
-
-
-void BookmarkManager::slotEditBookmarks()
-{
- m_manager->slotEditBookmarks();
-}
-
-
-KBookmark BookmarkManager::findByAddress(const QString &address)
-{
- return m_manager->findByAddress(address);
-}
-
-
-void BookmarkManager::openFolderinTabs(const KBookmarkGroup &bm)
-{
- m_owner->openFolderinTabs(bm);
-}
-
-
-void BookmarkManager::emitChanged()
-{
- m_manager->emitChanged();
-}
diff --git a/src/bookmarks/bookmarkmanager.h b/src/bookmarks/bookmarkmanager.h
deleted file mode 100644
index e5528a8a..00000000
--- a/src/bookmarks/bookmarkmanager.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef BOOKMARK_MANAGER_H
-#define BOOKMARK_MANAGER_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// KDE Includes
-#include <KBookmark>
-
-// Qt Includes
-#include <QObject>
-
-// Forward Declarations
-class BookmarksPanel;
-class BookmarkToolBar;
-class BookmarkOwner;
-class BookmarkMenu;
-
-class KAction;
-class KActionCollection;
-class KActionMenu;
-class KBookmarkGroup;
-class KBookmarkManager;
-class KUrl;
-
-class QAction;
-
-
-/**
- * This class represent the interface to rekonq bookmarks system.
- * All rekonq needs (Bookmarks Menu, Bookmarks Toolbar) is provided
- * from this class.
- * So it implements code to have each one.
- */
-class BookmarkManager : public QObject
-{
- Q_OBJECT
-
-public:
- /**
- * @short Class constructor.
- * Connect BookmarksProvider with bookmarks source
- * (actually konqueror's bookmarks).
- * @param parent The MainWindow to provide bookmarks objects.
- */
- BookmarkManager(QObject *parent = 0);
- ~BookmarkManager();
-
- /**
- * @short Get the Bookmarks Menu Action
- * @param the parent widget
- * @return the Bookmarks Menu
- */
- KActionMenu* bookmarkActionMenu(QWidget *parent);
-
- /**
- * @short set the Bookmarks Toolbar Action
- */
- void registerBookmarkBar(BookmarkToolBar *toolbar);
- void removeBookmarkBar(BookmarkToolBar *toolbar);
-
- void registerBookmarkPanel(BookmarksPanel *panel);
- void removeBookmarkPanel(BookmarksPanel *panel);
-
- /**
- * @short Get action by name
- * This method returns poiner bookmark action of given name.
- * @pre m_actionCollection != NULL
- * @param name Name of action you want to get
- * @return It returns actions if one exists or empty object
- */
- QAction* actionByName(const QString &name);
-
- /**
- * returns Bookmark Manager root group
- *
- * @return the root bookmark group
- */
- KBookmarkGroup rootGroup();
-
- inline KBookmarkManager* manager()
- {
- return m_manager;
- }
-
- inline BookmarkOwner* owner()
- {
- return m_owner;
- }
-
- QList<KBookmark> find(const QString &text);
-
- KBookmark bookmarkForUrl(const KUrl &url);
-
- KBookmark findByAddress(const QString &);
- void openFolderinTabs(const KBookmarkGroup &bm);
- void emitChanged();
-
- static inline QString bookmark_mime_type()
- {
- return QL1S("application/x-rekonq-bookmark");
- }
-
-public Q_SLOTS:
- /**
- * @short Waits for signal that the group with the address has been modified by the caller.
- * Waits for signal that the group (or any of its children) with the address
- * @p groupAddress (e.g. "/4/5") has been modified by the caller @p caller.
- * @param groupAddress bookmark group address
- * @param caller caller that modified the bookmarks
- * @see KBookmarkManager::changed
- */
- void slotBookmarksChanged();
- void fillBookmarkBar(BookmarkToolBar *toolBar);
-
- void slotEditBookmarks();
-
-private Q_SLOTS:
- void slotPanelChanged();
-
-Q_SIGNALS:
- /**
- * @short This signal is emitted when an url has to be loaded
- */
- void openUrl(const KUrl &, const Rekonq::OpenType &);
-
- void bookmarksUpdated();
-
-private:
- void find(QList<KBookmark> *list, const KBookmark &bookmark, const QString &text);
- KBookmark bookmarkForUrl(const KBookmark &bookmark, const KUrl &url);
- void copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup);
-
- KBookmarkManager *m_manager;
- BookmarkOwner *m_owner;
- KActionCollection *m_actionCollection;
- QList<BookmarkToolBar *> m_bookmarkToolBars;
- QList<BookmarksPanel *> m_bookmarkPanels;
-};
-
-
-#endif // BOOKMARK_MANAGER_H
diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp
deleted file mode 100644
index 430ec5c3..00000000
--- a/src/bookmarks/bookmarkowner.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "bookmarkowner.h"
-#include "bookmarkowner.moc"
-
-// Local Includes
-#include "application.h"
-#include "bookmarkmanager.h"
-#include "mainview.h"
-#include "mainwindow.h"
-#include "webtab.h"
-
-// KDE Includes
-#include <KBookmarkDialog>
-#include <KLocalizedString>
-#include <KMessageBox>
-
-// Qt Includes
-#include <QClipboard>
-
-// Nepomuk config include
-#include "config-nepomuk.h"
-
-#ifdef HAVE_NEPOMUK
-// Local Nepomuk Includes
-#include "resourcelinkdialog.h"
-
-// Nepomuk Includes
-#include <Nepomuk/Resource>
-#include <Nepomuk/Vocabulary/NFO>
-#endif
-
-
-BookmarkOwner::BookmarkOwner(KBookmarkManager *manager, QObject *parent)
- : QObject(parent)
- , KBookmarkOwner()
- , m_manager(manager)
-{
-}
-
-
-KAction* BookmarkOwner::createAction(const KBookmark &bookmark, const BookmarkAction &bmAction)
-{
- switch (bmAction)
- {
- case OPEN:
- return createAction(i18n("Open"), "tab-new",
- i18n("Open bookmark in current tab"), SLOT(openBookmark(KBookmark)), bookmark);
- case OPEN_IN_TAB:
- return createAction(i18n("Open in New Tab"), "tab-new",
- i18n("Open bookmark in new tab"), SLOT(openBookmarkInNewTab(KBookmark)), bookmark);
- case OPEN_IN_WINDOW:
- return createAction(i18n("Open in New Window"), "window-new",
- i18n("Open bookmark in new window"), SLOT(openBookmarkInNewWindow(KBookmark)), bookmark);
- case OPEN_FOLDER:
- return createAction(i18n("Open Folder in Tabs"), "tab-new",
- i18n("Open all the bookmarks in folder in tabs"), SLOT(openBookmarkFolder(KBookmark)), bookmark);
- case BOOKMARK_PAGE:
- return createAction(i18n("Add Bookmark"), "bookmark-new",
- i18n("Bookmark current page"), SLOT(bookmarkCurrentPage(KBookmark)), bookmark);
- case NEW_FOLDER:
- return createAction(i18n("New Folder"), "folder-new",
- i18n("Create a new bookmark folder"), SLOT(newBookmarkFolder(KBookmark)), bookmark);
- case NEW_SEPARATOR:
- return createAction(i18n("New Separator"), "edit-clear",
- i18n("Create a new bookmark separator"), SLOT(newSeparator(KBookmark)), bookmark);
- case COPY:
- return createAction(i18n("Copy Link"), "edit-copy",
- i18n("Copy the bookmark's link address"), SLOT(copyLink(KBookmark)), bookmark);
- case EDIT:
- return createAction(i18n("Edit"), "configure",
- i18n("Edit the bookmark"), SLOT(editBookmark(KBookmark)), bookmark);
-#ifdef HAVE_NEPOMUK
- case FANCYBOOKMARK:
- return createAction(i18n("Fancy Bookmark"), "nepomuk",
- i18n("Link Nepomuk resources"), SLOT(fancyBookmark(KBookmark)), bookmark);
-#endif
- case DELETE:
- return createAction(i18n("Delete"), "edit-delete",
- i18n("Delete the bookmark"), SLOT(deleteBookmark(KBookmark)), bookmark);
- case SET_TOOLBAR_FOLDER:
- return createAction(i18n("Set as toolbar folder"), "bookmark-toolbar",
- "", SLOT(setToolBarFolder(KBookmark)), bookmark);
- case UNSET_TOOLBAR_FOLDER:
- return createAction(i18n("Unset this folder as the toolbar folder"), "bookmark-toolbar",
- "", SLOT(unsetToolBarFolder()), bookmark);
- default:
- ASSERT_NOT_REACHED(unknown BookmarkAction);
- return 0;
- }
-}
-
-
-QString BookmarkOwner::currentTitle() const
-{
- return rApp->mainWindow()->currentTab()->view()->title();
-}
-
-
-QString BookmarkOwner::currentUrl() const
-{
- return rApp->mainWindow()->currentTab()->url().url();
-}
-
-
-QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const
-{
- QList< QPair<QString, QString> > bkList;
- MainView *view = rApp->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)
- openBookmarkInNewTab(bookmark);
- else
- openBookmark(bookmark);
-}
-
-
-void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bkGoup)
-{
- QList<KUrl> urlList = bkGoup.groupUrlList();
-
- if (urlList.length() > 8)
- {
- if (KMessageBox::warningContinueCancel(
- rApp->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()))
- != KMessageBox::Continue
- )
- return;
- }
-
- Q_FOREACH(const KUrl & url, urlList)
- {
- emit openUrl(url, Rekonq::NewFocusedTab);
- }
-}
-
-
-void BookmarkOwner::openBookmark(const KBookmark &bookmark)
-{
- emit openUrl(bookmark.url(), Rekonq::CurrentTab);
-}
-
-
-void BookmarkOwner::openBookmarkInNewTab(const KBookmark &bookmark)
-{
- emit openUrl(bookmark.url(), Rekonq::NewTab);
-}
-
-
-void BookmarkOwner::openBookmarkInNewWindow(const KBookmark &bookmark)
-{
- emit openUrl(bookmark.url(), Rekonq::NewWindow);
-}
-
-
-void BookmarkOwner::openBookmarkFolder(const KBookmark &bookmark)
-{
- Q_ASSERT(bookmark.isGroup());
- openFolderinTabs(bookmark.toGroup());
-}
-
-
-KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark)
-{
- KBookmarkGroup parent;
-
- if (!bookmark.isNull())
- {
- if (bookmark.isGroup())
- parent = bookmark.toGroup();
- else
- parent = bookmark.parentGroup();
- }
- else
- {
- parent = rApp->bookmarkManager()->rootGroup();
-#ifdef HAVE_NEPOMUK
- Nepomuk::Resource nfoResource;
- nfoResource = ((QUrl)currentUrl());
- nfoResource.addType(Nepomuk::Vocabulary::NFO::Website());
- nfoResource.setLabel(currentTitle());
-#endif
- }
-
- KBookmark newBk = parent.addBookmark(currentTitle(), KUrl(currentUrl()));
- if (!bookmark.isNull())
- parent.moveBookmark(newBk, bookmark);
-
- m_manager->emitChanged(parent);
- return newBk;
-}
-
-
-KBookmarkGroup BookmarkOwner::newBookmarkFolder(const KBookmark &bookmark)
-{
- KBookmarkGroup newBk;
- KBookmarkDialog *dialog = bookmarkDialog(m_manager, 0);
- QString folderName = i18n("New folder");
-
- if (!bookmark.isNull())
- {
- if (bookmark.isGroup())
- {
- newBk = dialog->createNewFolder(folderName, bookmark);
- }
- else
- {
- newBk = dialog->createNewFolder(folderName, bookmark.parentGroup());
- if (!newBk.isNull())
- {
- KBookmarkGroup parent = newBk.parentGroup();
- parent.moveBookmark(newBk, bookmark);
- m_manager->emitChanged(parent);
- }
- }
- }
- else
- {
- newBk = dialog->createNewFolder(folderName);
- }
-
- delete dialog;
- return newBk;
-}
-
-
-KBookmark BookmarkOwner::newSeparator(const KBookmark &bookmark)
-{
- KBookmark newBk;
-
- if (!bookmark.isNull())
- {
- if (bookmark.isGroup())
- {
- newBk = bookmark.toGroup().createNewSeparator();
- }
- else
- {
- newBk = bookmark.parentGroup().createNewSeparator();
- newBk.parentGroup().moveBookmark(newBk, bookmark);
- }
- }
- else
- {
- newBk = rApp->bookmarkManager()->rootGroup().createNewSeparator();
- }
-
- newBk.setIcon("edit-clear");
-
- m_manager->emitChanged(newBk.parentGroup());
- return newBk;
-}
-
-
-void BookmarkOwner::copyLink(const KBookmark &bookmark)
-{
- if (bookmark.isNull())
- return;
-
- QApplication::clipboard()->setText(bookmark.url().url());
-}
-
-
-void BookmarkOwner::editBookmark(KBookmark bookmark)
-{
- if (bookmark.isNull())
- return;
-
- KBookmarkDialog *dialog = bookmarkDialog(m_manager, 0);
- dialog->editBookmark(bookmark);
-
- delete dialog;
-}
-
-
-#ifdef HAVE_NEPOMUK
-void BookmarkOwner::fancyBookmark(KBookmark bookmark)
-{
- Nepomuk::Resource nfoResource = (KUrl)bookmark.url();
- Nepomuk::ResourceLinkDialog r(nfoResource);
- r.exec();
-
-}
-#endif
-
-bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark)
-{
- if (bookmark.isNull())
- return false;
-
- KBookmarkGroup bmg = bookmark.parentGroup();
- QString dialogCaption, dialogText;
-
- if (bookmark.isGroup())
- {
- dialogCaption = i18n("Bookmark Folder Deletion");
- dialogText = i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bookmark.fullText());
- }
- else if (bookmark.isSeparator())
- {
- dialogCaption = i18n("Separator Deletion");
- dialogText = i18n("Are you sure you wish to remove this separator?");
- }
- else
- {
- dialogCaption = i18n("Bookmark Deletion");
- dialogText = i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bookmark.fullText());
- }
-
- if (KMessageBox::warningContinueCancel(
- 0,
- dialogText,
- dialogCaption,
- KStandardGuiItem::del(),
- KStandardGuiItem::cancel(),
- "bookmarkDeletition_askAgain")
- != KMessageBox::Continue
- )
- return false;
-
- bmg.deleteBookmark(bookmark);
-#ifdef HAVE_NEPOMUK
- Nepomuk::Resource nfoResource(bookmark.url());
- nfoResource.remove();
-#endif
- m_manager->emitChanged(bmg);
- return true;
-}
-
-
-void BookmarkOwner::setToolBarFolder(KBookmark bookmark)
-{
- if (!bookmark.isGroup())
- return;
-
- unsetToolBarFolder();
- bookmark.internalElement().setAttribute("toolbar", "yes");
- bookmark.setIcon("bookmark-toolbar");
-
- m_manager->emitChanged();
-}
-
-
-void BookmarkOwner::unsetToolBarFolder()
-{
- KBookmarkGroup toolbar = m_manager->toolbar();
- if (!toolbar.isNull())
- {
- toolbar.internalElement().setAttribute("toolbar", "no");
- toolbar.setIcon("");
- }
- m_manager->emitChanged();
-}
-
-
-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);
- connect(act, SIGNAL(triggered(KBookmark)), this, slot);
- return act;
-}
-
-
-// -------------------------------------------------------------------------------------------------
-
-
-CustomBookmarkAction::CustomBookmarkAction(const KBookmark &bookmark, const KIcon &icon, const QString &text, QObject *parent)
- : KAction(icon, text, parent)
- , m_bookmark(bookmark)
-{
- connect(this, SIGNAL(triggered()), this, SLOT(onActionTriggered()));
-}
-
-void CustomBookmarkAction::onActionTriggered()
-{
- emit triggered(m_bookmark);
-}
diff --git a/src/bookmarks/bookmarkowner.h b/src/bookmarks/bookmarkowner.h
deleted file mode 100644
index f0b238b9..00000000
--- a/src/bookmarks/bookmarkowner.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef BOOKMARKOWNER_H
-#define BOOKMARKOWNER_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// Nepomuk config include
-#include "config-nepomuk.h"
-
-// KDE Includes
-#include <KAction>
-#include <KBookmarkOwner>
-
-
-/**
- * This class allows to manage bookmarks as actions.
- */
-class REKONQ_TESTS_EXPORT BookmarkOwner : public QObject, public KBookmarkOwner
-{
- Q_OBJECT
-
-public:
- explicit BookmarkOwner(KBookmarkManager *manager, QObject *parent = 0);
-
- enum BookmarkAction
- {
- OPEN = 0,
- OPEN_IN_TAB,
- OPEN_IN_WINDOW,
- OPEN_FOLDER,
- BOOKMARK_PAGE,
- NEW_FOLDER,
- NEW_SEPARATOR,
- COPY,
- EDIT,
-#ifdef HAVE_NEPOMUK
- FANCYBOOKMARK,
-#endif
- DELETE,
- NUM_ACTIONS,
- SET_TOOLBAR_FOLDER,
- UNSET_TOOLBAR_FOLDER
- };
-
- /**
- * @return A new action for the given bookmark.
- */
- KAction* createAction(const KBookmark &bookmark, const BookmarkAction &bmAction);
-
- // @{
- /**
- * Functions to get current information.
- */
- virtual QString currentTitle() const;
- virtual QString currentUrl() const;
- virtual QList< QPair<QString, QString> > currentBookmarkList() const;
- // @}
-
- virtual bool supportsTabs() const
- {
- return true;
- }
-
- // @{
- /**
- * This functions emit signals that open the selected URLs
- */
- virtual void openBookmark(const KBookmark &bookmark,
- Qt::MouseButtons mouseButtons,
- Qt::KeyboardModifiers keyboardModifiers);
- virtual void openFolderinTabs(const KBookmarkGroup &bkGoup);
- // @}
-
-public Q_SLOTS:
- void openBookmark(const KBookmark &bookmark);
- void openBookmarkInNewTab(const KBookmark &bookmark);
- void openBookmarkInNewWindow(const KBookmark &bookmark);
- void openBookmarkFolder(const KBookmark &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);
-#ifdef HAVE_NEPOMUK
- void fancyBookmark(KBookmark bookmark);
-#endif
- bool deleteBookmark(const KBookmark &bookmark);
- void setToolBarFolder(KBookmark bookmark = KBookmark());
- void unsetToolBarFolder();
-
-Q_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 &);
-
-private:
- KAction* createAction(const QString &text, const QString &icon,
- const QString &help, const char *slot,
- const KBookmark &bookmark);
-
- KBookmarkManager *m_manager;
-};
-
-
-// -----------------------------------------------------------------------------------------------
-
-
-class CustomBookmarkAction : public KAction
-{
- Q_OBJECT
-
-public:
- CustomBookmarkAction(const KBookmark &bookmark, const KIcon &icon, const QString &text, QObject *parent);
-
-Q_SIGNALS:
- void triggered(const KBookmark &);
-
-private Q_SLOTS:
- void onActionTriggered();
-
-private:
- KBookmark m_bookmark;
-};
-
-#endif // BOOKMARKOWNER_H
diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp
deleted file mode 100644
index 65f7994f..00000000
--- a/src/bookmarks/bookmarkscontextmenu.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-* Copyright (c) 2011-2012 by Phaneendra Hegde <pnh.pes@gmail.com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "bookmarkscontextmenu.h"
-
-// Nepomuk config include
-#include "config-nepomuk.h"
-
-// Local Includes
-#include "bookmarkowner.h"
-#include "bookmarkmanager.h"
-#include "application.h"
-
-// KDE Includes
-#include <KBookmarkManager>
-
-
-BookmarksContextMenu::BookmarksContextMenu(const KBookmark &bookmark,
- KBookmarkManager *manager,
- BookmarkOwner *owner,
- bool nullForced,
- QWidget *parent
- )
- : KBookmarkContextMenu(bookmark, manager, owner, parent)
- , m_bmOwner(owner)
- , m_nullForced(nullForced)
-{
-}
-
-
-void BookmarksContextMenu::addBookmarkActions()
-{
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_IN_TAB));
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_IN_WINDOW));
-
- addSeparator();
-
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE));
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER));
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR));
-
- addSeparator();
-
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::COPY));
-
- addSeparator();
-
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::EDIT));
-#ifdef HAVE_NEPOMUK
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::FANCYBOOKMARK));
-#endif
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE));
-}
-
-
-void BookmarksContextMenu::addFolderActions()
-{
- KBookmarkGroup group = bookmark().toGroup();
-
- if (bookmark().internalElement().attributeNode("toolbar").value() == "yes")
- {
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER));
- }
- else
- {
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::SET_TOOLBAR_FOLDER));
- }
-
- if (!group.first().isNull())
- {
- KBookmark child = group.first();
-
- while (child.isGroup() || child.isSeparator())
- {
- child = group.next(child);
- }
-
- if (!child.isNull())
- {
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_FOLDER));
- addSeparator();
- }
- }
-
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE));
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER));
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR));
-
- addSeparator();
-
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::EDIT));
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE));
-}
-
-
-void BookmarksContextMenu::addSeparatorActions()
-{
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE));
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER));
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR));
-
- addSeparator();
-
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE));
-}
-
-
-void BookmarksContextMenu::addNullActions()
-{
- KBookmarkManager *mngr = rApp->bookmarkManager()->manager();
- if (mngr->toolbar().hasParent())
- {
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER));
- }
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE));
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER));
- addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR));
-}
-
-
-void BookmarksContextMenu::addActions()
-{
- if (bookmark().isNull() || m_nullForced)
- {
- addNullActions();
- }
- else if (bookmark().isSeparator())
- {
- addSeparatorActions();
- }
- else if (bookmark().isGroup())
- {
- addFolderActions();
- }
- else
- {
- addBookmarkActions();
- }
-}
diff --git a/src/bookmarks/bookmarkscontextmenu.h b/src/bookmarks/bookmarkscontextmenu.h
deleted file mode 100644
index c927f3a6..00000000
--- a/src/bookmarks/bookmarkscontextmenu.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef BOOKMARKS_CONTEXT_MENU_H
-#define BOOKMARKS_CONTEXT_MENU_H
-
-// KDE Includes
-#include <KBookmarkMenu>
-
-// Forward Declarations
-class BookmarkOwner;
-
-
-class BookmarksContextMenu : public KBookmarkContextMenu
-{
-public:
- BookmarksContextMenu(const KBookmark &bookmark,
- KBookmarkManager *manager,
- BookmarkOwner *owner,
- bool nullForced = false,
- QWidget *parent = 0);
- virtual void addActions();
-
-private:
- void addFolderActions();
- void addBookmarkActions();
- void addSeparatorActions();
- void addNullActions();
-
- BookmarkOwner *m_bmOwner;
- bool m_nullForced;
-};
-
-#endif // BOOKMARKS_CONTEXT_MENU_H
diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp
deleted file mode 100644
index 2b2a7ea9..00000000
--- a/src/bookmarks/bookmarkspanel.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Nils Weigel <nehlsen at gmail dot com>
-* Copyright (C) 2010-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "bookmarkspanel.h"
-#include "bookmarkspanel.moc"
-
-// Auto Includes
-#include "rekonq.h"
-
-// Local Includes
-#include "application.h"
-#include "bookmarkmanager.h"
-#include "bookmarkstreemodel.h"
-#include "bookmarkscontextmenu.h"
-#include "bookmarkowner.h"
-#include "paneltreeview.h"
-#include "urlfilterproxymodel.h"
-
-
-BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags)
- : UrlPanel(title, parent, flags)
- , _bkTreeModel(new BookmarksTreeModel(this))
- , _loadingState(false)
-{
- setObjectName("bookmarksPanel");
- setVisible(ReKonfig::showBookmarksPanel());
- panelTreeView()->setDragEnabled(true);
- panelTreeView()->setAcceptDrops(true);
- connect(_bkTreeModel, SIGNAL(bookmarksUpdated()), this, SLOT(loadFoldedState()));
-}
-
-
-BookmarksPanel::~BookmarksPanel()
-{
- ReKonfig::setShowBookmarksPanel(!isHidden());
-}
-
-
-void BookmarksPanel::loadFoldedState()
-{
- _loadingState = true;
- loadFoldedState(QModelIndex());
- _loadingState = false;
-}
-
-
-void BookmarksPanel::contextMenu(const QPoint &pos)
-{
- if (_loadingState)
- return;
-
- BookmarksContextMenu menu(bookmarkForIndex(panelTreeView()->indexAt(pos)),
- rApp->bookmarkManager()->manager(),
- rApp->bookmarkManager()->owner()
- );
-
- menu.exec(panelTreeView()->mapToGlobal(pos));
-}
-
-
-void BookmarksPanel::deleteBookmark()
-{
- QModelIndex index = panelTreeView()->currentIndex();
- if (_loadingState || !index.isValid())
- return;
-
- rApp->bookmarkManager()->owner()->deleteBookmark(bookmarkForIndex(index));
-}
-
-
-void BookmarksPanel::onCollapse(const QModelIndex &index)
-{
- if (_loadingState)
- return;
-
- bookmarkForIndex(index).internalElement().setAttribute("folded", "yes");
- emit expansionChanged();
-}
-
-
-void BookmarksPanel::onExpand(const QModelIndex &index)
-{
- if (_loadingState)
- return;
-
- bookmarkForIndex(index).internalElement().setAttribute("folded", "no");
- emit expansionChanged();
-}
-
-
-void BookmarksPanel::setup()
-{
- UrlPanel::setup();
-
- connect(panelTreeView(), SIGNAL(delKeyPressed()), this, SLOT(deleteBookmark()));
- connect(panelTreeView(), SIGNAL(collapsed(QModelIndex)), this, SLOT(onCollapse(QModelIndex)));
- connect(panelTreeView(), SIGNAL(expanded(QModelIndex)), this, SLOT(onExpand(QModelIndex)));
-
- loadFoldedState();
-}
-
-
-void BookmarksPanel::loadFoldedState(const QModelIndex &root)
-{
- QAbstractItemModel *model = panelTreeView()->model();
- if (!model)
- return;
-
- int count = model->rowCount(root);
- QModelIndex index;
-
- for (int i = 0; i < count; ++i)
- {
- index = model->index(i, 0, root);
- if (index.isValid())
- {
- KBookmark bm = bookmarkForIndex(index);
- if (bm.isGroup())
- {
- panelTreeView()->setExpanded(index, bm.toGroup().isOpen());
- loadFoldedState(index);
- }
- }
- }
-}
-
-
-KBookmark BookmarksPanel::bookmarkForIndex(const QModelIndex &index)
-{
- if (!index.isValid())
- return KBookmark();
-
- const UrlFilterProxyModel *proxyModel = static_cast<const UrlFilterProxyModel*>(index.model());
- QModelIndex originalIndex = proxyModel->mapToSource(index);
-
- BtmItem *node = static_cast<BtmItem*>(originalIndex.internalPointer());
- return node->getBkm();
-}
-
-
-QAbstractItemModel* BookmarksPanel::model()
-{
- return _bkTreeModel;
-}
diff --git a/src/bookmarks/bookmarkspanel.h b/src/bookmarks/bookmarkspanel.h
deleted file mode 100644
index 796b8315..00000000
--- a/src/bookmarks/bookmarkspanel.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Nils Weigel <nehlsen at gmail dot com>
-* Copyright (C) 2010-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef BOOKMARKSPANEL_H
-#define BOOKMARKSPANEL_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// Local Includes
-#include "urlpanel.h"
-
-// Forward Declarations
-class BookmarksTreeModel;
-
-class KBookmark;
-class QModelIndex;
-
-
-class REKONQ_TESTS_EXPORT BookmarksPanel : public UrlPanel
-{
- Q_OBJECT
-
-public:
- explicit BookmarksPanel(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~BookmarksPanel();
-
-public Q_SLOTS:
- void loadFoldedState();
-
-Q_SIGNALS:
- void expansionChanged();
-
-private Q_SLOTS:
- void contextMenu(const QPoint &pos);
-
- virtual void contextMenuItem(const QPoint &pos)
- {
- contextMenu(pos);
- }
- virtual void contextMenuGroup(const QPoint &pos)
- {
- contextMenu(pos);
- }
- virtual void contextMenuEmpty(const QPoint &pos)
- {
- contextMenu(pos);
- }
-
- void deleteBookmark();
- void onCollapse(const QModelIndex &index);
- void onExpand(const QModelIndex &index);
-
-private:
- virtual void setup();
-
- void loadFoldedState(const QModelIndex &root);
-
- KBookmark bookmarkForIndex(const QModelIndex &index);
-
- virtual QAbstractItemModel* model();
-
- BookmarksTreeModel *_bkTreeModel;
- bool _loadingState;
-};
-
-#endif // BOOKMARKSPANEL_H
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp
deleted file mode 100644
index ad8af326..00000000
--- a/src/bookmarks/bookmarkstoolbar.cpp
+++ /dev/null
@@ -1,624 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "bookmarkstoolbar.h"
-#include "bookmarkstoolbar.moc"
-
-// Local Includes
-#include "iconmanager.h"
-#include "bookmarkscontextmenu.h"
-#include "mainwindow.h"
-#include "application.h"
-#include "bookmarkmanager.h"
-#include "bookmarkowner.h"
-#include "webtab.h"
-
-// Qt Includes
-#include <QtGui/QFrame>
-#include <QtGui/QActionEvent>
-
-
-BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,
- KBookmarkOwner *owner,
- KMenu *menu,
- KActionCollection* actionCollection)
- : KBookmarkMenu(manager, owner, menu, actionCollection)
-{
-}
-
-
-BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,
- KBookmarkOwner *owner,
- KMenu *parentMenu,
- const QString &parentAddress)
- : KBookmarkMenu(manager, owner, parentMenu, parentAddress)
-{
-}
-
-
-BookmarkMenu::~BookmarkMenu()
-{
- kDebug() << "Deleting BookmarkMenu.. See http://svn.reviewboard.kde.org/r/5606/ about.";
-}
-
-
-KMenu * BookmarkMenu::contextMenu(QAction *act)
-{
- KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(act);
- if (!action)
- return 0;
- return new BookmarksContextMenu(action->bookmark(), manager(), static_cast<BookmarkOwner*>(owner()));
-}
-
-
-QAction * BookmarkMenu::actionForBookmark(const KBookmark &bookmark)
-{
- if (bookmark.isGroup())
- {
- KBookmarkActionMenu *actionMenu = new KBookmarkActionMenu(bookmark, this);
- BookmarkMenu *menu = new BookmarkMenu(manager(), owner(), actionMenu->menu(), bookmark.address());
- // An hack to get rid of bug 219274
- connect(actionMenu, SIGNAL(hovered()), menu, SLOT(slotAboutToShow()));
- return actionMenu;
- }
- else if (bookmark.isSeparator())
- {
- return KBookmarkMenu::actionForBookmark(bookmark);
- }
- else
- {
- KBookmarkAction *action = new KBookmarkAction(bookmark, owner(), this);
- action->setIcon(rApp->iconManager()->iconForUrl(KUrl(bookmark.url())));
- connect(action, SIGNAL(hovered()), this, SLOT(actionHovered()));
- return action;
- }
-}
-
-
-void BookmarkMenu::refill()
-{
- clear();
- fillBookmarks();
-
- if (parentMenu()->actions().count() > 0)
- parentMenu()->addSeparator();
-
- if (isRoot())
- {
- addAddBookmarksList();
- addEditBookmarks();
- }
- else
- {
- addOpenFolderInTabs();
- addAddBookmarksList();
- }
-}
-
-
-void BookmarkMenu::addOpenFolderInTabs()
-{
- KBookmarkGroup group = manager()->findByAddress(parentAddress()).toGroup();
-
- if (!group.first().isNull())
- {
- KBookmark bookmark = group.first();
-
- while (bookmark.isGroup() || bookmark.isSeparator())
- {
- bookmark = group.next(bookmark);
- }
-
- if (!bookmark.isNull())
- {
- parentMenu()->addAction(rApp->bookmarkManager()->owner()->createAction(group, BookmarkOwner::OPEN_FOLDER));
- }
- }
-}
-
-
-void BookmarkMenu::actionHovered()
-{
- KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(sender());
- if (action)
- rApp->mainWindow()->notifyMessage(action->bookmark().url().url());
-}
-
-
-// ------------------------------------------------------------------------------------------------------
-
-
-BookmarkToolBar::BookmarkToolBar(KToolBar *toolBar, QObject *parent)
- : QObject(parent)
- , m_toolBar(toolBar)
- , m_currentMenu(0)
- , m_dragAction(0)
- , m_dropAction(0)
- , m_checkedAction(0)
- , m_filled(false)
-{
- toolBar->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(toolBar, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
- connect(rApp->bookmarkManager()->manager(), SIGNAL(changed(QString, QString)), this, SLOT(hideMenu()));
- toolBar->setAcceptDrops(true);
- toolBar->installEventFilter(this);
- toolBar->setShortcutEnabled(false);
-
- if (toolBar->isVisible())
- {
- rApp->bookmarkManager()->fillBookmarkBar(this);
- m_filled = true;
- }
-}
-
-
-KToolBar* BookmarkToolBar::toolBar()
-{
- return m_toolBar;
-}
-
-
-void BookmarkToolBar::contextMenu(const QPoint &point)
-{
- KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface*>(toolBar()->actionAt(point));
- KBookmark bookmark = rApp->bookmarkManager()->manager()->toolbar();
- bool nullAction = true;
- if (action)
- {
- bookmark = action->bookmark();
- nullAction = false;
- }
-
- BookmarksContextMenu menu(bookmark,
- rApp->bookmarkManager()->manager(),
- rApp->bookmarkManager()->owner(),
- nullAction);
- menu.exec(toolBar()->mapToGlobal(point));
-}
-
-
-void BookmarkToolBar::menuDisplayed()
-{
- qApp->installEventFilter(this);
- m_currentMenu = qobject_cast<KMenu*>(sender());
-}
-
-
-void BookmarkToolBar::menuHidden()
-{
- qApp->removeEventFilter(this);
- m_currentMenu = 0;
-}
-
-
-void BookmarkToolBar::hideMenu()
-{
- if (m_currentMenu)
- m_currentMenu->hide();
-}
-
-
-bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event)
-{
- if (m_currentMenu && m_currentMenu->isVisible()
- && !m_currentMenu->rect().contains(m_currentMenu->mapFromGlobal(QCursor::pos())))
- {
- // To switch root folders as in a menubar
-
- KBookmarkActionMenu* act = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(toolBar()->mapFromGlobal(QCursor::pos())));
-
- if (event->type() == QEvent::MouseMove && act && act->menu() != m_currentMenu)
- {
- m_currentMenu->hide();
- QPoint pos = toolBar()->mapToGlobal(toolBar()->widgetForAction(act)->pos());
- act->menu()->popup(QPoint(pos.x(), pos.y() + toolBar()->widgetForAction(act)->height()));
- }
- else if (event->type() == QEvent::MouseButtonPress && act)
- {
- m_currentMenu->hide();
- }
-
- return QObject::eventFilter(watched, event);
- }
-
- switch (event->type())
- {
- case QEvent::Show:
- {
- if (!m_filled)
- {
- rApp->bookmarkManager()->fillBookmarkBar(this);
- m_filled = true;
- }
- }
- break;
-
- case QEvent::ActionRemoved:
- {
- QActionEvent *actionEvent = static_cast<QActionEvent*>(event);
- if (actionEvent && actionEvent->action() != m_dropAction)
- {
- QWidget *widget = toolBar()->widgetForAction(actionEvent->action());
- if (widget)
- {
- widget->removeEventFilter(this);
- }
- }
- }
- break;
-
- case QEvent::ParentChange:
- {
- QActionEvent *actionEvent = static_cast<QActionEvent*>(event);
- if (actionEvent && actionEvent->action() != m_dropAction)
- {
- QWidget *widget = toolBar()->widgetForAction(actionEvent->action());
- if (widget)
- {
- widget->removeEventFilter(this);
- }
- }
- }
- break;
-
- case QEvent::DragEnter:
- {
- QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent*>(event);
- if (dragEvent->mimeData()->hasFormat(BookmarkManager::bookmark_mime_type())
- || dragEvent->mimeData()->hasFormat("text/uri-list")
- || dragEvent->mimeData()->hasFormat("text/plain"))
- {
- QFrame* dropIndicatorWidget = new QFrame(toolBar());
- dropIndicatorWidget->setFrameShape(QFrame::VLine);
- m_dropAction = toolBar()->insertWidget(toolBar()->actionAt(dragEvent->pos()), dropIndicatorWidget);
-
- dragEvent->accept();
- }
- }
- break;
-
- case QEvent::DragLeave:
- {
- QDragLeaveEvent *dragEvent = static_cast<QDragLeaveEvent*>(event);
-
- if (m_checkedAction)
- {
- m_checkedAction->setCheckable(false);
- m_checkedAction->setChecked(false);
- }
-
- delete m_dropAction;
- m_dropAction = 0;
- dragEvent->accept();
- }
- break;
-
- case QEvent::DragMove:
- {
- QDragMoveEvent *dragEvent = static_cast<QDragMoveEvent*>(event);
- if (dragEvent->mimeData()->hasFormat(BookmarkManager::bookmark_mime_type())
- || dragEvent->mimeData()->hasFormat("text/uri-list")
- || dragEvent->mimeData()->hasFormat("text/plain"))
- {
- QAction *overAction = toolBar()->actionAt(dragEvent->pos());
- KBookmarkActionInterface *overActionBK = dynamic_cast<KBookmarkActionInterface*>(overAction);
- QWidget *widgetAction = toolBar()->widgetForAction(overAction);
-
- if (overAction != m_dropAction && overActionBK && widgetAction && m_dropAction)
- {
- toolBar()->removeAction(m_dropAction);
- if (m_checkedAction)
- {
- m_checkedAction->setCheckable(false);
- m_checkedAction->setChecked(false);
- }
-
- if (!overActionBK->bookmark().isGroup())
- {
- if ((dragEvent->pos().x() - widgetAction->pos().x()) > (widgetAction->width() / 2))
- {
- if (toolBar()->actions().count() > toolBar()->actions().indexOf(overAction) + 1)
- {
- toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction);
- }
- else
- {
- toolBar()->addAction(m_dropAction);
- }
- }
- else
- {
- toolBar()->insertAction(overAction, m_dropAction);
- }
- }
- else
- {
- if ((dragEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75))
- {
- if (toolBar()->actions().count() > toolBar()->actions().indexOf(overAction) + 1)
- {
- toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction);
- }
- else
- {
- toolBar()->addAction(m_dropAction);
- }
- }
- else if ((dragEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25))
- {
- toolBar()->insertAction(overAction, m_dropAction);
- }
- else
- {
- overAction->setCheckable(true);
- overAction->setChecked(true);
- m_checkedAction = overAction;
- }
- }
-
- dragEvent->accept();
- }
- }
- }
- break;
-
-
- case QEvent::Drop:
- {
- QDropEvent *dropEvent = static_cast<QDropEvent*>(event);
- KBookmark bookmark;
- KBookmarkGroup root = rApp->bookmarkManager()->manager()->toolbar();
-
- if (m_checkedAction)
- {
- m_checkedAction->setCheckable(false);
- m_checkedAction->setChecked(false);
- }
-
- if (dropEvent->mimeData()->hasFormat(BookmarkManager::bookmark_mime_type()))
- {
- QByteArray addresses = dropEvent->mimeData()->data(BookmarkManager::bookmark_mime_type());
- bookmark = rApp->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data()));
- if (bookmark.isNull())
- return false;
- }
- else if (dropEvent->mimeData()->hasFormat("text/uri-list"))
- {
- // DROP is URL
- QString url = dropEvent->mimeData()->urls().at(0).toString();
- QString title = url.contains(rApp->mainWindow()->currentTab()->url().url())
- ? rApp->mainWindow()->currentTab()->view()->title()
- : url;
- bookmark = root.addBookmark(title, url);
- }
- else if (dropEvent->mimeData()->hasFormat("text/plain"))
- {
- // DROP is TEXT
- QString url = dropEvent->mimeData()->text();
- KUrl u(url);
- if (u.isValid())
- {
- QString title = url.contains(rApp->mainWindow()->currentTab()->url().url())
- ? rApp->mainWindow()->currentTab()->view()->title()
- : url;
- bookmark = root.addBookmark(title, url);
- }
- }
- else
- {
- return false;
- }
-
- QAction *destAction = toolBar()->actionAt(dropEvent->pos());
- if (destAction && destAction == m_dropAction)
- {
- if (toolBar()->actions().indexOf(m_dropAction) > 0)
- {
- destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1);
- }
- else
- {
- destAction = toolBar()->actions().at(1);
- }
- }
-
- if (destAction)
- {
- KBookmarkActionInterface *destBookmarkAction = dynamic_cast<KBookmarkActionInterface *>(destAction);
- QWidget *widgetAction = toolBar()->widgetForAction(destAction);
-
- if (destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction
- && bookmark.address() != destBookmarkAction->bookmark().address())
- {
- KBookmark destBookmark = destBookmarkAction->bookmark();
-
- if (!destBookmark.isGroup())
- {
- if ((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() / 2))
- {
- root.moveBookmark(bookmark, destBookmark);
- }
- else
- {
- root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark));
- }
- }
- else
- {
- if ((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75))
- {
- root.moveBookmark(bookmark, destBookmark);
- }
- else if ((dropEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25))
- {
- root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark));
- }
- else
- {
- destBookmark.toGroup().addBookmark(bookmark);
- }
- }
-
-
- rApp->bookmarkManager()->emitChanged();
- }
- }
- else
- {
- root.deleteBookmark(bookmark);
- bookmark = root.addBookmark(bookmark);
- if (dropEvent->pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x())
- {
- root.moveBookmark(bookmark, KBookmark());
- }
-
- rApp->bookmarkManager()->emitChanged();
- }
- dropEvent->accept();
- }
- break;
-
- default:
- break;
- }
-
- QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
-
- // These events need to be handled only for Bookmark actions and not the bar
- if (watched != toolBar() && mouseEvent)
- {
- switch (event->type())
- {
- case QEvent::MouseButtonPress: // drag handling
- {
- QPoint pos = toolBar()->mapFromGlobal(QCursor::pos());
- KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(pos));
-
- if (action && mouseEvent->button() != Qt::MidButton)
- {
- m_dragAction = toolBar()->actionAt(pos);
- m_startDragPos = pos;
-
- // The menu is displayed only when the mouse button is released
- if (action->bookmark().isGroup())
- return true;
- }
- }
- break;
-
- case QEvent::MouseMove:
- {
- int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength();
- if (!m_currentMenu && distance >= QApplication::startDragDistance())
- {
- startDrag();
- }
- }
- break;
-
- case QEvent::MouseButtonRelease:
- {
- QPoint destPos = toolBar()->mapFromGlobal(QCursor::pos());
- int distance = (destPos - m_startDragPos).manhattanLength();
- KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(destPos));
-
- if (action && action->bookmark().isGroup())
- {
- if (mouseEvent->button() == Qt::MidButton)
- {
- rApp->bookmarkManager()->owner()->openBookmarkFolder(action->bookmark());
- }
- else if (distance < QApplication::startDragDistance())
- {
- KBookmarkActionMenu *menu = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(m_startDragPos));
- QPoint actionPos = toolBar()->mapToGlobal(toolBar()->widgetForAction(menu)->pos());
- menu->menu()->popup(QPoint(actionPos.x(), actionPos.y() + toolBar()->widgetForAction(menu)->height()));
- }
- }
- }
- break;
-
- default:
- break;
- }
- }
-
- return QObject::eventFilter(watched, event);
-}
-
-
-void BookmarkToolBar::actionHovered()
-{
- KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(sender());
- if (action)
- rApp->mainWindow()->notifyMessage(action->bookmark().url().url());
-}
-
-
-void BookmarkToolBar::startDrag()
-{
- KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(m_dragAction);
- if (action)
- {
- QMimeData *mimeData = new QMimeData;
- KBookmark bookmark = action->bookmark();
-
- QByteArray address = bookmark.address().toLatin1();
- mimeData->setData(BookmarkManager::bookmark_mime_type(), address);
- bookmark.populateMimeData(mimeData);
-
- QDrag *drag = new QDrag(toolBar());
- drag->setMimeData(mimeData);
-
- if (bookmark.isGroup())
- {
- drag->setPixmap(KIcon(bookmark.icon()).pixmap(24, 24));
- }
- else
- {
- drag->setPixmap(rApp->iconManager()->iconForUrl(action->bookmark().url()).pixmap(24, 24));
- }
-
- drag->start(Qt::MoveAction);
- connect(drag, SIGNAL(destroyed()), this, SLOT(dragDestroyed()));
- }
-}
-
-
-void BookmarkToolBar::dragDestroyed()
-{
- // A workaround to get rid of the checked state of the dragged action
- if (m_dragAction)
- {
- m_dragAction->setVisible(false);
- m_dragAction->setVisible(true);
- m_dragAction = 0;
- }
- delete m_dropAction;
- m_dropAction = 0;
-}
diff --git a/src/bookmarks/bookmarkstoolbar.h b/src/bookmarks/bookmarkstoolbar.h
deleted file mode 100644
index b96085ee..00000000
--- a/src/bookmarks/bookmarkstoolbar.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-#ifndef BOOKMARKSTOOLBAR_H
-#define BOOKMARKSTOOLBAR_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// KDE Includes
-#include <KBookmarkMenu>
-
-/**
- * This class represent the rekonq bookmarks menu.
- * It's just a simple class inherited from KBookmarkMenu
- *
- */
-class BookmarkMenu : public KBookmarkMenu
-{
- Q_OBJECT
-
-public:
- BookmarkMenu(KBookmarkManager* manager,
- KBookmarkOwner* owner,
- KMenu* menu,
- KActionCollection* actionCollection);
- BookmarkMenu(KBookmarkManager *manager,
- KBookmarkOwner *owner,
- KMenu *parentMenu,
- const QString &parentAddress);
- ~BookmarkMenu();
-
-protected:
- virtual KMenu * contextMenu(QAction * act);
- virtual void refill();
- virtual QAction* actionForBookmark(const KBookmark &bookmark);
-
-private Q_SLOTS:
- void actionHovered();
-
-private:
- void addOpenFolderInTabs();
-
-};
-
-
-// ------------------------------------------------------------------------------
-
-
-// KDE Includes
-#include <KToolBar>
-
-
-/**
- * This class manage the bookmark toolbar.
- * Some events from the toolbar are handled to allow the drag and drop
- */
-
-class BookmarkToolBar : public QObject
-{
- Q_OBJECT
-
-public:
- BookmarkToolBar(KToolBar *toolBar, QObject *parent);
-
- KToolBar* toolBar();
-
-protected:
- bool eventFilter(QObject *watched, QEvent *event);
-
-private Q_SLOTS:
- void contextMenu(const QPoint &);
- void actionHovered();
- void menuDisplayed();
- void menuHidden();
- void hideMenu();
- void dragDestroyed();
-
-private:
- void startDrag();
-
- KToolBar *m_toolBar;
- KMenu *m_currentMenu;
- QPoint m_startDragPos;
- QAction *m_dragAction;
- QAction *m_dropAction;
- QAction *m_checkedAction;
- bool m_filled;
-};
-
-#endif // BOOKMARKSTOOLBAR_H
diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp
deleted file mode 100644
index 9e54f010..00000000
--- a/src/bookmarks/bookmarkstreemodel.cpp
+++ /dev/null
@@ -1,407 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Nils Weigel <nehlsen at gmail dot com>
-* Copyright (C) 2010-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "bookmarkstreemodel.h"
-#include "bookmarkstreemodel.moc"
-
-// Local Includes
-#include "application.h"
-#include "bookmarkmanager.h"
-#include "iconmanager.h"
-
-// KDE Includes
-#include <KBookmarkManager>
-#include <KLocalizedString>
-#include <KIcon>
-
-// Qt Includes
-#include <QtCore/QMimeData>
-
-
-BtmItem::BtmItem(const KBookmark &bm)
- : m_parent(0)
- , m_kbm(bm)
-{
-}
-
-
-BtmItem::~BtmItem()
-{
- qDeleteAll(m_children);
-}
-
-
-QVariant BtmItem::data(int role) const
-{
- if (m_kbm.isNull())
- return QVariant(); // should only happen for root item
-
- if (role == Qt::DisplayRole)
- return m_kbm.text();
-
- if (role == Qt::DecorationRole)
- {
- // NOTE
- // this should be:
- // return KIcon(m_kbm.icon());
- // but I cannot let it work :(
- // I really cannot understand how let this work properly...
- if (m_kbm.isGroup() || m_kbm.isSeparator())
- return KIcon(m_kbm.icon());
- else
- return rApp->iconManager()->iconForUrl(KUrl(m_kbm.url()));
- }
-
- if (role == Qt::UserRole)
- return m_kbm.url();
-
- if (role == Qt::ToolTipRole)
- {
- QString tooltip = m_kbm.fullText();
- if (m_kbm.isGroup())
- tooltip += i18ncp("%1=Number of items in bookmark folder", " (1 item)", " (%1 items)", childCount());
-
- QString url = m_kbm.url().url();
- if (!url.isEmpty())
- {
- if (!tooltip.isEmpty())
- tooltip += '\n';
- tooltip += url;
- }
-
- if (!m_kbm.description().isEmpty())
- {
- if (!tooltip.isEmpty())
- tooltip += '\n';
- tooltip += m_kbm.description();
- }
-
- return tooltip;
- }
-
- return QVariant();
-}
-
-
-int BtmItem::row() const
-{
- if (m_parent)
- return m_parent->m_children.indexOf(const_cast< BtmItem* >(this));
- return 0;
-}
-
-
-int BtmItem::childCount() const
-{
- return m_children.count();
-}
-
-
-BtmItem* BtmItem::child(int n)
-{
- Q_ASSERT(n >= 0);
- Q_ASSERT(n < childCount());
-
- return m_children.at(n);
-}
-
-
-BtmItem* BtmItem::parent() const
-{
- return m_parent;
-}
-
-
-void BtmItem::appendChild(BtmItem *child)
-{
- if (!child)
- return;
-
- child->m_parent = this;
- m_children << child;
-}
-
-
-void BtmItem::clear()
-{
- qDeleteAll(m_children);
- m_children.clear();
-}
-
-KBookmark BtmItem::getBkm() const
-{
- return m_kbm;
-}
-
-
-// -------------------------------------------------------------------------------------
-
-
-BookmarksTreeModel::BookmarksTreeModel(QObject *parent)
- : QAbstractItemModel(parent)
- , m_root(0)
-{
- resetModel();
- connect(rApp->bookmarkManager()->manager(), SIGNAL(changed(QString, QString)),
- this, SLOT(bookmarksChanged(QString)));
-}
-
-
-BookmarksTreeModel::~BookmarksTreeModel()
-{
- delete m_root;
-}
-
-
-int BookmarksTreeModel::rowCount(const QModelIndex &parent) const
-{
- BtmItem *parentItem = 0;
- if (!parent.isValid())
- {
- parentItem = m_root;
- }
- else
- {
- parentItem = static_cast<BtmItem*>(parent.internalPointer());
- }
-
- return parentItem->childCount();
-}
-
-
-int BookmarksTreeModel::columnCount(const QModelIndex& /*parent*/) const
-{
- return 1;
-}
-
-
-Qt::ItemFlags BookmarksTreeModel::flags(const QModelIndex &index) const
-{
- Qt::ItemFlags flags = QAbstractItemModel::flags(index);
-
- if (!index.isValid())
- return flags | Qt::ItemIsDropEnabled;
-
- flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
-
- if (bookmarkForIndex(index).isGroup())
- flags |= Qt::ItemIsDropEnabled;
-
- return flags;
-}
-
-
-QModelIndex BookmarksTreeModel::index(int row, int column, const QModelIndex &parent) const
-{
- if (!hasIndex(row, column, parent))
- return QModelIndex();
-
- BtmItem *parentItem;
-
- if (!parent.isValid())
- parentItem = m_root;
- else
- parentItem = static_cast<BtmItem*>(parent.internalPointer());
-
- BtmItem *childItem = parentItem->child(row);
- if (childItem)
- return createIndex(row, column, childItem);
-
- return QModelIndex();
-}
-
-
-QModelIndex BookmarksTreeModel::parent(const QModelIndex &index) const
-{
- if (!index.isValid())
- return QModelIndex();
-
- BtmItem *childItem = static_cast<BtmItem*>(index.internalPointer());
- BtmItem *parentItem = childItem->parent();
-
- if (parentItem == m_root)
- return QModelIndex();
-
- return createIndex(parentItem->row(), 0, parentItem);
-}
-
-
-QVariant BookmarksTreeModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- BtmItem *node = static_cast<BtmItem*>(index.internalPointer());
- if (node && node == m_root)
- {
- if (role == Qt::DisplayRole)
- return i18n("Bookmarks");
- if (role == Qt::DecorationRole)
- return KIcon("bookmarks");
- }
- else
- {
- if (node)
- return node->data(role);
- }
-
- return QVariant();
-}
-
-
-QStringList BookmarksTreeModel::mimeTypes() const
-{
- return QStringList(BookmarkManager::bookmark_mime_type());
-}
-
-
-bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
-{
- if (action != Qt::MoveAction || !data->hasFormat(BookmarkManager::bookmark_mime_type()))
- return false;
-
- QByteArray addresses = data->data(BookmarkManager::bookmark_mime_type());
- KBookmark bookmark = rApp->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data()));
-
- KBookmarkGroup root;
- if (parent.isValid())
- root = bookmarkForIndex(parent).toGroup();
- else
- root = rApp->bookmarkManager()->rootGroup();
-
- QModelIndex destIndex = index(row, column, parent);
-
- if (destIndex.isValid() && row != -1)
- {
- root.moveBookmark(bookmark, root.previous(bookmarkForIndex(destIndex)));
- }
- else
- {
- root.deleteBookmark(bookmark);
- root.addBookmark(bookmark);
- }
-
- rApp->bookmarkManager()->emitChanged();
-
- return true;
-}
-
-
-Qt::DropActions BookmarksTreeModel::supportedDropActions() const
-{
- return Qt::MoveAction;
-}
-
-
-QMimeData* BookmarksTreeModel::mimeData(const QModelIndexList &indexes) const
-{
- QMimeData *mimeData = new QMimeData;
-
- QByteArray address = bookmarkForIndex(indexes.first()).address().toLatin1();
- mimeData->setData(BookmarkManager::bookmark_mime_type(), address);
- bookmarkForIndex(indexes.first()).populateMimeData(mimeData);
-
- return mimeData;
-}
-
-
-void BookmarksTreeModel::bookmarksChanged(const QString &groupAddress)
-{
- if (groupAddress.isEmpty())
- {
- resetModel();
- }
- else
- {
- beginResetModel();
- BtmItem *node = m_root;
- QModelIndex nodeIndex;
-
- QStringList indexChain(groupAddress.split('/', QString::SkipEmptyParts));
- bool ok;
- int i;
- Q_FOREACH(const QString & sIndex, indexChain)
- {
- i = sIndex.toInt(&ok);
- if (!ok)
- break;
-
- if (i < 0 || i >= node->childCount())
- break;
-
- node = node->child(i);
- nodeIndex = index(i, 0, nodeIndex);
- }
- populate(node, rApp->bookmarkManager()->findByAddress(groupAddress).toGroup());
- endResetModel();
- }
-
- emit bookmarksUpdated();
-}
-
-
-void BookmarksTreeModel::resetModel()
-{
- setRoot(rApp->bookmarkManager()->rootGroup());
-}
-
-
-void BookmarksTreeModel::setRoot(KBookmarkGroup bmg)
-{
- beginResetModel();
- delete m_root;
- m_root = new BtmItem(KBookmark());
- populate(m_root, bmg);
- endResetModel();
-}
-
-
-void BookmarksTreeModel::populate(BtmItem *node, KBookmarkGroup bmg)
-{
- node->clear();
-
- if (bmg.isNull())
- return;
-
- KBookmark bm = bmg.first();
- while (!bm.isNull())
- {
- BtmItem *newChild = new BtmItem(bm);
- if (bm.isGroup())
- populate(newChild, bm.toGroup());
-
- node->appendChild(newChild);
- bm = bmg.next(bm);
- }
-}
-
-
-KBookmark BookmarksTreeModel::bookmarkForIndex(const QModelIndex &index) const
-{
- return static_cast<BtmItem*>(index.internalPointer())->getBkm();
-}
diff --git a/src/bookmarks/bookmarkstreemodel.h b/src/bookmarks/bookmarkstreemodel.h
deleted file mode 100644
index f433ccaf..00000000
--- a/src/bookmarks/bookmarkstreemodel.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Nils Weigel <nehlsen at gmail dot com>
-* Copyright (C) 2010-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef BOOKMARKSTREEMODEL_H
-#define BOOKMARKSTREEMODEL_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// KDE includes
-#include <KBookmark>
-
-// Qt Includes
-#include <QtCore/QAbstractItemModel>
-
-
-class BtmItem
-{
-public:
- BtmItem(const KBookmark &bm);
- ~BtmItem();
-
- QVariant data(int role = Qt::DisplayRole) const;
- int row() const;
- int childCount() const;
- BtmItem* child(int n);
- BtmItem* parent() const;
- void appendChild(BtmItem *child);
- void clear();
- KBookmark getBkm() const;
-
-private:
- BtmItem *m_parent;
- QList< BtmItem* > m_children;
- KBookmark m_kbm;
-};
-
-
-// -------------------------------------------------------------------------------------------------
-
-
-class REKONQ_TESTS_EXPORT BookmarksTreeModel : public QAbstractItemModel
-{
- Q_OBJECT
-
-public:
- explicit BookmarksTreeModel(QObject *parent = 0);
- virtual ~BookmarksTreeModel();
-
- /**
- * @return number of rows under the given parent.
- */
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
- /**
- * @return number of columns (always 1).
- */
- virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
-
- virtual Qt::ItemFlags flags(const QModelIndex &index) const;
-
- /**
- * @return index in the model specified by the given row, column and parent.
- */
- virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
- /**
- * @return parent of the given index.
- */
- virtual QModelIndex parent(const QModelIndex &index) const;
- virtual QVariant data(const QModelIndex &index, int role) const;
-
- virtual QStringList mimeTypes() const;
- virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
- virtual Qt::DropActions supportedDropActions() const;
- virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
-
-private Q_SLOTS:
- void bookmarksChanged(const QString &groupAddress);
-
-Q_SIGNALS:
- void bookmarksUpdated();
-
-private:
- void resetModel();
- void setRoot(KBookmarkGroup bmg);
- void populate(BtmItem *node, KBookmarkGroup bmg);
- KBookmark bookmarkForIndex(const QModelIndex &index) const;
-
- BtmItem *m_root;
-};
-
-#endif // BOOKMARKSTREEMODEL_H