1 | /* |
2 | This file is part of the KDE project |
3 | |
4 | Copyright (C) 2007 Tobias Koenig <tokoe@kde.org> |
5 | |
6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. |
10 | |
11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. |
20 | */ |
21 | |
22 | #ifndef KFILETREEVIEW_H |
23 | #define KFILETREEVIEW_H |
24 | |
25 | #include <QtGui/QTreeView> |
26 | |
27 | #include <kurl.h> |
28 | |
29 | #include <kfile_export.h> |
30 | |
31 | /** |
32 | * The file treeview offers a treeview on the filesystem. |
33 | */ |
34 | class KFILE_EXPORT KFileTreeView : public QTreeView // KDE5: remove KFILE_EXPORT? Seems internal only. |
35 | { |
36 | Q_OBJECT |
37 | |
38 | public: |
39 | /** |
40 | * Creates a new file tree view. |
41 | */ |
42 | KFileTreeView(QWidget *parent = 0); |
43 | |
44 | /** |
45 | * Destroys the file tree view. |
46 | */ |
47 | ~KFileTreeView(); |
48 | |
49 | /** |
50 | * Returns the current url. |
51 | */ |
52 | KUrl currentUrl() const; |
53 | |
54 | /** |
55 | * Returns the selected url. |
56 | */ |
57 | KUrl selectedUrl() const; |
58 | |
59 | /** |
60 | * Returns all selected urls. |
61 | */ |
62 | KUrl::List selectedUrls() const; |
63 | |
64 | /** |
65 | * Returns the current root url of the view. |
66 | */ |
67 | KUrl rootUrl() const; |
68 | |
69 | /** |
70 | * Returns true if the view is currently showing hidden files |
71 | * @since 4.3 |
72 | */ |
73 | bool showHiddenFiles() const; |
74 | |
75 | /** |
76 | * @reimplemented |
77 | */ |
78 | QSize sizeHint() const; |
79 | |
80 | public Q_SLOTS: |
81 | /** |
82 | * Sets whether the dir-only mode is @p enabled. |
83 | * |
84 | * In dir-only mode, only directories and subdirectories |
85 | * are listed in the view. |
86 | */ |
87 | void setDirOnlyMode(bool enabled); |
88 | |
89 | /** |
90 | * Sets whether hidden files shall be listed. |
91 | */ |
92 | void setShowHiddenFiles(bool enabled); |
93 | |
94 | /** |
95 | * Sets the current @p url of the view. |
96 | */ |
97 | void setCurrentUrl(const KUrl &url); |
98 | |
99 | /** |
100 | * Sets the root @p url of the view. |
101 | * |
102 | * The default is file:///. |
103 | */ |
104 | void setRootUrl(const KUrl &url); |
105 | |
106 | Q_SIGNALS: |
107 | /** |
108 | * This signal is emitted whenever an @p url has been activated. |
109 | */ |
110 | void activated(const KUrl &url); |
111 | |
112 | /** |
113 | * This signal is emitted whenever the current @p url has been changed. |
114 | */ |
115 | void currentChanged(const KUrl &url); |
116 | |
117 | protected: |
118 | virtual void ( QContextMenuEvent* ); |
119 | |
120 | private: |
121 | class Private; |
122 | Private* const d; |
123 | |
124 | Q_PRIVATE_SLOT(d, void _k_activated(const QModelIndex&)) |
125 | Q_PRIVATE_SLOT(d, void _k_currentChanged(const QModelIndex&, const QModelIndex&)) |
126 | Q_PRIVATE_SLOT(d, void _k_expanded(const QModelIndex&)) |
127 | }; |
128 | |
129 | #endif |
130 | |