File indexing completed on 2024-11-24 05:00:55
0001 /* 0002 This file is part of the KDE project 0003 0004 SPDX-FileCopyrightText: 2007 Tobias Koenig <tokoe@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KFILETREEVIEW_H 0010 #define KFILETREEVIEW_H 0011 0012 #include <QTreeView> 0013 0014 #include <QUrl> 0015 0016 /** 0017 * The file treeview offers a treeview on the filesystem. 0018 */ 0019 class KFileTreeView : public QTreeView // exported only for kfiletreeviewtest 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 /** 0025 * Creates a new file tree view. 0026 */ 0027 explicit KFileTreeView(QWidget *parent = nullptr); 0028 0029 /** 0030 * Destroys the file tree view. 0031 */ 0032 ~KFileTreeView() override; 0033 0034 /** 0035 * Returns the current url. 0036 */ 0037 QUrl currentUrl() const; 0038 0039 /** 0040 * Returns the selected url. 0041 */ 0042 QUrl selectedUrl() const; 0043 0044 /** 0045 * Returns all selected urls. 0046 */ 0047 QList<QUrl> selectedUrls() const; 0048 0049 /** 0050 * Returns the current root url of the view. 0051 */ 0052 QUrl rootUrl() const; 0053 0054 /** 0055 * Returns true if the view is currently showing hidden files 0056 * @since 4.3 0057 */ 0058 bool showHiddenFiles() const; 0059 0060 /** 0061 * @reimplemented 0062 */ 0063 QSize sizeHint() const override; 0064 0065 public Q_SLOTS: 0066 /** 0067 * Sets whether the dir-only mode is @p enabled. 0068 * 0069 * In dir-only mode, only directories and subdirectories 0070 * are listed in the view. 0071 */ 0072 void setDirOnlyMode(bool enabled); 0073 0074 /** 0075 * Sets whether hidden files shall be listed. 0076 */ 0077 void setShowHiddenFiles(bool enabled); 0078 0079 /** 0080 * Sets the current @p url of the view. 0081 */ 0082 void setCurrentUrl(const QUrl &url); 0083 0084 /** 0085 * Sets the root @p url of the view. 0086 * 0087 * The default is file:///. 0088 */ 0089 void setRootUrl(const QUrl &url); 0090 0091 Q_SIGNALS: 0092 /** 0093 * This signal is emitted whenever an @p url has been activated. 0094 */ 0095 void activated(const QUrl &url); 0096 0097 /** 0098 * This signal is emitted whenever the current @p url has been changed. 0099 */ 0100 void currentUrlChanged(const QUrl &url); 0101 0102 protected: 0103 void contextMenuEvent(QContextMenuEvent *) override; 0104 0105 private: 0106 class Private; 0107 Private *const d; 0108 }; 0109 0110 #endif