diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/bookmarks/bookmarkspanel.cpp | 5 | ||||
-rw-r--r-- | src/bookmarks/bookmarkspanel.h | 3 | ||||
-rw-r--r-- | src/history/historypanel.cpp | 82 | ||||
-rw-r--r-- | src/history/historypanel.h | 21 | ||||
-rw-r--r-- | src/history/sidepanel.cpp | 60 | ||||
-rw-r--r-- | src/history/sidepanel.h | 58 | ||||
-rw-r--r-- | src/mainwindow.cpp | 92 | ||||
-rw-r--r-- | src/mainwindow.h | 19 | ||||
-rw-r--r-- | src/rekonq.kcfg | 2 | ||||
-rw-r--r-- | src/webinspectorpanel.cpp (renamed from src/webinspectordock.cpp) | 17 | ||||
-rw-r--r-- | src/webinspectorpanel.h (renamed from src/webinspectordock.h) | 10 |
12 files changed, 123 insertions, 249 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c80aedc0..7a77c25c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,7 +21,7 @@ SET( rekonq_KDEINIT_SRCS webtab.cpp clicktoflash.cpp networkaccessmanager.cpp - webinspectordock.cpp + webinspectorpanel.cpp walletbar.cpp protocolhandler.cpp #---------------------------------------- @@ -29,7 +29,6 @@ SET( rekonq_KDEINIT_SRCS history/historymanager.cpp history/historymodels.cpp history/historypanel.cpp - history/sidepanel.cpp #---------------------------------------- rekonqpage/newtabpage.cpp #---------------------------------------- diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index 97097fbb..9164dbb6 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -57,7 +57,6 @@ BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::Window BookmarksPanel::~BookmarksPanel() { ReKonfig::setShowBookmarksPanel(!isHidden()); - delete ui; } @@ -73,7 +72,7 @@ void BookmarksPanel::setup() setObjectName("bookmarksPanel"); setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - ui = new QWidget(this); + QWidget *ui = new QWidget(this); // setup search bar QHBoxLayout *searchLayout = new QHBoxLayout; @@ -110,5 +109,5 @@ void BookmarksPanel::setup() treeView->setModel( proxy ); connect(search, SIGNAL(textChanged(QString)), proxy, SLOT(setFilterFixedString(QString))); - connect( treeView, SIGNAL( activated(QModelIndex) ), this, SLOT( bookmarkActivated(QModelIndex) ) ); + connect(treeView, SIGNAL( activated(QModelIndex) ), this, SLOT( bookmarkActivated(QModelIndex) ) ); } diff --git a/src/bookmarks/bookmarkspanel.h b/src/bookmarks/bookmarkspanel.h index b7c0b5ed..6c0e153f 100644 --- a/src/bookmarks/bookmarkspanel.h +++ b/src/bookmarks/bookmarkspanel.h @@ -38,7 +38,6 @@ class QModelIndex; class BookmarksPanel : public QDockWidget { Q_OBJECT - Q_DISABLE_COPY(BookmarksPanel) public: explicit BookmarksPanel(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0); @@ -52,8 +51,6 @@ private slots: private: void setup(); - - QWidget *ui; }; #endif // BOOKMARKSPANEL_H diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index 42497f9e..08dc3800 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -29,25 +29,52 @@ #include "historypanel.h" #include "historypanel.moc" +// Auto Includes +#include "rekonq.h" + +// Local Includes +#include "application.h" +#include "historymodels.h" + // Qt Includes #include <QtGui/QLabel> #include <QtGui/QHBoxLayout> #include <QtGui/QHeaderView> +#include <QtGui/QTreeView> + // KDE Includes #include <KLineEdit> #include <KLocalizedString> -HistoryPanel::HistoryPanel(QWidget *parent) - : QWidget(parent) - , m_historyTreeView(new QTreeView) - , m_treeProxyModel(new TreeProxyModel(this)) +HistoryPanel::HistoryPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) + : QDockWidget(title, parent, flags) +{ + setup(); + setShown(ReKonfig::showHistoryPanel()); +} + + +HistoryPanel::~HistoryPanel() +{ + // Save side panel's state + ReKonfig::setShowHistoryPanel(!isHidden()); +} + + +void HistoryPanel::setup() { - m_historyTreeView->setUniformRowHeights(true); - m_historyTreeView->setSelectionBehavior(QAbstractItemView::SelectRows); - m_historyTreeView->setTextElideMode(Qt::ElideMiddle); - m_historyTreeView->setAlternatingRowColors(true); + setObjectName("historyPanel"); + setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + + QWidget *ui = new QWidget(this); + + QTreeView *historyTreeView = new QTreeView(this); + historyTreeView->setUniformRowHeights(true); + historyTreeView->setSelectionBehavior(QAbstractItemView::SelectRows); + historyTreeView->setTextElideMode(Qt::ElideMiddle); + historyTreeView->setAlternatingRowColors(true); // add search bar QHBoxLayout *hBoxLayout = new QHBoxLayout; @@ -60,42 +87,35 @@ HistoryPanel::HistoryPanel(QWidget *parent) QWidget *searchBar = new QWidget; searchBar->setLayout(hBoxLayout); - // setup view + // setup layout QVBoxLayout *vBoxLayout = new QVBoxLayout; vBoxLayout->setContentsMargins(0, 0, 0, 0); vBoxLayout->addWidget(searchBar); - vBoxLayout->addWidget(m_historyTreeView); - setLayout(vBoxLayout); + vBoxLayout->addWidget(historyTreeView); + + // add it to the UI + ui->setLayout(vBoxLayout); + setWidget(ui); //- HistoryManager *historyManager = Application::historyManager(); QAbstractItemModel *model = historyManager->historyTreeModel(); - m_treeProxyModel->setSourceModel(model); - m_historyTreeView->setModel(m_treeProxyModel); - m_historyTreeView->setExpanded(m_treeProxyModel->index(0, 0), true); - m_historyTreeView->header()->hideSection(1); + TreeProxyModel *treeProxyModel = new TreeProxyModel(this); + treeProxyModel->setSourceModel(model); + historyTreeView->setModel(treeProxyModel); + historyTreeView->setExpanded(treeProxyModel->index(0, 0), true); + historyTreeView->header()->hideSection(1); QFontMetrics fm(font()); int header = fm.width(QLatin1Char('m')) * 40; - m_historyTreeView->header()->resizeSection(0, header); - - connect(search, SIGNAL(textChanged(QString)), m_treeProxyModel, SLOT(setFilterFixedString(QString))); - connect(m_historyTreeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(open())); -} - + historyTreeView->header()->resizeSection(0, header); -HistoryPanel::~HistoryPanel() -{ - delete m_treeProxyModel; - delete m_historyTreeView; + connect(search, SIGNAL(textChanged(QString)), treeProxyModel, SLOT(setFilterFixedString(QString))); + connect(historyTreeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(itemActivated(const QModelIndex &))); } -void HistoryPanel::open() +void HistoryPanel::itemActivated(const QModelIndex &item) { - QModelIndex index = m_historyTreeView->currentIndex(); - if (!index.parent().isValid()) - return; - emit openUrl(index.data(HistoryModel::UrlRole).toUrl()); + emit openUrl( item.data(HistoryModel::UrlRole).toUrl() ); } - diff --git a/src/history/historypanel.h b/src/history/historypanel.h index 083b2741..e07e2190 100644 --- a/src/history/historypanel.h +++ b/src/history/historypanel.h @@ -29,36 +29,31 @@ #define HISTORYPANEL_H -// Local Includes -#include "application.h" -#include "historymodels.h" - // Qt Includes -#include <QtGui/QWidget> -#include <QtGui/QTreeView> +#include <QDockWidget> // Forward Declarations class KUrl; +class QWidget; +class QModelIndex; -class HistoryPanel : public QWidget +class HistoryPanel : public QDockWidget { Q_OBJECT public: - explicit HistoryPanel(QWidget *parent = 0); - virtual ~HistoryPanel(); + explicit HistoryPanel(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0); + ~HistoryPanel(); signals: void openUrl(const KUrl &); private slots: - void open(); + void itemActivated(const QModelIndex &); private: - QTreeView *m_historyTreeView; - TreeProxyModel *m_treeProxyModel; - + void setup(); }; #endif // HISTORYPANEL_H diff --git a/src/history/sidepanel.cpp b/src/history/sidepanel.cpp deleted file mode 100644 index 7c42301c..00000000 --- a/src/history/sidepanel.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com> -* Copyright (C) 2009 by Paweł Prażak <pawelprazak 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 "sidepanel.h" -#include "sidepanel.moc" - -// Auto Includes -#include "rekonq.h" - -// Local Includes -#include "historypanel.h" - - -SidePanel::SidePanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(title, parent, flags) - , m_historyPanel(new HistoryPanel(this)) -{ - setObjectName("sidePanel"); - setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - - setShown(ReKonfig::showSideBar()); - - connect(m_historyPanel, SIGNAL(openUrl(const KUrl&)), this, SIGNAL(openUrl(const KUrl&))); - - setWidget(m_historyPanel); -} - - -SidePanel::~SidePanel() -{ - // Save side panel's state - ReKonfig::setShowSideBar(!isHidden()); - - delete m_historyPanel; -} diff --git a/src/history/sidepanel.h b/src/history/sidepanel.h deleted file mode 100644 index 6aca3587..00000000 --- a/src/history/sidepanel.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com> -* Copyright (C) 2009 by Paweł Prażak <pawelprazak 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 SIDEPANEL_H -#define SIDEPANEL_H - -// Local Includes -#include "application.h" - -// Qt Includes -#include <QDockWidget> - -// Forward Declarations -class KUrl; -class HistoryPanel; - - -class SidePanel : public QDockWidget -{ - Q_OBJECT - -public: - explicit SidePanel(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0); - ~SidePanel(); - -signals: - void openUrl(const KUrl &); - -private: - HistoryPanel *m_historyPanel; - -}; - -#endif // SIDEPANEL_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9352ec36..659e5bf5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -40,9 +40,9 @@ #include "webtab.h" #include "mainview.h" #include "findbar.h" -#include "sidepanel.h" +#include "historypanel.h" #include "bookmarkspanel.h" -#include "webinspectordock.h" +#include "webinspectorpanel.h" #include "urlbar.h" #include "tabbar.h" #include "adblockmanager.h" @@ -98,9 +98,9 @@ MainWindow::MainWindow() : KMainWindow() , m_view( new MainView(this) ) , m_findBar( new FindBar(this) ) - , m_sidePanel(0) + , m_historyPanel(0) , m_bookmarksPanel(0) - , m_webInspectorDock(0) + , m_webInspectorPanel(0) , m_historyBackMenu(0) , m_mainBar( new KToolBar( QString("MainToolBar"), this, Qt::TopToolBarArea, true, false, false) ) , m_bmBar( new KToolBar( QString("BookmarkToolBar"), this, Qt::TopToolBarArea, true, false, false) ) @@ -134,10 +134,8 @@ MainWindow::MainWindow() // then, setup our actions setupActions(); - // setting Side Panel - setupSidePanel(); - setupBookmarksPanel(); - setupWebInspector(); + // setting Panels + setupPanels(); // setting up rekonq tools setupTools(); @@ -166,17 +164,6 @@ MainWindow::~MainWindow() } -SidePanel *MainWindow::sidePanel() -{ - return m_sidePanel; -} - -BookmarksPanel *MainWindow::bookmarksPanel() -{ - return m_bookmarksPanel; -} - - void MainWindow::setupToolbars() { // ============ Main ToolBar ================================ @@ -459,51 +446,50 @@ void MainWindow::setupTools() } -void MainWindow::setupSidePanel() +void MainWindow::setupPanels() { - // Setup history side panel - m_sidePanel = new SidePanel(i18n("History Panel"), this); - connect(m_sidePanel, SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&))); - connect(m_sidePanel, SIGNAL(destroyed()), Application::instance(), SLOT(saveConfiguration())); + KAction* a; + + // STEP 1 + // Setup history panel + m_historyPanel = new HistoryPanel(i18n("History Panel"), this); + connect(m_historyPanel, SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&))); + connect(m_historyPanel, SIGNAL(destroyed()), Application::instance(), SLOT(saveConfiguration())); - addDockWidget(Qt::LeftDockWidgetArea, m_sidePanel); + addDockWidget(Qt::LeftDockWidgetArea, m_historyPanel); - // setup side panel actions - KAction* a = (KAction *) m_sidePanel->toggleViewAction(); - a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H)); + // setup history panel action + a = (KAction *) m_historyPanel->toggleViewAction(); + a->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_H) ); a->setIcon(KIcon("view-history")); actionCollection()->addAction(QLatin1String("show_history_panel"), a); -} - -void MainWindow::setupBookmarksPanel() -{ + // STEP 2 + // Setup bookmarks panel m_bookmarksPanel = new BookmarksPanel(i18n("Bookmarks Panel"), this); connect(m_bookmarksPanel, SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&))); connect(m_bookmarksPanel, SIGNAL(destroyed()), Application::instance(), SLOT(saveConfiguration())); addDockWidget(Qt::LeftDockWidgetArea, m_bookmarksPanel); - // setup side panel actions - KAction* a = (KAction *) m_bookmarksPanel->toggleViewAction(); - a->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B)); + // setup bookmarks panel action + a = (KAction *) m_bookmarksPanel->toggleViewAction(); + a->setShortcut( QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B) ); a->setIcon(KIcon("bookmarks-organize")); actionCollection()->addAction(QLatin1String("show_bookmarks_panel"), a); -} - -void MainWindow::setupWebInspector() -{ - m_webInspectorDock = new WebInspectorDock(i18n("Web Inspector"), this); - connect(mainView(), SIGNAL(currentChanged(int)), m_webInspectorDock, SLOT(changeCurrentPage())); + // STEP 3 + // Setup webinspector panel + m_webInspectorPanel = new WebInspectorPanel(i18n("Web Inspector"), this); + connect(mainView(), SIGNAL(currentChanged(int)), m_webInspectorPanel, SLOT(changeCurrentPage())); - KAction *a = new KAction(KIcon("tools-report-bug"), i18n("Web &Inspector"), this); + a = new KAction(KIcon("tools-report-bug"), i18n("Web &Inspector"), this); a->setCheckable(true); actionCollection()->addAction(QLatin1String("web_inspector"), a); - connect(a, SIGNAL(triggered(bool)), m_webInspectorDock, SLOT(toggle(bool))); + connect(a, SIGNAL(triggered(bool)), m_webInspectorPanel, SLOT(toggle(bool))); - addDockWidget(Qt::BottomDockWidgetArea, m_webInspectorDock); - m_webInspectorDock->hide(); + addDockWidget(Qt::BottomDockWidgetArea, m_webInspectorPanel); + m_webInspectorPanel->hide(); } @@ -808,7 +794,7 @@ void MainWindow::setWidgetsVisible(bool makeVisible) { // state flags static bool bookmarksToolBarFlag; - static bool sidePanelFlag; + static bool historyPanelFlag; static bool bookmarksPanelFlag; if (!makeVisible) @@ -817,14 +803,14 @@ void MainWindow::setWidgetsVisible(bool makeVisible) if (!isFullScreen()) { bookmarksToolBarFlag = m_bmBar->isHidden(); - sidePanelFlag = sidePanel()->isHidden(); - bookmarksPanelFlag = bookmarksPanel()->isHidden(); + historyPanelFlag = m_historyPanel->isHidden(); + bookmarksPanelFlag = m_bookmarksPanel->isHidden(); } m_bmBar->hide(); m_view->setTabBarHidden(true); - sidePanel()->hide(); - bookmarksPanel()->hide(); + m_historyPanel->hide(); + m_bookmarksPanel->hide(); // hide main toolbar m_mainBar->hide(); @@ -838,10 +824,10 @@ void MainWindow::setWidgetsVisible(bool makeVisible) // restore state of windowed mode if (!bookmarksToolBarFlag) m_bmBar->show(); - if (!sidePanelFlag) - sidePanel()->show(); + if (!historyPanelFlag) + m_historyPanel->show(); if (!bookmarksPanelFlag) - bookmarksPanel()->show(); + m_bookmarksPanel->show(); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 49dc2a59..7083591d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -46,9 +46,9 @@ class KAction; class KPassivePopup; class FindBar; -class SidePanel; +class HistoryPanel; class BookmarksPanel; -class WebInspectorDock; +class WebInspectorPanel; class WebTab; class MainView; @@ -77,15 +77,8 @@ private: void setupActions(); void setupTools(); void setupToolbars(); - - void setupSidePanel(); - SidePanel *sidePanel(); - - void setupBookmarksPanel(); - BookmarksPanel *bookmarksPanel(); + void setupPanels(); - void setupWebInspector(); - public slots: void updateBrowser(); void homePage(); @@ -159,9 +152,10 @@ private slots: private: MainView *m_view; FindBar *m_findBar; - SidePanel *m_sidePanel; + + HistoryPanel *m_historyPanel; BookmarksPanel *m_bookmarksPanel; - WebInspectorDock *m_webInspectorDock; + WebInspectorPanel *m_webInspectorPanel; KAction *m_stopReloadAction; KMenu *m_historyBackMenu; @@ -178,4 +172,3 @@ private: }; #endif // MAINWINDOW_H - diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index f74fb144..a24508fc 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -35,7 +35,7 @@ <entry name="homePage" type="String"> <default>http://www.kde.org/</default> </entry> - <entry name="showSideBar" type="Bool"> + <entry name="showHistoryPanel" type="Bool"> <default>false</default> </entry> <entry name="showBookmarksPanel" type="Bool"> diff --git a/src/webinspectordock.cpp b/src/webinspectorpanel.cpp index 55ae11cf..a038d280 100644 --- a/src/webinspectordock.cpp +++ b/src/webinspectorpanel.cpp @@ -23,9 +23,10 @@ * * ============================================================ */ + // Self Includes -#include "webinspectordock.h" -#include "webinspectordock.moc" +#include "webinspectorpanel.h" +#include "webinspectorpanel.moc" // Local Includes #include "webtab.h" @@ -40,26 +41,28 @@ #include <QWebInspector> -WebInspectorDock::WebInspectorDock(QString title, QWidget *parent) +WebInspectorPanel::WebInspectorPanel(QString title, QWidget *parent) : QDockWidget(title, parent) { setObjectName("webInspectorDock"); setWidget( new QWebInspector(this) ); } -void WebInspectorDock::closeEvent(QCloseEvent *event) + +void WebInspectorPanel::closeEvent(QCloseEvent *event) { Q_UNUSED(event); toggle(false); } -MainWindow* WebInspectorDock::mainWindow() + +MainWindow* WebInspectorPanel::mainWindow() { return qobject_cast< MainWindow* >(parentWidget()); } -void WebInspectorDock::toggle(bool enable) +void WebInspectorPanel::toggle(bool enable) { mainWindow()->actionByName("web_inspector")->setChecked(enable); if (enable) @@ -76,7 +79,7 @@ void WebInspectorDock::toggle(bool enable) } -void WebInspectorDock::changeCurrentPage() +void WebInspectorPanel::changeCurrentPage() { bool enable = mainWindow()->currentTab()->view()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled); toggle(enable); diff --git a/src/webinspectordock.h b/src/webinspectorpanel.h index c6697361..8f65b48a 100644 --- a/src/webinspectordock.h +++ b/src/webinspectorpanel.h @@ -24,8 +24,8 @@ * ============================================================ */ -#ifndef WEBINSPECTORDOCK_H -#define WEBINSPECTORDOCK_H +#ifndef WEBINSPECTOR_PANEL_H +#define WEBINSPECTOR_PANEL_H // Local Includes @@ -38,11 +38,11 @@ Docked web inspector behaviour : hide/show by tab, not globally */ -class WebInspectorDock : public QDockWidget +class WebInspectorPanel : public QDockWidget { Q_OBJECT public: - WebInspectorDock(QString title, QWidget *parent); + WebInspectorPanel(QString title, QWidget *parent); public slots: void toggle(bool enable); @@ -55,4 +55,4 @@ protected: }; -#endif
\ No newline at end of file +#endif |