]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/folders/folderspanel.h
Initial draft for bringing back the "Folders" panel
[dolphin.git] / src / panels / folders / folderspanel.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
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 KFileItemModel;
28 class KItemListController;
29
30 /**
31 * @brief Shows a tree view of the directories starting from
32 * the currently selected place.
33 *
34 * The tree view is always synchronized with the currently active view
35 * from the main window.
36 */
37 class FoldersPanel : public Panel
38 {
39 Q_OBJECT
40
41 public:
42 FoldersPanel(QWidget* parent = 0);
43 virtual ~FoldersPanel();
44
45 void setHiddenFilesShown(bool show);
46 bool hiddenFilesShown() const;
47
48 void setAutoScrolling(bool enable);
49 bool autoScrolling() const;
50
51 void rename(const KFileItem& item);
52
53 signals:
54 /**
55 * Is emitted if the an URL change is requested.
56 */
57 void changeUrl(const KUrl& url, Qt::MouseButtons buttons);
58
59 protected:
60 /** @see Panel::urlChanged() */
61 virtual bool urlChanged();
62
63 /** @see QWidget::showEvent() */
64 virtual void showEvent(QShowEvent* event);
65
66 /** @see QWidget::contextMenuEvent() */
67 virtual void contextMenuEvent(QContextMenuEvent* event);
68
69 /** @see QWidget::keyPressEvent() */
70 virtual void keyPressEvent(QKeyEvent* event);
71
72 private slots:
73 /**
74 * Updates the active view to the URL
75 * which is given by the item with the index \a index.
76 */
77 //void updateActiveView(const QModelIndex& index);
78
79 /**
80 * Is emitted if URLs have been dropped
81 * to the index \a index.
82 */
83 //void dropUrls(const QModelIndex& index, QDropEvent* event);
84
85 /**
86 * Expands the treeview to show the directory
87 * specified by \a index.
88 */
89 //void expandToDir(const QModelIndex& index);
90
91 /**
92 * Assures that the leaf folder gets visible.
93 */
94 //void scrollToLeaf();
95
96 void updateMouseButtons();
97
98 void slotLoadingCompleted();
99
100 void slotHorizontalScrollBarMoved(int value);
101
102 void slotVerticalScrollBarMoved(int value);
103
104 private:
105 /**
106 * Initializes the base URL of the tree and expands all
107 * directories until \a url.
108 * @param url URL of the leaf directory that should get expanded.
109 */
110 void loadTree(const KUrl& url);
111
112 /**
113 * Selects the current leaf directory m_leafDir and assures
114 * that the directory is visible if the leaf has been set by
115 * FoldersPanel::setUrl().
116 */
117 void selectLeafDirectory();
118
119 KFileItemModel* fileItemModel() const;
120
121 private:
122 bool m_setLeafVisible;
123 Qt::MouseButtons m_mouseButtons;
124 KDirLister* m_dirLister;
125 KItemListController* m_controller;
126 KUrl m_leafDir;
127 };
128
129 #endif // FOLDERSPANEL_H