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/history/historypanel.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/history/historypanel.cpp') diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index b9e7b10b..4c1dc732 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -27,13 +27,14 @@ // Self Includes #include "historypanel.h" -#include "historypanel.moc" // Auto Includes #include "rekonq.h" // Local Includes +#include "panels/urlfilterproxymodel.h" #include "application.h" +#include "paneltreeview.h" #include "historymodels.h" // Qt Includes @@ -58,9 +59,9 @@ HistoryPanel::HistoryPanel(const QString &title, QWidget *parent, Qt::WindowFlag { setObjectName("historyPanel"); setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - + connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(showing(bool))); - + setShown(ReKonfig::showHistoryPanel()); } @@ -117,16 +118,16 @@ void HistoryPanel::setup() HistoryManager *historyManager = Application::historyManager(); QAbstractItemModel *model = historyManager->historyTreeModel(); - TreeProxyModel *treeProxyModel = new TreeProxyModel(this); - treeProxyModel->setSourceModel(model); - m_treeView->setModel(treeProxyModel); - m_treeView->setExpanded(treeProxyModel->index(0, 0), true); + UrlFilterProxyModel *proxy = new UrlFilterProxyModel(this); + proxy->setSourceModel(model); + m_treeView->setModel(proxy); + m_treeView->setExpanded(proxy->index(0, 0), true); m_treeView->header()->hideSection(1); QFontMetrics fm(font()); int header = fm.width( QL1C('m') ) * 40; m_treeView->header()->resizeSection(0, header); - connect(search, SIGNAL(textChanged(QString)), treeProxyModel, SLOT(setFilterFixedString(QString))); + connect(search, SIGNAL(textChanged(QString)), proxy, SLOT(setFilterFixedString(QString))); connect(m_treeView, SIGNAL(contextMenuItemRequested(const QPoint &)), this, SLOT(contextMenuItem(const QPoint &))); connect(m_treeView, SIGNAL(contextMenuGroupRequested(const QPoint &)), this, SLOT(contextMenuGroup(const QPoint &))); -- 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/history/historypanel.cpp | 94 +++++++++++--------------------------------- 1 file changed, 22 insertions(+), 72 deletions(-) (limited to 'src/history/historypanel.cpp') diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index 4c1dc732..79efb2b1 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -33,105 +33,44 @@ // Local Includes #include "panels/urlfilterproxymodel.h" + #include "application.h" #include "paneltreeview.h" #include "historymodels.h" -// Qt Includes -#include -#include -#include -#include - - // KDE Includes -#include #include #include #include #include +// Qt Includes +#include + HistoryPanel::HistoryPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(title, parent, flags) - , m_treeView(new PanelTreeView(this)) - , _loaded(false) + : UrlPanel(title, parent, flags) { setObjectName("historyPanel"); - setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - - connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(showing(bool))); - - setShown(ReKonfig::showHistoryPanel()); + setVisible(ReKonfig::showHistoryPanel()); } HistoryPanel::~HistoryPanel() { - // Save side panel's state ReKonfig::setShowHistoryPanel(!isHidden()); } - -void HistoryPanel::showing(bool b) -{ - if(b && !_loaded) - setup(); -} - - void HistoryPanel::setup() { - kDebug() << "Loading history panel setup..."; - - QWidget *ui = new QWidget(this); - - m_treeView->setUniformRowHeights(true); - m_treeView->setSelectionBehavior(QAbstractItemView::SelectRows); - m_treeView->setTextElideMode(Qt::ElideMiddle); - m_treeView->setAlternatingRowColors(true); - m_treeView->header()->hide(); - - // add search bar - QHBoxLayout *hBoxLayout = new QHBoxLayout; - hBoxLayout->setContentsMargins(5, 0, 0, 0); - QLabel *searchLabel = new QLabel(i18n("Search:")); - hBoxLayout->addWidget(searchLabel); - KLineEdit *search = new KLineEdit; - search->setClearButtonShown(true); - hBoxLayout->addWidget(search); - QWidget *searchBar = new QWidget; - searchBar->setLayout(hBoxLayout); - - // setup layout - QVBoxLayout *vBoxLayout = new QVBoxLayout; - vBoxLayout->setContentsMargins(0, 0, 0, 0); - vBoxLayout->addWidget(searchBar); - vBoxLayout->addWidget(m_treeView); - - // add it to the UI - ui->setLayout(vBoxLayout); - setWidget(ui); - - //- - HistoryManager *historyManager = Application::historyManager(); - QAbstractItemModel *model = historyManager->historyTreeModel(); - - UrlFilterProxyModel *proxy = new UrlFilterProxyModel(this); - proxy->setSourceModel(model); - m_treeView->setModel(proxy); - m_treeView->setExpanded(proxy->index(0, 0), true); - m_treeView->header()->hideSection(1); - QFontMetrics fm(font()); - int header = fm.width( QL1C('m') ) * 40; - m_treeView->header()->resizeSection(0, header); + UrlPanel::setup(); + kDebug() << "History panel..."; - connect(search, SIGNAL(textChanged(QString)), proxy, SLOT(setFilterFixedString(QString))); - connect(m_treeView, SIGNAL(contextMenuItemRequested(const QPoint &)), this, SLOT(contextMenuItem(const QPoint &))); - connect(m_treeView, SIGNAL(contextMenuGroupRequested(const QPoint &)), this, SLOT(contextMenuGroup(const QPoint &))); + m_treeView->header()->hideSection(1); - _loaded = true; + const UrlFilterProxyModel *proxy = static_cast(m_treeView->model()); + m_treeView->expand(proxy->index(0, 0)); } @@ -173,6 +112,11 @@ void HistoryPanel::contextMenuGroup(const QPoint &pos) } +void HistoryPanel::contextMenuEmpty(const QPoint& /*pos*/) +{ +} + + void HistoryPanel::openAll() { QModelIndex index = m_treeView->currentIndex(); @@ -199,3 +143,9 @@ void HistoryPanel::openAll() emit openUrl(allChild.at(i).url(), Rekonq::NewTab); } + +QAbstractItemModel* HistoryPanel::getModel() +{ + return Application::historyManager()->historyTreeModel(); +} + -- 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/history/historypanel.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/history/historypanel.cpp') diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index 79efb2b1..c0097965 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -62,18 +62,6 @@ HistoryPanel::~HistoryPanel() } -void HistoryPanel::setup() -{ - UrlPanel::setup(); - kDebug() << "History panel..."; - - m_treeView->header()->hideSection(1); - - const UrlFilterProxyModel *proxy = static_cast(m_treeView->model()); - m_treeView->expand(proxy->index(0, 0)); -} - - void HistoryPanel::contextMenuItem(const QPoint &pos) { KMenu menu; @@ -144,8 +132,19 @@ void HistoryPanel::openAll() } +void HistoryPanel::setup() +{ + UrlPanel::setup(); + kDebug() << "History panel..."; + + m_treeView->header()->hideSection(1); + + const UrlFilterProxyModel *proxy = static_cast(m_treeView->model()); + m_treeView->expand(proxy->index(0, 0)); +} + + QAbstractItemModel* HistoryPanel::getModel() { return Application::historyManager()->historyTreeModel(); } - -- 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/history/historypanel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/history/historypanel.cpp') diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index c0097965..84f2296e 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -32,11 +32,10 @@ #include "rekonq.h" // Local Includes -#include "panels/urlfilterproxymodel.h" - #include "application.h" #include "paneltreeview.h" #include "historymodels.h" +#include "urlfilterproxymodel.h" // KDE Includes #include -- cgit v1.2.1