summaryrefslogtreecommitdiff
path: root/src/bookmarks/bookmarkspanel.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-08-30 18:02:05 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-08-30 18:02:05 +0200
commit4b160adc90c4a484e7cb94b3c9fd23439f0e12a8 (patch)
treea1fff65e53a3910cf5e86e75147ed517a51a4978 /src/bookmarks/bookmarkspanel.cpp
parentsuggestion download: kill previous job before start a new one. (diff)
parentpanels directory removed (diff)
downloadrekonq-4b160adc90c4a484e7cb94b3c9fd23439f0e12a8.tar.xz
Merge commit 'refs/merge-requests/193' of git://gitorious.org/rekonq/mainline into m193
Diffstat (limited to 'src/bookmarks/bookmarkspanel.cpp')
-rw-r--r--src/bookmarks/bookmarkspanel.cpp112
1 files changed, 38 insertions, 74 deletions
diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp
index 08f99155..e88d3060 100644
--- a/src/bookmarks/bookmarkspanel.cpp
+++ b/src/bookmarks/bookmarkspanel.cpp
@@ -28,51 +28,31 @@
// Self Includes
#include "bookmarkspanel.h"
+// Auto Includes
+#include "rekonq.h"
+
// Local Includes
#include "application.h"
#include "bookmarkprovider.h"
#include "bookmarkstreemodel.h"
-#include "bookmarksproxy.h"
#include "bookmarkscontextmenu.h"
#include "bookmarkowner.h"
#include "paneltreeview.h"
+#include "urlfilterproxymodel.h"
-// Auto Includes
-#include "rekonq.h"
-
-// Qt includes
-#include <QtGui/QHBoxLayout>
-#include <QtGui/QLabel>
-#include <QtGui/QHeaderView>
-
-// KDE includes
-#include <KLineEdit>
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());
}
BookmarksPanel::~BookmarksPanel()
{
- ReKonfig::setShowBookmarksPanel(false);
-}
-
-
-void BookmarksPanel::showing(bool b)
-{
- if(b && !m_loaded)
- setup();
+ ReKonfig::setShowBookmarksPanel(!isHidden());
}
@@ -99,6 +79,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 +129,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 +151,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);
- BookmarksProxy *proxy = new BookmarksProxy(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;
}
@@ -211,9 +167,17 @@ KBookmark BookmarksPanel::bookmarkForIndex(const QModelIndex &index)
if (!index.isValid())
return KBookmark();
- const BookmarksProxy *proxyModel = static_cast<const BookmarksProxy*>(index.model());
+ 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::getModel()
+{
+ BookmarksTreeModel *model = new BookmarksTreeModel(this);
+ connect(model, SIGNAL(bookmarksUpdated()), this, SLOT(startLoadFoldedState()));
+ return model;
+}