From: Peter Penz Date: Fri, 2 Mar 2007 18:59:09 +0000 (+0000) Subject: It seems some people cannot live without a tree view ;-) So Dolphin will provide... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/fe8b349bcee6426ddc6f33bc221dfc8973b07e33 It seems some people cannot live without a tree view ;-) So Dolphin will provide a dock which contains the directory hierarchy, which will be synchronized with the active view. It does not clutter the UI (the dock can be turned off), but makes happy a lot of users -> kind of win-win-situation. This commit provides only a rough initial version, which shows the current URL as tree. I'll work on the interaction during the next week(s)... svn path=/trunk/KDE/kdebase/apps/; revision=638628 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ed9374e8..6c53dca95 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,6 +40,7 @@ set(dolphin_SRCS sidebarpage.cpp statusbarspaceinfo.cpp statusbarmessagelabel.cpp + treeviewsidebarpage.cpp urlbutton.cpp urlnavigator.cpp urlnavigatorbutton.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 72b6703d8..f7b7246b4 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -24,21 +24,21 @@ #include +#include "bookmarkssidebarpage.h" #include "dolphinapplication.h" #include "dolphinnewmenu.h" #include "dolphinsettings.h" #include "dolphinsettingsdialog.h" #include "dolphinstatusbar.h" -#include "dolphinapplication.h" -#include "urlnavigator.h" -#include "dolphinsettings.h" -#include "bookmarkssidebarpage.h" #include "infosidebarpage.h" -#include "dolphin_generalsettings.h" -#include "viewpropertiesdialog.h" -#include "viewproperties.h" #include "metadataloader.h" #include "mainwindowadaptor.h" +#include "treeviewsidebarpage.h" +#include "urlnavigator.h" +#include "viewpropertiesdialog.h" +#include "viewproperties.h" + +#include "dolphin_generalsettings.h" #include #include @@ -1191,6 +1191,10 @@ void DolphinMainWindow::setupActions() void DolphinMainWindow::setupDockWidgets() { + // TODO: there's a lot copy/paste code here. Provide a generic approach + // after the dock concept has been finalized. + + // setup "Bookmarks" QDockWidget* shortcutsDock = new QDockWidget(i18n("Bookmarks")); shortcutsDock->setObjectName("bookmarksDock"); shortcutsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); @@ -1201,6 +1205,7 @@ void DolphinMainWindow::setupDockWidgets() addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock); + // setup "Information" QDockWidget* infoDock = new QDockWidget(i18n("Information")); infoDock->setObjectName("infoDock"); infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); @@ -1210,6 +1215,17 @@ void DolphinMainWindow::setupDockWidgets() actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction()); addDockWidget(Qt::RightDockWidgetArea, infoDock); + + // setup "Tree View" + QDockWidget* treeViewDock = new QDockWidget(i18n("Folders")); // TODO: naming? + treeViewDock->setObjectName("treeViewDock"); + treeViewDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + treeViewDock->setWidget(new TreeViewSidebarPage(this)); + + treeViewDock->toggleViewAction()->setText(i18n("Show Folders Panel")); + actionCollection()->addAction("show_folders_panel", treeViewDock->toggleViewAction()); + + addDockWidget(Qt::LeftDockWidgetArea, treeViewDock); } void DolphinMainWindow::updateHistory() diff --git a/src/dolphinui.rc b/src/dolphinui.rc index 601c9f859..d20cdcf1d 100644 --- a/src/dolphinui.rc +++ b/src/dolphinui.rc @@ -43,6 +43,7 @@ Panels + Navigation Bar diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h index 5509ed1f4..e60d4c3d3 100644 --- a/src/infosidebarpage.h +++ b/src/infosidebarpage.h @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#ifndef _INFOSIDEBARPAGE_H_ -#define _INFOSIDEBARPAGE_H_ +#ifndef INFOSIDEBARPAGE_H +#define INFOSIDEBARPAGE_H #include @@ -60,7 +60,7 @@ class InfoSidebarPage : public SidebarPage Q_OBJECT public: - explicit InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent=0); + explicit InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent = 0); virtual ~InfoSidebarPage(); protected: @@ -161,12 +161,12 @@ private: * Show the annotation of a file in the sidebar. */ void showAnnotation(const KUrl& file); - + /** * Show the annotations of multiple files in the sidebar. */ void showAnnotations(const KUrl::List& files); - + bool m_multipleSelection; bool m_pendingPreview; QTimer* m_timer; @@ -218,4 +218,4 @@ private: int m_index; }; -#endif // _INFOSIDEBARPAGE_H_ +#endif // INFOSIDEBARPAGE_H diff --git a/src/sidebarpage.cpp b/src/sidebarpage.cpp index 25b528f55..ce3b8cc34 100644 --- a/src/sidebarpage.cpp +++ b/src/sidebarpage.cpp @@ -20,7 +20,7 @@ #include "sidebarpage.h" #include "dolphinmainwindow.h" -SidebarPage::SidebarPage(DolphinMainWindow *mainWindow, QWidget* parent) : +SidebarPage::SidebarPage(DolphinMainWindow* mainWindow, QWidget* parent) : QWidget(parent), m_mainWindow(mainWindow) { diff --git a/src/sidebarpage.h b/src/sidebarpage.h index b1e758824..0399796b7 100644 --- a/src/sidebarpage.h +++ b/src/sidebarpage.h @@ -42,7 +42,7 @@ public: protected slots: /** * Is invoked whenever the active view from Dolphin has been changed. - * The active view can be retrieved by Dolphin::mainWin().activeView(); + * The active view can be retrieved by mainWindow()->activeView(); */ virtual void activeViewChanged(); diff --git a/src/treeviewsidebarpage.cpp b/src/treeviewsidebarpage.cpp new file mode 100644 index 000000000..f57146684 --- /dev/null +++ b/src/treeviewsidebarpage.cpp @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz * + * * + * 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) any later version. * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "treeviewsidebarpage.h" + +#include "dolphinmainwindow.h" +#include "dolphinview.h" + +#include "kdirlister.h" +#include "kdirmodel.h" + +#include +#include + +TreeViewSidebarPage::TreeViewSidebarPage(DolphinMainWindow* mainWindow, + QWidget* parent) : + SidebarPage(mainWindow, parent), + m_dirLister(0), + m_dirModel(0), + m_treeView(0) +{ + Q_ASSERT(mainWindow != 0); + + m_dirLister = new KDirLister(); + m_dirLister->setDirOnlyMode(true); + m_dirLister->setAutoUpdate(true); + m_dirLister->setMainWindow(this); + m_dirLister->setDelayedMimeTypes(true); + m_dirLister->setAutoErrorHandlingEnabled(false, this); + + m_dirModel = new KDirModel(); + m_dirModel->setDirLister(m_dirLister); + + m_treeView = new QTreeView(this); + m_treeView->setModel(m_dirModel); + + // hide all columns except of the 'Name' column + m_treeView->hideColumn(KDirModel::Size); + m_treeView->hideColumn(KDirModel::ModifiedTime); + m_treeView->hideColumn(KDirModel::Permissions); + m_treeView->hideColumn(KDirModel::Owner); + m_treeView->hideColumn(KDirModel::Group); + + QVBoxLayout* layout = new QVBoxLayout(this); + layout->addWidget(m_treeView); + + connectToActiveView(); +} + +TreeViewSidebarPage::~TreeViewSidebarPage() +{ + delete m_dirLister; + m_dirLister = 0; +} + +void TreeViewSidebarPage::activeViewChanged() +{ + connectToActiveView(); +} + +void TreeViewSidebarPage::updatePosition(const KUrl& url) +{ +} + +void TreeViewSidebarPage::connectToActiveView() +{ + DolphinView* view = mainWindow()->activeView(); + m_dirLister->openUrl(view->url(), true); + connect(view, SIGNAL(urlChanged(const KUrl&)), + this, SLOT(updatePosition(const KUrl&))); +} + +#include "treeviewsidebarpage.moc" diff --git a/src/treeviewsidebarpage.h b/src/treeviewsidebarpage.h new file mode 100644 index 000000000..1761d8c2b --- /dev/null +++ b/src/treeviewsidebarpage.h @@ -0,0 +1,65 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz + * * + * 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) any later version. * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#ifndef TREEVIEWSIDEBARPAGE_H +#define TREEVIEWSIDEBARPAGE_H + +#include + +class KDirLister; +class KDirModel; +class KUrl; +class QTreeView; + +/** + * @brief + */ +class TreeViewSidebarPage : public SidebarPage +{ + Q_OBJECT + +public: + TreeViewSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent = 0); + virtual ~TreeViewSidebarPage(); + +protected: + /** @see SidebarPage::activeViewChanged() */ + virtual void activeViewChanged(); + +private slots: + /** + * Updates the current position inside the tree to + * \a url. + */ + void updatePosition(const KUrl& url); + +private: + /** + * Connects to signals from the currently active Dolphin view to get + * informed about highlighting changes. + */ + void connectToActiveView(); + +private: + KDirLister* m_dirLister; + KDirModel* m_dirModel; + QTreeView* m_treeView; +}; + +#endif // BOOKMARKSSIDEBARPAGE_H