summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornehlsen <nehlsen@gmail.com>2009-11-16 15:03:42 +0100
committernehlsen <nehlsen@gmail.com>2009-11-16 15:03:42 +0100
commit2e9b9376fd8857e4667d8c6e18cb0f66a3fc3726 (patch)
treece9757e40965ca7029fc8a89d76235a863003a20 /src
parentFixing "open in ne window" slot (diff)
downloadrekonq-2e9b9376fd8857e4667d8c6e18cb0f66a3fc3726.tar.xz
added bookmarks panel and model(read only atm)
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt15
-rw-r--r--src/bookmarks.h6
-rw-r--r--src/bookmarkspanel/bookmarkspanel.cpp122
-rw-r--r--src/bookmarkspanel/bookmarkspanel.h58
-rw-r--r--src/bookmarkspanel/bookmarkstreemodel.cpp255
-rw-r--r--src/bookmarkspanel/bookmarkstreemodel.h69
-rw-r--r--src/mainwindow.cpp60
-rw-r--r--src/mainwindow.h13
-rw-r--r--src/rekonq.kcfg5
9 files changed, 575 insertions, 28 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9c0ace58..6b3f9edf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,16 +10,16 @@ SET( rekonq_KDEINIT_SRCS
previewimage.cpp
websnap.cpp
networkaccessmanager.cpp
- autosaver.cpp
- application.cpp
- mainwindow.cpp
+ autosaver.cpp
+ application.cpp
+ mainwindow.cpp
mainview.cpp
tabbar.cpp
cookiejar.cpp
history.cpp
historymodels.cpp
bookmarks.cpp
- modelmenu.cpp
+ modelmenu.cpp
urlbar.cpp
findbar.cpp
settings.cpp
@@ -30,6 +30,9 @@ SET( rekonq_KDEINIT_SRCS
webpage.cpp
sessionmanager.cpp
webpluginfactory.cpp
+
+ bookmarkspanel/bookmarkspanel.cpp
+ bookmarkspanel/bookmarkstreemodel.cpp
)
@@ -65,9 +68,9 @@ KDE4_ADD_KDEINIT_EXECUTABLE( rekonq ${rekonq_KDEINIT_SRCS} main.cpp )
### --------------- TARGETTING LINK LIBRARIES...
TARGET_LINK_LIBRARIES ( kdeinit_rekonq
- ${QT_LIBRARIES}
+ ${QT_LIBRARIES}
${QT_QTNETWORK_LIBRARY}
- ${QT_QTWEBKIT_LIBRARY}
+ ${QT_QTWEBKIT_LIBRARY}
${KDE4_KUTILS_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
diff --git a/src/bookmarks.h b/src/bookmarks.h
index 0fde004f..febac234 100644
--- a/src/bookmarks.h
+++ b/src/bookmarks.h
@@ -12,9 +12,9 @@
* 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
+* 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
@@ -208,6 +208,8 @@ public:
* @return the root bookmark group
*/
KBookmarkGroup rootGroup();
+
+ KBookmarkManager *bookmarkManager() { return m_manager; }
signals:
/**
* @short This signal is emitted when an url has to be loaded
diff --git a/src/bookmarkspanel/bookmarkspanel.cpp b/src/bookmarkspanel/bookmarkspanel.cpp
new file mode 100644
index 00000000..1f3dff9b
--- /dev/null
+++ b/src/bookmarkspanel/bookmarkspanel.cpp
@@ -0,0 +1,122 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2009 by Nils Weigel <nehlsen 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/>.
+*
+* ============================================================ */
+
+
+// rekonq includes
+#include "bookmarkspanel.h"
+#include "bookmarkstreemodel.h"
+
+// Auto Includes
+#include "rekonq.h"
+
+// Qt includes
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QTreeView>
+#include <QSortFilterProxyModel>
+#include <QHeaderView>
+
+// KDE includes
+#include <KLineEdit>
+#include <KLocalizedString>
+
+BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags):
+ QDockWidget(title, parent, flags)
+{
+ setup();
+
+ setShown(ReKonfig::showBookmarksPanel());
+}
+
+
+BookmarksPanel::~BookmarksPanel()
+{
+ ReKonfig::setShowBookmarksPanel(!isHidden());
+
+ delete ui;
+}
+
+void BookmarksPanel::bookmarkActivated( const QModelIndex &index )
+{
+ if( index.isValid() )
+ emit openUrl( qVariantValue< KUrl >( index.data( Qt::UserRole ) ) );
+}
+
+void BookmarksPanel::setup()
+{
+ setObjectName("bookmarksPanel");
+ setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+
+ 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);
+
+ // setup tree view
+ QTreeView *treeView = new QTreeView(ui);
+ treeView->setUniformRowHeights(true);
+ treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
+ treeView->setTextElideMode(Qt::ElideMiddle);
+ treeView->setAlternatingRowColors(true);
+ treeView->header()->hide();
+ treeView->setRootIsDecorated( false );
+
+ // 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);
+
+ BookmarksTreeModel *model = new BookmarksTreeModel( this );
+ treeView->setModel( model );
+
+ connect( treeView, SIGNAL( activated(QModelIndex) ), this, SLOT( bookmarkActivated(QModelIndex) ) );
+
+// QSortFilterProxyModel *proxy = new QSortFilterProxyModel(ui);
+ //-
+// HistoryManager *historyManager = Application::historyManager();
+// QAbstractItemModel *model = historyManager->historyTreeModel();
+//
+// m_treeProxyModel->setSourceModel(model);
+// m_treeView->setModel(m_treeProxyModel);
+// m_treeView->setExpanded(m_treeProxyModel->index(0, 0), true);
+// m_treeView->header()->hideSection(1);
+// QFontMetrics fm(font());
+// int header = fm.width(QLatin1Char('m')) * 40;
+// m_treeView->header()->resizeSection(0, header);
+//
+// connect(search, SIGNAL(textChanged(QString)), m_treeProxy, SLOT(setFilterFixedString(QString)));
+// connect(m_treeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(open()));
+}
diff --git a/src/bookmarkspanel/bookmarkspanel.h b/src/bookmarkspanel/bookmarkspanel.h
new file mode 100644
index 00000000..8c3e6121
--- /dev/null
+++ b/src/bookmarkspanel/bookmarkspanel.h
@@ -0,0 +1,58 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2009 by Nils Weigel <nehlsen 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 BOOKMARKSPANEL_H
+#define BOOKMARKSPANEL_H
+
+// Qt Includes
+#include <QDockWidget>
+
+// Forward Declarations
+class KUrl;
+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);
+ ~BookmarksPanel();
+
+signals:
+ void openUrl(const KUrl &);
+
+private slots:
+ void bookmarkActivated( const QModelIndex &index );
+
+private:
+ void setup();
+
+ QWidget *ui;
+};
+
+#endif // BOOKMARKSPANEL_H
diff --git a/src/bookmarkspanel/bookmarkstreemodel.cpp b/src/bookmarkspanel/bookmarkstreemodel.cpp
new file mode 100644
index 00000000..99441a63
--- /dev/null
+++ b/src/bookmarkspanel/bookmarkstreemodel.cpp
@@ -0,0 +1,255 @@
+#include "bookmarkstreemodel.h"
+
+// rekonq includes
+#include "../application.h"
+#include "../bookmarks.h"
+
+// KDE includes
+#include <KBookmarkGroup>
+#include <KLocalizedString>
+
+class BookmarksTreeModel::BtmItem
+{
+public:
+ BtmItem(const KBookmark &bm):
+ m_parent(0), m_kbm(bm)
+ {
+ }
+ ~BtmItem()
+ {
+ qDeleteAll(m_children);
+ }
+
+ QVariant data( int role = Qt::DisplayRole ) const
+ {
+ if( m_kbm.isNull() )
+ return QVariant();// should only happen for root item
+
+ if( role == Qt::DisplayRole )
+ return m_kbm.text();
+ if( role == Qt::DecorationRole )
+ return KIcon( m_kbm.icon() );
+ if( role == Qt::UserRole )
+ return m_kbm.url();
+
+ return QVariant();
+ }
+
+ int row() const
+ {
+ if(m_parent)
+ return m_parent->m_children.indexOf( const_cast< BtmItem* >( this ) );
+ return 0;
+ }
+ int childCount() const
+ {
+ return m_children.count();
+ }
+ BtmItem* child( int n )
+ {
+ Q_ASSERT(n>=0);
+ Q_ASSERT(n<childCount());
+
+ return m_children.at(n);
+ }
+ BtmItem* parent() const
+ {
+ return m_parent;
+ }
+
+ void appendChild(BtmItem *child)
+ {
+// Q_ASSERT( child != 0 );
+ if( !child )
+ return;
+
+ child->m_parent = this;
+ m_children << child;
+ }
+ void clear()
+ {
+ qDeleteAll(m_children);
+ m_children.clear();
+ }
+
+private:
+ BtmItem *m_parent;
+ QList< BtmItem* > m_children;
+
+ KBookmark m_kbm;
+};
+
+BookmarksTreeModel::BookmarksTreeModel(QObject *parent):
+ QAbstractItemModel(parent), m_root(0)
+{
+ resetModel();
+ connect( Application::bookmarkProvider()->bookmarkManager(), SIGNAL( changed(QString,QString) ), this, SLOT( bookmarksChanged(QString) ) );
+ connect( Application::bookmarkProvider()->bookmarkManager(), SIGNAL( bookmarksChanged(QString) ), this, SLOT( bookmarksChanged(QString) ) );
+}
+
+BookmarksTreeModel::~BookmarksTreeModel()
+{
+ delete m_root;
+}
+
+int BookmarksTreeModel::rowCount(const QModelIndex &parent) const
+{
+ BtmItem *parentItem = 0;
+ if( !parent.isValid() ) {
+ parentItem = m_root;
+ }
+ else {
+ parentItem = static_cast< BtmItem* >( parent.internalPointer() );
+ }
+
+ return parentItem->childCount();
+}
+
+int BookmarksTreeModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ // name
+ return 1;
+}
+
+QVariant BookmarksTreeModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if( orientation == Qt::Horizontal && role == Qt::DisplayRole && section == 0 )
+ return i18n( "Bookmark" );
+
+ return QVariant();
+}
+
+Qt::ItemFlags BookmarksTreeModel::flags(const QModelIndex &/*index*/) const
+{
+ return Qt::ItemIsEnabled|Qt::ItemIsSelectable;
+}
+
+QModelIndex BookmarksTreeModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if( !hasIndex( row, column, parent ) ) {
+ return QModelIndex();
+ }
+
+ BtmItem *parentItem;
+
+ if( !parent.isValid() ) {
+ parentItem = m_root;
+ }
+ else {
+ parentItem = static_cast< BtmItem* >( parent.internalPointer() );
+ }
+
+ BtmItem *childItem = parentItem->child( row );
+ if( childItem ) {
+ return createIndex( row, column, childItem );
+ }
+
+ return QModelIndex();
+}
+
+QModelIndex BookmarksTreeModel::parent(const QModelIndex &index) const
+{
+ if( !index.isValid() ) {
+ return QModelIndex();
+ }
+
+ BtmItem *childItem = static_cast< BtmItem* >( index.internalPointer() );
+ BtmItem *parentItem = childItem->parent();
+
+ if( parentItem == m_root ) {
+ return QModelIndex();
+ }
+
+ return createIndex( parentItem->row(), 0, parentItem );
+}
+
+QVariant BookmarksTreeModel::data(const QModelIndex &index, int role) const
+{
+ if( !index.isValid() ) {
+ return QVariant();
+ }
+
+ BtmItem *node = static_cast< BtmItem* >( index.internalPointer() );
+ if( node && node == m_root ) {
+ if( role == Qt::DisplayRole )
+ return i18n( "Bookmarks" );
+ else if( role == Qt::DecorationRole )
+ return KIcon( "bookmarks" );
+ }
+ else if( node ) {
+ return node->data( role );
+ }
+
+ return QVariant();
+}
+
+// bool BookmarksTreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
+// {
+// }
+
+void BookmarksTreeModel::bookmarksChanged( const QString &groupAddress )
+{
+// qDebug( "bookmarksChanged '%s'", qPrintable( groupAddress ) );
+
+ if( groupAddress.isEmpty() ) {
+ resetModel();
+ return;
+ }
+
+ BtmItem *node = m_root;
+ QModelIndex nodeIndex;
+
+ QStringList indexChain( groupAddress.split( '/', QString::SkipEmptyParts) );
+ foreach( QString sIndex, indexChain ) {
+ bool ok;
+ int i = sIndex.toInt( &ok );
+ if( !ok )
+ break;
+
+ if( i < 0 || i >= node->childCount() )
+ break;
+
+ node = node->child( i );
+ nodeIndex = index( i, 0, nodeIndex );
+ }
+// qDebug( " changed: '%s'(0-%d)", ( node == m_root ? "ROOT" : qPrintable( node->data().toString() ) ), node->childCount() );
+ emit dataChanged( index( 0, 0, nodeIndex ), index( node->childCount(), 0, nodeIndex ) );
+}
+
+void BookmarksTreeModel::resetModel()
+{
+ setRoot(Application::bookmarkProvider()->rootGroup());
+}
+
+void BookmarksTreeModel::setRoot(KBookmarkGroup bmg)
+{
+ delete m_root;
+ m_root = new BtmItem(KBookmark());
+
+ if( bmg.isNull() ) {
+ return;
+ }
+
+ populate( m_root, bmg );
+
+ reset();
+}
+
+void BookmarksTreeModel::populate( BtmItem *node, KBookmarkGroup bmg)
+{
+ node->clear();
+
+ if( bmg.isNull() ) {
+ return;
+ }
+
+ KBookmark bm = bmg.first();
+ while( !bm.isNull() ) {
+ BtmItem *newChild = new BtmItem( bm );
+ if( bm.isGroup() )
+ populate( newChild, bm.toGroup() );
+
+ node->appendChild( newChild );
+ bm = bmg.next( bm );
+ }
+}
diff --git a/src/bookmarkspanel/bookmarkstreemodel.h b/src/bookmarkspanel/bookmarkstreemodel.h
new file mode 100644
index 00000000..9753999c
--- /dev/null
+++ b/src/bookmarkspanel/bookmarkstreemodel.h
@@ -0,0 +1,69 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2009 by Nils Weigel <nehlsen 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 BOOKMARKSTREEMODEL_H
+#define BOOKMARKSTREEMODEL_H
+
+// Qt Includes
+#include <QAbstractItemModel>
+
+// KDE includes
+#include <KBookmark>
+
+class BookmarksTreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(BookmarksTreeModel)
+
+public:
+ explicit BookmarksTreeModel(QObject *parent = 0);
+ ~BookmarksTreeModel();
+
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+ virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ virtual QModelIndex parent(const QModelIndex &index) const;
+ virtual QVariant data(const QModelIndex &index, int role) const;
+// virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
+
+private slots:
+ void bookmarksChanged( const QString &groupAddress );
+
+private:
+ class BtmItem;
+ BtmItem *m_root;
+
+ void resetModel();
+
+ void setRoot(KBookmarkGroup bmg);
+ void populate( BtmItem *node, KBookmarkGroup bmg);
+};
+
+#endif // BOOKMARKSTREEMODEL_H
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7a9e3ad6..e2e45ae0 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -44,6 +44,7 @@
#include "mainview.h"
#include "findbar.h"
#include "sidepanel.h"
+#include "bookmarkspanel/bookmarkspanel.h"
#include "urlbar.h"
#include "tabbar.h"
#include "newtabpage.h"
@@ -97,6 +98,7 @@ MainWindow::MainWindow()
, m_view(new MainView(this))
, m_findBar(new FindBar(this))
, m_sidePanel(0)
+ , m_bookmarksPanel(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) )
@@ -133,6 +135,7 @@ MainWindow::MainWindow()
// setting Side Panel
setupSidePanel();
+ setupBookmarksPanel();
// setting up rekonq tools
setupTools();
@@ -166,6 +169,11 @@ SidePanel *MainWindow::sidePanel()
return m_sidePanel;
}
+BookmarksPanel *MainWindow::bookmarksPanel()
+{
+ return m_bookmarksPanel;
+}
+
void MainWindow::setupToolbars()
{
@@ -185,7 +193,7 @@ void MainWindow::setupToolbars()
KAction *urlBarAction = new KAction(this);
urlBarAction->setDefaultWidget(m_view->urlBar());
m_mainBar->addAction( urlBarAction );
-
+
m_mainBar->addAction( actionByName("bookmarksActionMenu") );
m_mainBar->addAction( actionByName("rekonq_tools") );
@@ -210,7 +218,7 @@ void MainWindow::postLaunch()
connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(updateWindowTitle(const QString &)));
connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *)));
- // (shift +) ctrl + tab switching
+ // (shift +) ctrl + tab switching
connect(this, SIGNAL(ctrlTabPressed()), m_view, SLOT(nextTab()));
connect(this, SIGNAL(shiftCtrlTabPressed()), m_view, SLOT(previousTab()));
@@ -220,7 +228,7 @@ void MainWindow::postLaunch()
// launch it manually. Just the first time...
updateActions();
-
+
// Find Bar signal
connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(find(const QString &)));
@@ -255,7 +263,7 @@ void MainWindow::setupActions()
actionCollection()->addAssociatedWidget(this);
KAction *a;
-
+
// new window action
a = new KAction(KIcon("window-new"), i18n("&New Window"), this);
a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_N));
@@ -379,11 +387,11 @@ void MainWindow::setupActions()
a = new KAction(KIcon("tab-close-other"), i18n("Close &Other Tabs"), this);
actionCollection()->addAction( QLatin1String("close_other_tabs"), a);
connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(closeOtherTabs()) );
-
+
a = new KAction(KIcon("view-refresh"), i18n("Reload Tab"), this);
actionCollection()->addAction( QLatin1String("reload_tab"), a);
connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(reloadTab()) );
-
+
// ----------------------- Bookmarks ToolBar Action --------------------------------------
QAction *qa = m_bmBar->toggleViewAction();
qa->setText( i18n("Bookmarks Toolbar") );
@@ -430,6 +438,7 @@ void MainWindow::setupTools()
toolsMenu->addAction(actionByName(QLatin1String("bm_bar")));
toolsMenu->addAction(actionByName(QLatin1String("show_history_panel")));
+ toolsMenu->addAction(actionByName(QLatin1String("show_bookmarks_panel")));
toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::FullScreen)));
toolsMenu->addSeparator();
@@ -459,6 +468,21 @@ void MainWindow::setupSidePanel()
actionCollection()->addAction(QLatin1String("show_history_panel"), a);
}
+void MainWindow::setupBookmarksPanel()
+{
+ 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)); // FIXME: this shortcut should be configurable !
+ a->setIcon(KIcon("bookmarks-organize"));
+ actionCollection()->addAction(QLatin1String("show_bookmarks_panel"), a);
+}
+
void MainWindow::updateConfiguration()
{
@@ -500,7 +524,7 @@ void MainWindow::updateConfiguration()
QWebSettings::setOfflineStoragePath(path);
QWebSettings::setOfflineStorageDefaultQuota(50000);
}
-
+
// Applies user defined CSS to all open webpages. If there no longer is a
// user defined CSS removes it from all open webpages.
defaultSettings->setUserStyleSheetUrl(ReKonfig::userCSS());
@@ -588,7 +612,7 @@ void MainWindow::updateWindowTitle(const QString &title)
void MainWindow::fileOpen()
{
QString filePath = KFileDialog::getOpenFileName(KUrl(),
- i18n("*.html *.htm *.svg *.png *.gif *.svgz|Web Resources (*.html *.htm *.svg *.png *.gif *.svgz)\n"
+ i18n("*.html *.htm *.svg *.png *.gif *.svgz|Web Resources (*.html *.htm *.svg *.png *.gif *.svgz)\n"
"*.*|All files (*.*)"),
this,
i18n("Open Web Resource"));
@@ -726,6 +750,7 @@ void MainWindow::viewFullScreen(bool makeFullScreen)
// state flags
static bool bookmarksToolBarFlag;
static bool sidePanelFlag;
+ static bool bookmarksPanelFlag;
if (makeFullScreen == true)
{
@@ -736,6 +761,9 @@ void MainWindow::viewFullScreen(bool makeFullScreen)
sidePanelFlag = sidePanel()->isHidden();
sidePanel()->hide();
+ bookmarksPanelFlag = bookmarksPanel()->isHidden();
+ bookmarksPanel()->hide();
+
// hide main toolbar
m_mainBar->hide();
}
@@ -749,6 +777,8 @@ void MainWindow::viewFullScreen(bool makeFullScreen)
m_bmBar->show();
if (!sidePanelFlag)
sidePanel()->show();
+ if (!bookmarksPanelFlag)
+ bookmarksPanel()->show();
}
KToggleFullScreenAction::setFullScreen(this, makeFullScreen);
@@ -926,7 +956,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
m_view->closeTab(m_view->currentIndex());
return;
}
-
+
KMainWindow::keyPressEvent(event);
}
@@ -960,7 +990,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
}
m_hidePopup->stop();
-
+
switch(status)
{
@@ -1079,7 +1109,7 @@ void MainWindow::aboutToShowBackMenu()
QWebHistoryItem item = history->backItems(history->count()).at(i);
KAction *action = new KAction(this);
action->setData( i - history->currentItemIndex() );
- QIcon icon = Application::icon(item.url());
+ QIcon icon = Application::icon(item.url());
action->setIcon(icon);
action->setText(item.title());
m_historyBackMenu->addAction(action);
@@ -1091,7 +1121,7 @@ void MainWindow::openActionUrl(QAction *action)
{
int offset = action->data().toInt();
QWebHistory *history = currentTab()->history();
-
+
if(!history->itemAt(offset).isValid())
{
kDebug() << "Invalid Offset!";
@@ -1116,9 +1146,9 @@ bool MainWindow::newTabPage(const KUrl &url)
{
if(m_loadingNewTabPage)
return false;
-
- if ( url == KUrl("about:closedTabs")
- || url == KUrl("about:history")
+
+ if ( url == KUrl("about:closedTabs")
+ || url == KUrl("about:history")
|| url == KUrl("about:bookmarks")
|| url == KUrl("about:favorites")
|| url == KUrl("about:home")
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 5071cdb2..af052c1b 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -12,9 +12,9 @@
* 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
+* 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
@@ -48,6 +48,7 @@ class KPassivePopup;
class FindBar;
class SidePanel;
+class BookmarksPanel;
class WebView;
class MainView;
@@ -81,6 +82,9 @@ private:
void setupSidePanel();
SidePanel *sidePanel();
+ void setupBookmarksPanel();
+ BookmarksPanel *bookmarksPanel();
+
public slots:
void updateBrowser();
void homePage();
@@ -159,20 +163,21 @@ private:
MainView *m_view;
FindBar *m_findBar;
SidePanel *m_sidePanel;
+ BookmarksPanel *m_bookmarksPanel;
KAction *m_stopReloadAction;
KMenu *m_historyBackMenu;
KToolBar *m_mainBar;
KToolBar *m_bmBar;
-
+
QString m_lastSearch;
KPassivePopup *m_popup;
QTimer *m_hidePopup;
KActionCollection *m_ac;
-
+
bool m_loadingNewTabPage;
};
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index 5505e4b2..500c06b7 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -35,6 +35,9 @@
<entry name="showSideBar" type="Bool">
<default>false</default>
</entry>
+ <entry name="showBookmarksPanel" type="Bool">
+ <default>false</default>
+ </entry>
</group>
<!-- Tabs Settings -->
@@ -74,7 +77,7 @@
<group name="Privacy">
<entry name="expireHistory" type="Int">
<default>1</default>
- </entry>
+ </entry>
<entry name="acceptCookies" type="Int">
<default>2</default>
</entry>