]> cloud.milkyroute.net Git - dolphin.git/blob - src/treeviewsidebarpage.h
consider the protocol and directory capabilities for file actions like Rename, Delete...
[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 DolphinModel;
28
29 class DolphinSortFilterProxyModel;
30 class SidebarTreeView;
31 class QModelIndex;
32
33 /**
34 * @brief Shows a tree view of the directories starting from
35 * the currently selected place.
36 *
37 * The tree view is always synchronized with the currently active view
38 * from the main window.
39 */
40 class TreeViewSidebarPage : public SidebarPage
41 {
42 Q_OBJECT
43
44 public:
45 TreeViewSidebarPage(QWidget* parent = 0);
46 virtual ~TreeViewSidebarPage();
47
48 /** @see QWidget::sizeHint() */
49 virtual QSize sizeHint() const;
50
51 void setShowHiddenFiles(bool show);
52 bool showHiddenFiles() const;
53
54 public slots:
55 /**
56 * Changes the current selection inside the tree to \a url.
57 */
58 virtual void setUrl(const KUrl& url);
59
60 protected:
61 /** @see QWidget::showEvent() */
62 virtual void showEvent(QShowEvent* event);
63
64 /** @see QWidget::contextMenuEvent() */
65 virtual void contextMenuEvent(QContextMenuEvent* event);
66
67 private slots:
68 /**
69 * Updates the active view to the URL
70 * which is given by the item with the index \a index.
71 */
72 void updateActiveView(const QModelIndex& index);
73
74 /**
75 * Is emitted if the URLs \a urls have been dropped
76 * to the index \a index. */
77 void dropUrls(const KUrl::List& urls,
78 const QModelIndex& index);
79
80 /**
81 * Invokes expandToLeafDir() asynchronously (the expanding
82 * may not be done in the context of this slot).
83 */
84 void triggerExpanding();
85
86 /**
87 * Invokes loadSubTree() asynchronously (the loading
88 * may not be done in the context of this slot).
89 */
90 void triggerLoadSubTree();
91
92 /**
93 * Expands all directories to make m_leafDir visible and
94 * adjusts the selection.
95 */
96 void expandToLeafDir();
97
98 /**
99 * Loads the sub tree to make m_leafDir visible. Is invoked
100 * indirectly by loadTree() after the directory lister has
101 * finished loading the root items.
102 */
103 void loadSubTree();
104
105 /**
106 * Assures that the leaf folder gets visible.
107 */
108 void scrollToLeaf();
109
110 private:
111 /**
112 * Initializes the base URL of the tree and expands all
113 * directories until \a url.
114 * @param url URL of the leaf directory that should get expanded.
115 */
116 void loadTree(const KUrl& url);
117
118 /**
119 * Selects the current leaf directory m_leafDir and assures
120 * that the directory is visible if the leaf has been set by
121 * TreeViewSidebarPage::setUrl().
122 */
123 void selectLeafDirectory();
124
125 private:
126 bool m_setLeafVisible;
127 int m_horizontalPos;
128 KDirLister* m_dirLister;
129 DolphinModel* m_dolphinModel;
130 DolphinSortFilterProxyModel* m_proxyModel;
131 SidebarTreeView* m_treeView;
132 KUrl m_leafDir;
133 };
134
135 #endif // TREEVIEWSIDEBARPAGE_H