]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/folders/folderspanel.h
Use capitalized KDE includes
[dolphin.git] / src / panels / folders / folderspanel.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 FOLDERSPANEL_H
21 #define FOLDERSPANEL_H
22
23 #include <KUrl>
24 #include <panels/panel.h>
25
26 class KDirLister;
27 class DolphinModel;
28
29 class DolphinSortFilterProxyModel;
30 class PanelTreeView;
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 FoldersPanel : public Panel
41 {
42 Q_OBJECT
43
44 public:
45 FoldersPanel(QWidget* parent = 0);
46 virtual ~FoldersPanel();
47
48 void setShowHiddenFiles(bool show);
49 bool showHiddenFiles() const;
50
51 void setAutoScrolling(bool enable);
52 bool autoScrolling() const;
53
54 void rename(const KFileItem& item);
55
56 signals:
57 /**
58 * Is emitted if the an URL change is requested.
59 */
60 void changeUrl(const KUrl& url, Qt::MouseButtons buttons);
61
62 protected:
63 /** @see Panel::urlChanged() */
64 virtual bool urlChanged();
65
66 /** @see QWidget::showEvent() */
67 virtual void showEvent(QShowEvent* event);
68
69 /** @see QWidget::contextMenuEvent() */
70 virtual void contextMenuEvent(QContextMenuEvent* event);
71
72 /** @see QWidget::keyPressEvent() */
73 virtual void keyPressEvent(QKeyEvent* event);
74
75 private slots:
76 /**
77 * Updates the active view to the URL
78 * which is given by the item with the index \a index.
79 */
80 void updateActiveView(const QModelIndex& index);
81
82 /**
83 * Is emitted if URLs have been dropped
84 * to the index \a index.
85 */
86 void dropUrls(const QModelIndex& index, QDropEvent* event);
87
88 /**
89 * Expands the treeview to show the directory
90 * specified by \a index.
91 */
92 void expandToDir(const QModelIndex& index);
93
94 /**
95 * Assures that the leaf folder gets visible.
96 */
97 void scrollToLeaf();
98
99 void updateMouseButtons();
100
101 void slotDirListerCompleted();
102
103 void slotHorizontalScrollBarMoved(int value);
104
105 void slotVerticalScrollBarMoved(int value);
106
107 private:
108 /**
109 * Initializes the base URL of the tree and expands all
110 * directories until \a url.
111 * @param url URL of the leaf directory that should get expanded.
112 */
113 void loadTree(const KUrl& url);
114
115 /**
116 * Selects the current leaf directory m_leafDir and assures
117 * that the directory is visible if the leaf has been set by
118 * FoldersPanel::setUrl().
119 */
120 void selectLeafDirectory();
121
122 private:
123 bool m_setLeafVisible;
124 Qt::MouseButtons m_mouseButtons;
125 KDirLister* m_dirLister;
126 DolphinModel* m_dolphinModel;
127 DolphinSortFilterProxyModel* m_proxyModel;
128 PanelTreeView* m_treeView;
129 KUrl m_leafDir;
130 };
131
132 #endif // FOLDERSPANEL_H