From 6a5f7762fa7e2876d63c4adb9a1842acef0c7333 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 14 Apr 2010 10:39:36 +0200 Subject: Stupid commit :) Renamed urltreeview files to paneltreeviews one to let my konsole tab completion easily work. Blame me for this.. --- src/CMakeLists.txt | 2 +- src/bookmarks/bookmarkspanel.cpp | 6 +- src/bookmarks/bookmarkspanel.h | 4 +- src/history/historypanel.cpp | 4 +- src/history/historypanel.h | 4 +- src/paneltreeview.cpp | 196 +++++++++++++++++++++++++++++++++++++++ src/paneltreeview.h | 69 ++++++++++++++ src/urltreeview.cpp | 195 -------------------------------------- src/urltreeview.h | 69 -------------- 9 files changed, 275 insertions(+), 274 deletions(-) create mode 100644 src/paneltreeview.cpp create mode 100644 src/paneltreeview.h delete mode 100644 src/urltreeview.cpp delete mode 100644 src/urltreeview.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 102935a6..2ab308de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,11 +15,11 @@ SET( rekonq_KDEINIT_SRCS mainwindow.cpp networkaccessmanager.cpp newtabpage.cpp + paneltreeview.cpp previewselectorbar.cpp protocolhandler.cpp sessionmanager.cpp tabbar.cpp - urltreeview.cpp walletbar.cpp webinspectorpanel.cpp webpage.cpp diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index 611031b5..0caf0f31 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -51,9 +51,9 @@ BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(title, parent, flags), - m_treeView(new UrlTreeView(this)), - m_loadingState(false) + : QDockWidget(title, parent, flags) + , m_treeView(new PanelTreeView(this)) + , m_loadingState(false) { setup(); setShown(ReKonfig::showBookmarksPanel()); diff --git a/src/bookmarks/bookmarkspanel.h b/src/bookmarks/bookmarkspanel.h index 86794d3a..90597c73 100644 --- a/src/bookmarks/bookmarkspanel.h +++ b/src/bookmarks/bookmarkspanel.h @@ -33,7 +33,7 @@ // Local Includes #include "rekonqprivate_export.h" #include "application.h" -#include "urltreeview.h" +#include "paneltreeview.h" // Qt Includes #include @@ -73,7 +73,7 @@ private: void setup(); KBookmark bookmarkForIndex(const QModelIndex &index); - UrlTreeView *m_treeView; + PanelTreeView *m_treeView; bool m_loadingState; }; diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index 87b5fe55..8c36dfa8 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -52,8 +52,8 @@ HistoryPanel::HistoryPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(title, parent, flags), - m_treeView(new UrlTreeView(this)) + : QDockWidget(title, parent, flags) + , m_treeView(new PanelTreeView(this)) { setup(); setShown(ReKonfig::showHistoryPanel()); diff --git a/src/history/historypanel.h b/src/history/historypanel.h index 0c01189c..a4dfaf64 100644 --- a/src/history/historypanel.h +++ b/src/history/historypanel.h @@ -32,7 +32,7 @@ // Local Includes #include "rekonqprivate_export.h" #include "application.h" -#include "urltreeview.h" +#include "paneltreeview.h" // Qt Includes #include @@ -62,7 +62,7 @@ private slots: private: void setup(); - UrlTreeView *m_treeView; + PanelTreeView *m_treeView; }; #endif // HISTORYPANEL_H diff --git a/src/paneltreeview.cpp b/src/paneltreeview.cpp new file mode 100644 index 00000000..c13caf4d --- /dev/null +++ b/src/paneltreeview.cpp @@ -0,0 +1,196 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 by Yoann Laissus +* +* +* 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 . +* +* ============================================================ */ + + +// Self Includes +#include "paneltreeview.h" +#include "paneltreeview.moc" + +// Local Includes +#include "application.h" + +// Qt Includes +#include +#include + + +PanelTreeView::PanelTreeView(QWidget *parent) + : QTreeView(parent) +{ + connect(this, SIGNAL(itemHovered(const QString &)), parent, SIGNAL(itemHovered(const QString &))); + connect(this, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), parent, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType))); + setMouseTracking(true); + setExpandsOnDoubleClick(false); +} + + +PanelTreeView::~PanelTreeView() +{ +} + + +void PanelTreeView::mousePressEvent(QMouseEvent *event) +{ + const QModelIndex index = indexAt(event->pos()); + bool expanded = isExpanded(index); + + QTreeView::mousePressEvent(event); + + // A change of an item expansion is handle by mouseReleaseEvent() + // So toggle again the item + if(expanded != isExpanded(index)) + setExpanded(index, !isExpanded(index)); + + if(!index.isValid()) + { + clearSelection(); + setCurrentIndex(QModelIndex()); + + if(event->button() == Qt::RightButton) + emit contextMenuEmptyRequested(event->pos()); + return; + } + + if(event->button() == Qt::RightButton) + { + if(model()->rowCount(index) == 0) + { + // An empty group needs to be handle by the panels + emit contextMenuItemRequested(event->pos()); + } + else + { + emit contextMenuGroupRequested(event->pos()); + } + } +} + + +void PanelTreeView::mouseReleaseEvent(QMouseEvent *event) +{ + QTreeView::mouseReleaseEvent(event); + + const QModelIndex index = indexAt(event->pos()); + if(!index.isValid()) + return; + + if(event->button() == Qt::MidButton || event->modifiers() == Qt::ControlModifier) + validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::SettingOpenTab); + + else if(event->button() == Qt::LeftButton) + { + if(model()->rowCount(index) == 0) + validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); + else + setExpanded(index, !isExpanded(index)); + } +} + + +void PanelTreeView::keyPressEvent(QKeyEvent *event) +{ + QTreeView::keyPressEvent(event); + QModelIndex index = currentIndex(); + + if(!index.isValid()) + return; + + if(event->key() == Qt::Key_Return) + { + if(model()->rowCount(index) == 0) + validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); + else + setExpanded(index, !isExpanded(index)); + } + + else if(event->key() == Qt::Key_Delete) + { + emit delKeyPressed(); + } +} + + +void PanelTreeView::validOpenUrl(const KUrl &url, Rekonq::OpenType openType) +{ + // To workaround a crash when the url is about:blank + if(url.url() == "about:blank") + emit openUrl(KUrl("about:home"), openType); + else + emit openUrl(url, openType); +} + + +void PanelTreeView::mouseMoveEvent(QMouseEvent *event) +{ + QTreeView::mouseMoveEvent(event); + const QModelIndex index = indexAt(event->pos()); + if(!index.isValid()) + { + emit itemHovered(""); + return; + } + emit itemHovered(qVariantValue< KUrl >(index.data(Qt::UserRole)).url()); +} + + +void PanelTreeView::openInCurrentTab() +{ + QModelIndex index = currentIndex(); + if(!index.isValid()) + return; + + validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); +} + + +void PanelTreeView::copyToClipboard() +{ + QModelIndex index = currentIndex(); + if(!index.isValid()) + return; + + QClipboard *cb = QApplication::clipboard(); + cb->setText(qVariantValue< KUrl >(index.data(Qt::UserRole)).url()); +} + + +void PanelTreeView::openInNewTab() +{ + QModelIndex index = currentIndex(); + if(!index.isValid()) + return; + + validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::SettingOpenTab); +} + + +void PanelTreeView::openInNewWindow() +{ + QModelIndex index = currentIndex(); + if(!index.isValid()) + return; + + validOpenUrl( qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::NewWindow); +} diff --git a/src/paneltreeview.h b/src/paneltreeview.h new file mode 100644 index 00000000..93d7a33e --- /dev/null +++ b/src/paneltreeview.h @@ -0,0 +1,69 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 by Yoann Laissus +* +* +* 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 . +* +* ============================================================ */ + + +#ifndef PANELTREEVIEW_H +#define PANELTREEVIEW_H + +// Local Includes +#include "application.h" + +// Qt Includes +#include + + +class PanelTreeView : public QTreeView +{ + Q_OBJECT + +public: + PanelTreeView(QWidget *parent = 0); + ~PanelTreeView(); + +signals: + void openUrl(const KUrl &, const Rekonq::OpenType &); + void itemHovered(const QString &); + void delKeyPressed(); + void contextMenuItemRequested(const QPoint &pos); + void contextMenuGroupRequested(const QPoint &pos); + void contextMenuEmptyRequested(const QPoint &pos); + +public slots: + void copyToClipboard(); + void openInCurrentTab(); + void openInNewTab(); + void openInNewWindow(); + +protected: + void mouseReleaseEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void keyPressEvent(QKeyEvent *event); + +private: + void validOpenUrl(const KUrl &url, Rekonq::OpenType openType = Rekonq::CurrentTab); +}; + +#endif // PANELTREEVIEW_H diff --git a/src/urltreeview.cpp b/src/urltreeview.cpp deleted file mode 100644 index aeaef2f7..00000000 --- a/src/urltreeview.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2010 by Yoann Laissus -* -* -* 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 . -* -* ============================================================ */ - - -// Self Includes -#include "urltreeview.h" - -// Local Includes -#include "application.h" - -// Qt Includes -#include -#include - - -UrlTreeView::UrlTreeView(QWidget *parent) - : QTreeView(parent) -{ - connect(this, SIGNAL(itemHovered(const QString &)), parent, SIGNAL(itemHovered(const QString &))); - connect(this, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), parent, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType))); - setMouseTracking(true); - setExpandsOnDoubleClick(false); -} - - -UrlTreeView::~UrlTreeView() -{ -} - - -void UrlTreeView::mousePressEvent(QMouseEvent *event) -{ - const QModelIndex index = indexAt(event->pos()); - bool expanded = isExpanded(index); - - QTreeView::mousePressEvent(event); - - // A change of an item expansion is handle by mouseReleaseEvent() - // So toggle again the item - if(expanded != isExpanded(index)) - setExpanded(index, !isExpanded(index)); - - if(!index.isValid()) - { - clearSelection(); - setCurrentIndex(QModelIndex()); - - if(event->button() == Qt::RightButton) - emit contextMenuEmptyRequested(event->pos()); - return; - } - - if(event->button() == Qt::RightButton) - { - if(model()->rowCount(index) == 0) - { - // An empty group needs to be handle by the panels - emit contextMenuItemRequested(event->pos()); - } - else - { - emit contextMenuGroupRequested(event->pos()); - } - } -} - - -void UrlTreeView::mouseReleaseEvent(QMouseEvent *event) -{ - QTreeView::mouseReleaseEvent(event); - - const QModelIndex index = indexAt(event->pos()); - if(!index.isValid()) - return; - - if(event->button() == Qt::MidButton || event->modifiers() == Qt::ControlModifier) - validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::SettingOpenTab); - - else if(event->button() == Qt::LeftButton) - { - if(model()->rowCount(index) == 0) - validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); - else - setExpanded(index, !isExpanded(index)); - } -} - - -void UrlTreeView::keyPressEvent(QKeyEvent *event) -{ - QTreeView::keyPressEvent(event); - QModelIndex index = currentIndex(); - - if(!index.isValid()) - return; - - if(event->key() == Qt::Key_Return) - { - if(model()->rowCount(index) == 0) - validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); - else - setExpanded(index, !isExpanded(index)); - } - - else if(event->key() == Qt::Key_Delete) - { - emit delKeyPressed(); - } -} - - -void UrlTreeView::validOpenUrl(const KUrl &url, Rekonq::OpenType openType) -{ - // To workaround a crash when the url is about:blank - if(url.url() == "about:blank") - emit openUrl(KUrl("about:home"), openType); - else - emit openUrl(url, openType); -} - - -void UrlTreeView::mouseMoveEvent(QMouseEvent *event) -{ - QTreeView::mouseMoveEvent(event); - const QModelIndex index = indexAt(event->pos()); - if(!index.isValid()) - { - emit itemHovered(""); - return; - } - emit itemHovered(qVariantValue< KUrl >(index.data(Qt::UserRole)).url()); -} - - -void UrlTreeView::openInCurrentTab() -{ - QModelIndex index = currentIndex(); - if(!index.isValid()) - return; - - validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); -} - - -void UrlTreeView::copyToClipboard() -{ - QModelIndex index = currentIndex(); - if(!index.isValid()) - return; - - QClipboard *cb = QApplication::clipboard(); - cb->setText(qVariantValue< KUrl >(index.data(Qt::UserRole)).url()); -} - - -void UrlTreeView::openInNewTab() -{ - QModelIndex index = currentIndex(); - if(!index.isValid()) - return; - - validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::SettingOpenTab); -} - - -void UrlTreeView::openInNewWindow() -{ - QModelIndex index = currentIndex(); - if(!index.isValid()) - return; - - validOpenUrl( qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::NewWindow); -} diff --git a/src/urltreeview.h b/src/urltreeview.h deleted file mode 100644 index cce7a257..00000000 --- a/src/urltreeview.h +++ /dev/null @@ -1,69 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2010 by Yoann Laissus -* -* -* 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 . -* -* ============================================================ */ - - -#ifndef URLTREEVIEW_H -#define URLTREEVIEW_H - -// Local Includes -#include "application.h" - -// Qt Includes -#include - - -class UrlTreeView : public QTreeView -{ - Q_OBJECT - -public: - UrlTreeView(QWidget *parent = 0); - ~UrlTreeView(); - -signals: - void openUrl(const KUrl &, const Rekonq::OpenType &); - void itemHovered(const QString &); - void delKeyPressed(); - void contextMenuItemRequested(const QPoint &pos); - void contextMenuGroupRequested(const QPoint &pos); - void contextMenuEmptyRequested(const QPoint &pos); - -public slots: - void copyToClipboard(); - void openInCurrentTab(); - void openInNewTab(); - void openInNewWindow(); - -protected: - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void keyPressEvent(QKeyEvent *event); - -private: - void validOpenUrl(const KUrl &url, Rekonq::OpenType openType = Rekonq::CurrentTab); -}; - -#endif // URLTREEVIEW_H -- cgit v1.2.1