]> cloud.milkyroute.net Git - dolphin.git/blob - src/treeviewsidebarpage.h
Port dolphin to the KFileItemDelegate API changes.
[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 public slots:
52 /**
53 * Changes the current selection inside the tree to \a url.
54 */
55 virtual void setUrl(const KUrl& url);
56
57 protected:
58 /** @see QWidget::showEvent() */
59 virtual void showEvent(QShowEvent* event);
60
61 /** @see QWidget::contextMenuEvent() */
62 virtual void contextMenuEvent(QContextMenuEvent* event);
63
64 private slots:
65 /**
66 * Updates the active view to the URL
67 * which is given by the item with the index \a index.
68 */
69 void updateActiveView(const QModelIndex& index);
70
71 /**
72 * Is emitted if the URLs \a urls have been dropped
73 * to the index \a index. */
74 void dropUrls(const KUrl::List& urls,
75 const QModelIndex& index);
76
77 /**
78 * Invokes expandToLeafDir() asynchronously (the expanding
79 * may not be done in the context of this slot).
80 */
81 void triggerExpanding(const QModelIndex& index);
82
83 /**
84 * Expands all directories to make m_leafDir visible and
85 * adjusts the selection.
86 */
87 void expandToLeafDir();
88
89 /**
90 * Loads the sub tree to make m_leafDir visible. Is invoked
91 * indirectly by loadTree() after the directory lister has
92 * finished loading the root items.
93 */
94 void loadSubTree();
95
96 /**
97 * Is invoked when the directory lister has started the loading
98 * of the URL \a url and sets the internal m_dirListerCompleted
99 * state to false.
100 */
101 void slotDirListerStarted(const KUrl& url);
102
103 /**
104 * Is invoked when the directory lister has completed the loading
105 * and sets the internal m_dirListerCompleted state to true.
106 */
107 void slotDirListerCompleted();
108
109 private:
110 /**
111 * Initializes the base URL of the tree and expands all
112 * directories until \a url.
113 * @param url URL of the leaf directory that should get expanded.
114 */
115 void loadTree(const KUrl& url);
116
117 private:
118 bool m_dirListerCompleted;
119 KDirLister* m_dirLister;
120 DolphinModel* m_dolphinModel;
121 DolphinSortFilterProxyModel* m_proxyModel;
122 SidebarTreeView* m_treeView;
123 KUrl m_leafDir;
124 };
125
126 #endif // TREEVIEWSIDEBARPAGE_H