]> cloud.milkyroute.net Git - dolphin.git/blob - src/treeviewsidebarpage.h
Create a SidebarTreeView which will include support for drag & drop in later releases...
[dolphin.git] / src / treeviewsidebarpage.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef TREEVIEWSIDEBARPAGE_H
21 #define TREEVIEWSIDEBARPAGE_H
22
23 #include <kurl.h>
24 #include <sidebarpage.h>
25
26 class KDirLister;
27 class KDirModel;
28 class KUrl;
29
30 class DolphinSortFilterProxyModel;
31 class SidebarTreeView;
32 class QModelIndex;
33
34 /**
35 * @brief Shows a tree view of the directories starting from
36 * the currently selected bookmark.
37 *
38 * The tree view is always synchronized with the currently active view
39 * from the main window.
40 */
41 class TreeViewSidebarPage : public SidebarPage
42 {
43 Q_OBJECT
44
45 public:
46 TreeViewSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent = 0);
47 virtual ~TreeViewSidebarPage();
48
49 protected:
50 /** @see SidebarPage::activeViewChanged() */
51 virtual void activeViewChanged();
52
53 /** @see QWidget::showEvent() */
54 virtual void showEvent(QShowEvent* event);
55
56 private slots:
57 /**
58 * Updates the current selection inside the tree to
59 * \a url.
60 */
61 void updateSelection(const KUrl& url);
62
63 /**
64 * Expands the tree in a way that the item with the URL m_selectedUrl
65 * gets visible. Is called by TreeViewSidebarPage::updateSelection()
66 * if the dir lister has been completed.
67 */
68 void expandSelectionParent();
69
70 /**
71 * Updates the active view to the URL
72 * which is given by the item with the index \a index.
73 */
74 void updateActiveView(const QModelIndex& index);
75
76 private:
77 /**
78 * Connects to signals from the currently active Dolphin view to get
79 * informed about highlighting changes.
80 */
81 void connectToActiveView();
82
83 private:
84 KDirLister* m_dirLister;
85 KDirModel* m_dirModel;
86 DolphinSortFilterProxyModel* m_proxyModel;
87 SidebarTreeView* m_treeView;
88 KUrl m_selectedUrl;
89 };
90
91 #endif // BOOKMARKSSIDEBARPAGE_H