summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-09-11 10:45:14 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-09-14 08:51:10 +0300
commit9ff4588acd9702c268c2e70d44e962925bdde291 (patch)
tree635d0f8015eddf89388f10ba15b9a9b352e372f6
parentAdd Bookmarks panel (diff)
downloadrekonq-9ff4588acd9702c268c2e70d44e962925bdde291.tar.xz
BookmarksPanel: add custom context menu
-rw-r--r--src/bookmarks/CMakeLists.txt1
-rw-r--r--src/bookmarks/bookmarkscontextmenu.cpp133
-rw-r--r--src/bookmarks/bookmarkscontextmenu.h54
-rw-r--r--src/panels/bookmarkspanel.cpp35
-rw-r--r--src/panels/bookmarkspanel.hpp9
-rw-r--r--src/panels/paneltreeview.cpp186
-rw-r--r--src/panels/paneltreeview.h69
-rw-r--r--src/panels/urlfilterproxymodel.cpp59
-rw-r--r--src/panels/urlfilterproxymodel.h59
-rw-r--r--src/panels/urlpanel.cpp111
-rw-r--r--src/panels/urlpanel.h81
11 files changed, 39 insertions, 758 deletions
diff --git a/src/bookmarks/CMakeLists.txt b/src/bookmarks/CMakeLists.txt
index db0d9377..38a14204 100644
--- a/src/bookmarks/CMakeLists.txt
+++ b/src/bookmarks/CMakeLists.txt
@@ -1,7 +1,6 @@
add_library(bookmarks STATIC
# bookmarkmanager.cpp bookmarkmanager.h
# bookmarkowner.cpp bookmarkowner.h
-# bookmarkscontextmenu.cpp bookmarkscontextmenu.h
# bookmarksmenu.cpp bookmarksmenu.h
# bookmarkstoolbar.cpp bookmarkstoolbar.h
# Bookmarks Model
diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp
deleted file mode 100644
index a9683708..00000000
--- a/src/bookmarks/bookmarkscontextmenu.cpp
+++ /dev/null
@@ -1,133 +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"
-
-// Local Includes
-#include "bookmarkmanager.h"
-#include "bookmarkowner.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 = 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 2c122be4..00000000
--- a/src/bookmarks/bookmarkscontextmenu.h
+++ /dev/null
@@ -1,54 +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
-
-// 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/panels/bookmarkspanel.cpp b/src/panels/bookmarkspanel.cpp
index ee7ae717..5eda1c67 100644
--- a/src/panels/bookmarkspanel.cpp
+++ b/src/panels/bookmarkspanel.cpp
@@ -7,14 +7,15 @@
#include "bookmarkspanel.hpp"
#include "bookmarks/bookmarkstreemodel.hpp"
+#include <QMenu>
BookmarksPanel::BookmarksPanel(QWidget *parent) : QTreeView(parent)
{
- connect(this, &QTreeView::activated, this, [this](const QModelIndex &index) {
- auto *item = model()->item(index);
- const auto url = item->data(BookmarksTreeItem::Href).toUrl();
- emit loadUrl(url, rekonq::CurrentTab);
- });
+ setEditTriggers(QAbstractItemView::NoEditTriggers);
+ setContextMenuPolicy(Qt::CustomContextMenu);
+
+ connect(this, &QTreeView::activated, this, [this](const QModelIndex &index) { open(index); });
+ connect(this, &QTreeView::customContextMenuRequested, this, &BookmarksPanel::customContextMenu);
}
BookmarkModel *BookmarksPanel::model() const
@@ -23,3 +24,27 @@ BookmarkModel *BookmarksPanel::model() const
Q_CHECK_PTR(m);
return m;
}
+
+void BookmarksPanel::customContextMenu(const QPoint &pos)
+{
+ const auto index = indexAt(pos);
+ auto *item = model()->item(indexAt(pos));
+ Q_CHECK_PTR(item);
+
+ auto *menu = new QMenu(this);
+ menu->addAction(tr("Open in current tab"), this, [this, index]() { open(index); });
+ menu->addAction(tr("Open in new tab"), this, [this, index]() { open(index, rekonq::NewTab); });
+ menu->addAction(tr("Edit"));
+ menu->addAction(tr("Remove"), this, [this, index]() { remove(index); });
+
+ menu->popup(mapToGlobal(pos));
+}
+
+void BookmarksPanel::open(const QModelIndex &index, rekonq::OpenType type)
+{
+ auto *item = model()->item(index);
+ const auto url = item->data(BookmarksTreeItem::Href).toUrl();
+ emit loadUrl(url, type);
+}
+
+void BookmarksPanel::remove(const QModelIndex &index) { model()->removeRow(index.row(), index.parent()); }
diff --git a/src/panels/bookmarkspanel.hpp b/src/panels/bookmarkspanel.hpp
index 5961af7d..38d58f14 100644
--- a/src/panels/bookmarkspanel.hpp
+++ b/src/panels/bookmarkspanel.hpp
@@ -3,6 +3,9 @@
* ============================================================
* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================
+ * Description: A QTreeView that displays bookmarks and handles
+ * BookmarksTreeItem edits
* ============================================================ */
#pragma once
@@ -22,6 +25,12 @@ public:
signals:
void loadUrl(const QUrl &url, rekonq::OpenType type);
+private slots:
+ void customContextMenu(const QPoint &pos);
+
+ void open(const QModelIndex &index, rekonq::OpenType type = rekonq::CurrentTab);
+ void remove(const QModelIndex &index);
+
private:
[[nodiscard]] BookmarkModel *model() const;
};
diff --git a/src/panels/paneltreeview.cpp b/src/panels/paneltreeview.cpp
deleted file mode 100644
index e8cd90d9..00000000
--- a/src/panels/paneltreeview.cpp
+++ /dev/null
@@ -1,186 +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) 2012-2013 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 "paneltreeview.h"
-#include "paneltreeview.moc"
-
-// Local Includes
-#include "application.h"
-
-// KDE Includes
-#include <KUrl>
-
-// Qt Includes
-#include <QClipboard>
-#include <QMouseEvent>
-
-
-PanelTreeView::PanelTreeView(QWidget *parent)
- : QTreeView(parent)
-{
- connect(this, SIGNAL(itemHovered(QString)), parent, SIGNAL(itemHovered(QString)));
- connect(this, SIGNAL(openUrl(KUrl,Rekonq::OpenType)), parent, SIGNAL(openUrl(KUrl,Rekonq::OpenType)));
-
- setMouseTracking(true);
- setExpandsOnDoubleClick(false);
-}
-
-
-void PanelTreeView::mousePressEvent(QMouseEvent *event)
-{
- const QModelIndex index = indexAt(event->pos());
- bool expanded = isExpanded(index);
-
- QTreeView::mousePressEvent(event);
-
- // A change of an item expansion is handle by mouseReleaseEvent()
- // So toggle again the item
- if (expanded != isExpanded(index))
- setExpanded(index, !isExpanded(index));
-
- if (!index.isValid())
- {
- clearSelection();
- setCurrentIndex(QModelIndex());
-
- if (event->button() == Qt::RightButton)
- emit contextMenuEmptyRequested(event->pos());
- return;
- }
-
- if (event->button() == Qt::RightButton)
- {
- if (model()->rowCount(index) == 0)
- {
- // An empty group needs to be handle by the panels
- emit contextMenuItemRequested(event->pos());
- }
- else
- {
- emit contextMenuGroupRequested(event->pos());
- }
- }
-}
-
-
-void PanelTreeView::mouseReleaseEvent(QMouseEvent *event)
-{
- QTreeView::mouseReleaseEvent(event);
-
- const QModelIndex index = indexAt(event->pos());
- if (!index.isValid())
- return;
-
- if (event->button() == Qt::MidButton || event->modifiers() == Qt::ControlModifier)
- emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::NewTab);
-
- else if (event->button() == Qt::LeftButton)
- {
- if (model()->rowCount(index) == 0)
- emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)));
- else
- setExpanded(index, !isExpanded(index));
- }
-}
-
-
-void PanelTreeView::keyPressEvent(QKeyEvent *event)
-{
- QTreeView::keyPressEvent(event);
- QModelIndex index = currentIndex();
-
- if (!index.isValid())
- return;
-
- if (event->key() == Qt::Key_Return)
- {
- if (model()->rowCount(index) == 0)
- openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)));
- else
- setExpanded(index, !isExpanded(index));
- }
-
- else if (event->key() == Qt::Key_Delete)
- {
- emit delKeyPressed();
- }
-}
-
-
-void PanelTreeView::mouseMoveEvent(QMouseEvent *event)
-{
- QTreeView::mouseMoveEvent(event);
- const QModelIndex index = indexAt(event->pos());
- if (!index.isValid())
- {
- emit itemHovered("");
- return;
- }
- emit itemHovered(qVariantValue< KUrl >(index.data(Qt::UserRole)).url());
-}
-
-
-void PanelTreeView::openInCurrentTab()
-{
- QModelIndex index = currentIndex();
- if (!index.isValid())
- return;
-
- emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)));
-}
-
-
-void PanelTreeView::copyToClipboard()
-{
- QModelIndex index = currentIndex();
- if (!index.isValid())
- return;
-
- QClipboard *cb = QApplication::clipboard();
- cb->setText(qVariantValue< KUrl >(index.data(Qt::UserRole)).url());
-}
-
-
-void PanelTreeView::openInNewTab()
-{
- QModelIndex index = currentIndex();
- if (!index.isValid())
- return;
-
- emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::NewTab);
-}
-
-
-void PanelTreeView::openInNewWindow()
-{
- QModelIndex index = currentIndex();
- if (!index.isValid())
- return;
-
- emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::NewWindow);
-}
diff --git a/src/panels/paneltreeview.h b/src/panels/paneltreeview.h
deleted file mode 100644
index ee8c51d0..00000000
--- a/src/panels/paneltreeview.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2010-2011 by Yoann Laissus <yoann dot laissus at gmail dot com>
-* Copyright (C) 2012-2013 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 PANELTREEVIEW_H
-#define PANELTREEVIEW_H
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// Qt Includes
-#include <QTreeView>
-
-// Forward Declarations
-class KUrl;
-
-
-class REKONQ_TESTS_EXPORT PanelTreeView : public QTreeView
-{
- Q_OBJECT
-
-public:
- PanelTreeView(QWidget *parent = 0);
-
-Q_SIGNALS:
- void openUrl(const KUrl &, const Rekonq::OpenType & = Rekonq::CurrentTab);
- void itemHovered(const QString &);
- void delKeyPressed();
- void contextMenuItemRequested(const QPoint &pos);
- void contextMenuGroupRequested(const QPoint &pos);
- void contextMenuEmptyRequested(const QPoint &pos);
-
-public Q_SLOTS:
- void copyToClipboard();
- void openInCurrentTab();
- void openInNewTab();
- void openInNewWindow();
-
-protected:
- void mouseReleaseEvent(QMouseEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void keyPressEvent(QKeyEvent *event);
-};
-
-#endif // PANELTREEVIEW_H
diff --git a/src/panels/urlfilterproxymodel.cpp b/src/panels/urlfilterproxymodel.cpp
deleted file mode 100644
index aa9ac7a6..00000000
--- a/src/panels/urlfilterproxymodel.cpp
+++ /dev/null
@@ -1,59 +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-2011 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 "urlfilterproxymodel.h"
-#include "urlfilterproxymodel.moc"
-
-
-UrlFilterProxyModel::UrlFilterProxyModel(QObject *parent)
- : QSortFilterProxyModel(parent)
-{
- setFilterCaseSensitivity(Qt::CaseInsensitive);
-}
-
-
-bool UrlFilterProxyModel::filterAcceptsRow(const int source_row, const QModelIndex &source_parent) const
-{
- return recursiveMatch(sourceModel()->index(source_row, 0, source_parent));
-}
-
-
-bool UrlFilterProxyModel::recursiveMatch(const QModelIndex &index) const
-{
- if (index.data().toString().contains(filterRegExp()))
- return true;
-
- int numChildren = sourceModel()->rowCount(index);
- for (int childRow = 0; childRow < numChildren; ++childRow)
- {
- if (recursiveMatch(sourceModel()->index(childRow, 0, index)))
- return true;
- }
-
- return false;
-}
diff --git a/src/panels/urlfilterproxymodel.h b/src/panels/urlfilterproxymodel.h
deleted file mode 100644
index 6cb8574e..00000000
--- a/src/panels/urlfilterproxymodel.h
+++ /dev/null
@@ -1,59 +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-2011 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 URLFILTERPROXYMODEL_H
-#define URLFILTERPROXYMODEL_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// Qt Includes
-#include <QSortFilterProxyModel>
-
-
-/**
- * QSortFilterProxyModel hides all children which parent doesn't
- * match the filter. This class is used to change this behavior.
- * If a url matches the filter it'll be shown,
- * even if it's parent doesn't match it.
- */
-class REKONQ_TESTS_EXPORT UrlFilterProxyModel : public QSortFilterProxyModel
-{
- Q_OBJECT
-
-public:
- explicit UrlFilterProxyModel(QObject *parent = 0);
-
-protected:
- virtual bool filterAcceptsRow(const int source_row, const QModelIndex &source_parent) const;
-
- // returns true if index or any of his children match the filter
- bool recursiveMatch(const QModelIndex &index) const;
-};
-
-#endif // URLFILTERPROXYMODEL_H
diff --git a/src/panels/urlpanel.cpp b/src/panels/urlpanel.cpp
deleted file mode 100644
index 7fb75087..00000000
--- a/src/panels/urlpanel.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Domrachev Alexandr <alexandr.domrachev@gmail.com>
-* Copyright (C) 2009-2013 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 "urlpanel.h"
-#include "urlpanel.moc"
-
-// Local Includes
-#include "paneltreeview.h"
-#include "urlfilterproxymodel.h"
-
-// KDE Includes
-#include <KLineEdit>
-#include <KLocalizedString>
-
-// Qt Includes
-#include <QLabel>
-#include <QHBoxLayout>
-#include <QHeaderView>
-
-
-UrlPanel::UrlPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags)
- : QDockWidget(title, parent, flags)
- , _treeView(new PanelTreeView(this))
- , _loaded(false)
-{
- setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
-
- connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(showing(bool)));
-}
-
-
-void UrlPanel::showing(bool b)
-{
- if (!_loaded && b)
- {
- setup();
- _loaded = true;
- }
-}
-
-
-void UrlPanel::setup()
-{
- QWidget *ui = new QWidget(this);
-
- // setup search bar
- QHBoxLayout *searchLayout = new QHBoxLayout;
- searchLayout->setContentsMargins(5, 0, 0, 0);
- QLabel *searchLabel = new QLabel(i18n("&Search:"));
- searchLayout->addWidget(searchLabel);
- KLineEdit *search = new KLineEdit;
- search->setClearButtonShown(true);
- searchLayout->addWidget(search);
- searchLabel->setBuddy(search);
-
- // setup tree view
- _treeView->setUniformRowHeights(true);
- _treeView->header()->hide();
-
- // put everything together
- QVBoxLayout *vBoxLayout = new QVBoxLayout;
- vBoxLayout->setContentsMargins(0, 0, 0, 0);
- vBoxLayout->addLayout(searchLayout);
- vBoxLayout->addWidget(_treeView);
-
- // add it to the UI
- ui->setLayout(vBoxLayout);
- setWidget(ui);
-
- UrlFilterProxyModel *proxy = new UrlFilterProxyModel(this);
- proxy->setSourceModel(model());
- _treeView->setModel(proxy);
-
- connect(search, SIGNAL(textChanged(QString)), proxy, SLOT(setFilterFixedString(QString)));
- connect(search, SIGNAL(textChanged(QString)), this, SLOT(expandTreeView()));
-
- connect(_treeView, SIGNAL(contextMenuItemRequested(QPoint)), this, SLOT(contextMenuItem(QPoint)));
- connect(_treeView, SIGNAL(contextMenuGroupRequested(QPoint)), this, SLOT(contextMenuGroup(QPoint)));
- connect(_treeView, SIGNAL(contextMenuEmptyRequested(QPoint)), this, SLOT(contextMenuEmpty(QPoint)));
-}
-
-
-void UrlPanel::expandTreeView()
-{
- _treeView->expandAll();
-}
diff --git a/src/panels/urlpanel.h b/src/panels/urlpanel.h
deleted file mode 100644
index 72393c9e..00000000
--- a/src/panels/urlpanel.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Domrachev Alexandr <alexandr.domrachev@gmail.com>
-* Copyright (C) 2009-2013 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 URLPANEL_H
-#define URLPANEL_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// Qt Includes
-#include <QDockWidget>
-
-// Forward Declarations
-class PanelTreeView;
-
-class QAbstractItemModel;
-
-
-class REKONQ_TESTS_EXPORT UrlPanel : public QDockWidget
-{
- Q_OBJECT
-
-public:
- explicit UrlPanel(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
-
-Q_SIGNALS:
- void openUrl(const KUrl &, const Rekonq::OpenType &);
- void itemHovered(const QString &);
-
-public Q_SLOTS:
- void showing(bool);
-
-protected:
- virtual void setup();
- virtual QAbstractItemModel* model() = 0;
-
- PanelTreeView* panelTreeView() const
- {
- return _treeView;
- }
-
-protected Q_SLOTS:
- virtual void contextMenuItem(const QPoint &pos) = 0;
- virtual void contextMenuGroup(const QPoint &pos) = 0;
- virtual void contextMenuEmpty(const QPoint &pos) = 0;
-
-private Q_SLOTS:
- void expandTreeView();
-
-private:
- PanelTreeView *_treeView;
- bool _loaded;
-};
-
-
-#endif // URLPANEL_H