From fe8b349bcee6426ddc6f33bc221dfc8973b07e33 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 2 Mar 2007 18:59:09 +0000 Subject: 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 --- src/treeviewsidebarpage.cpp | 89 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/treeviewsidebarpage.cpp (limited to 'src/treeviewsidebarpage.cpp') 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" -- cgit v1.3