File indexing completed on 2024-05-05 16:08:27

0001 /*
0002    This file is part of the KDE project
0003 
0004    Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019    Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef KFILETREEVIEW_H
0023 #define KFILETREEVIEW_H
0024 
0025 #include <QTreeView>
0026 
0027 #include <QUrl>
0028 
0029 #include <kdelibs4support_export.h>
0030 
0031 /**
0032  * The file treeview offers a treeview on the filesystem.
0033  */
0034 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KFileTreeView : public QTreeView // exported only for kfiletreeviewtest
0035 {
0036     Q_OBJECT
0037 
0038 public:
0039     /**
0040      * Creates a new file tree view.
0041      */
0042     KFileTreeView(QWidget *parent = nullptr);
0043 
0044     /**
0045      * Destroys the file tree view.
0046      */
0047     ~KFileTreeView() override;
0048 
0049     /**
0050      * Returns the current url.
0051      */
0052     QUrl currentUrl() const;
0053 
0054     /**
0055      * Returns the selected url.
0056      */
0057     QUrl selectedUrl() const;
0058 
0059     /**
0060      * Returns all selected urls.
0061      */
0062     QList<QUrl> selectedUrls() const;
0063 
0064     /**
0065      * Returns the current root url of the view.
0066      */
0067     QUrl rootUrl() const;
0068 
0069     /**
0070      * Returns true if the view is currently showing hidden files
0071      * @since 4.3
0072      */
0073     bool showHiddenFiles() const;
0074 
0075     /**
0076      * @reimplemented
0077      */
0078     QSize sizeHint() const override;
0079 
0080 public Q_SLOTS:
0081     /**
0082      * Sets whether the dir-only mode is @p enabled.
0083      *
0084      * In dir-only mode, only directories and subdirectories
0085      * are listed in the view.
0086      */
0087     void setDirOnlyMode(bool enabled);
0088 
0089     /**
0090      * Sets whether hidden files shall be listed.
0091      */
0092     void setShowHiddenFiles(bool enabled);
0093 
0094     /**
0095      * Sets the current @p url of the view.
0096      */
0097     void setCurrentUrl(const QUrl &url);
0098 
0099     /**
0100      * Sets the root @p url of the view.
0101      *
0102      * The default is file:///.
0103      */
0104     void setRootUrl(const QUrl &url);
0105 
0106 Q_SIGNALS:
0107     /**
0108      * This signal is emitted whenever an @p url has been activated.
0109      */
0110     void activated(const QUrl &url);
0111 
0112     /**
0113      * This signal is emitted whenever the current @p url has been changed.
0114      */
0115     void currentChanged(const QUrl &url);
0116 
0117 protected:
0118     using QTreeView::currentChanged;
0119     void contextMenuEvent(QContextMenuEvent *) override;
0120 
0121 private:
0122     class Private;
0123     Private *const d;
0124 
0125     Q_PRIVATE_SLOT(d, void _k_activated(const QModelIndex &))
0126     Q_PRIVATE_SLOT(d, void _k_currentChanged(const QModelIndex &, const QModelIndex &))
0127     Q_PRIVATE_SLOT(d, void _k_expanded(const QModelIndex &))
0128 };
0129 
0130 #endif