From 51ef0020a78bd216cb357eaa574161299fa0b608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Mon, 30 Aug 2010 00:05:47 +0200 Subject: Use the same FilterProxyModel for the bookmarks and history panels --- src/bookmarks/bookmarkspanel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/bookmarks/bookmarkspanel.cpp') diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index 08f99155..53f22232 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -29,10 +29,10 @@ #include "bookmarkspanel.h" // Local Includes +#include "panels/urlfilterproxymodel.h" #include "application.h" #include "bookmarkprovider.h" #include "bookmarkstreemodel.h" -#include "bookmarksproxy.h" #include "bookmarkscontextmenu.h" #include "bookmarkowner.h" #include "paneltreeview.h" @@ -185,7 +185,7 @@ void BookmarksPanel::setup() setWidget(ui); BookmarksTreeModel *model = new BookmarksTreeModel(this); - BookmarksProxy *proxy = new BookmarksProxy(ui); + UrlFilterProxyModel *proxy = new UrlFilterProxyModel(ui); proxy->setSourceModel(model); m_treeView->setModel(proxy); @@ -211,7 +211,7 @@ KBookmark BookmarksPanel::bookmarkForIndex(const QModelIndex &index) if (!index.isValid()) return KBookmark(); - const BookmarksProxy *proxyModel = static_cast(index.model()); + const UrlFilterProxyModel *proxyModel = static_cast(index.model()); QModelIndex originalIndex = proxyModel->mapToSource(index); BtmItem *node = static_cast(originalIndex.internalPointer()); -- cgit v1.2.1 From 0d53995507a369d5b4cfddbe365fc8a438fcf3cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Mon, 30 Aug 2010 01:40:33 +0200 Subject: New general panel class created and used by the bookmarks and history panel --- src/bookmarks/bookmarkspanel.cpp | 107 +++++++++++++-------------------------- 1 file changed, 36 insertions(+), 71 deletions(-) (limited to 'src/bookmarks/bookmarkspanel.cpp') diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index 53f22232..118074d0 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -28,6 +28,9 @@ // Self Includes #include "bookmarkspanel.h" +// Auto Includes +#include "rekonq.h" + // Local Includes #include "panels/urlfilterproxymodel.h" #include "application.h" @@ -37,27 +40,12 @@ #include "bookmarkowner.h" #include "paneltreeview.h" -// Auto Includes -#include "rekonq.h" - -// Qt includes -#include -#include -#include - -// KDE includes -#include BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(title, parent, flags) - , m_treeView(new PanelTreeView(this)) + : UrlPanel(title, parent, flags) , m_loadingState(false) - , m_loaded(false) { setObjectName("bookmarksPanel"); - setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - - connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(showing(bool))); setVisible(ReKonfig::showBookmarksPanel()); } @@ -65,14 +53,7 @@ BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::Window BookmarksPanel::~BookmarksPanel() { - ReKonfig::setShowBookmarksPanel(false); -} - - -void BookmarksPanel::showing(bool b) -{ - if(b && !m_loaded) - setup(); + ReKonfig::setShowBookmarksPanel(!isHidden()); } @@ -99,6 +80,24 @@ void BookmarksPanel::contextMenu(const QPoint &pos) } +void BookmarksPanel::contextMenuItem(const QPoint &pos) +{ + contextMenu(pos); +} + + +void BookmarksPanel::contextMenuGroup(const QPoint &pos) +{ + contextMenu(pos); +} + + +void BookmarksPanel::contextMenuEmpty(const QPoint &pos) +{ + contextMenu(pos); +} + + void BookmarksPanel::deleteBookmark() { QModelIndex index = m_treeView->currentIndex(); @@ -131,12 +130,13 @@ void BookmarksPanel::onExpand(const QModelIndex &index) void BookmarksPanel::loadFoldedState(const QModelIndex &root) { - int count = m_treeView->model()->rowCount(root); + QAbstractItemModel *model = m_treeView->model(); + int count = model->rowCount(root); QModelIndex index; for (int i = 0; i < count; ++i) { - index = m_treeView->model()->index(i, 0, root); + index = model->index(i, 0, root); if (index.isValid()) { KBookmark bm = bookmarkForIndex(index); @@ -152,57 +152,14 @@ void BookmarksPanel::loadFoldedState(const QModelIndex &root) void BookmarksPanel::setup() { - kDebug() << "Loading bookmarks panel 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 - m_treeView->setUniformRowHeights(true); - m_treeView->header()->hide(); - m_treeView->setDragEnabled(true); - m_treeView->setAutoExpandDelay(750); - m_treeView->setDefaultDropAction(Qt::MoveAction); - m_treeView->viewport()->setAcceptDrops(true); - - // put everything together - QVBoxLayout *vBoxLayout = new QVBoxLayout; - vBoxLayout->setContentsMargins(0, 0, 0, 0); - vBoxLayout->addLayout(searchLayout); - vBoxLayout->addWidget(m_treeView); - - // add it to the UI - ui->setLayout(vBoxLayout); - setWidget(ui); - - BookmarksTreeModel *model = new BookmarksTreeModel(this); - UrlFilterProxyModel *proxy = new UrlFilterProxyModel(ui); - proxy->setSourceModel(model); - m_treeView->setModel(proxy); - - connect(search, SIGNAL(textChanged(const QString &)), proxy, SLOT(setFilterFixedString(const QString &))); + UrlPanel::setup(); + kDebug() << "Bookmarks panel..."; - connect(model, SIGNAL(bookmarksUpdated()), this, SLOT(startLoadFoldedState())); - - connect(m_treeView, SIGNAL(contextMenuItemRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); - connect(m_treeView, SIGNAL(contextMenuGroupRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); - connect(m_treeView, SIGNAL(contextMenuEmptyRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); connect(m_treeView, SIGNAL(delKeyPressed()), this, SLOT(deleteBookmark())); connect(m_treeView, SIGNAL(collapsed(const QModelIndex &)), this, SLOT(onCollapse(const QModelIndex &))); connect(m_treeView, SIGNAL(expanded(const QModelIndex &)), this, SLOT(onExpand(const QModelIndex &))); startLoadFoldedState(); - - m_loaded = true; } @@ -217,3 +174,11 @@ KBookmark BookmarksPanel::bookmarkForIndex(const QModelIndex &index) BtmItem *node = static_cast(originalIndex.internalPointer()); return node->getBkm(); } + + +QAbstractItemModel* BookmarksPanel::getModel() +{ + BookmarksTreeModel *model = new BookmarksTreeModel(this); + connect(model, SIGNAL(bookmarksUpdated()), this, SLOT(startLoadFoldedState())); + return model; +} -- cgit v1.2.1 From a3fd9b3a4b0c965d9a460e059f73f1ce0d52cc66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Mon, 30 Aug 2010 10:48:54 +0200 Subject: Minor changes in the panels --- src/bookmarks/bookmarkspanel.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/bookmarks/bookmarkspanel.cpp') diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index 118074d0..0d912113 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -46,7 +46,6 @@ BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::Window , m_loadingState(false) { setObjectName("bookmarksPanel"); - setVisible(ReKonfig::showBookmarksPanel()); } -- cgit v1.2.1 From 5fcf9b79a80d24261ae79999c13dc023ba1b677d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Mon, 30 Aug 2010 17:10:04 +0200 Subject: panels directory removed --- src/bookmarks/bookmarkspanel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bookmarks/bookmarkspanel.cpp') diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index 0d912113..e88d3060 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -32,13 +32,13 @@ #include "rekonq.h" // Local Includes -#include "panels/urlfilterproxymodel.h" #include "application.h" #include "bookmarkprovider.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) -- cgit v1.2.1