File indexing completed on 2024-04-28 17:06:20
0001 /* 0002 SPDX-FileCopyrightText: 2010 Jan Lepper <dehtris@yahoo.de> 0003 SPDX-FileCopyrightText: 2010-2022 Krusader Krew <https://krusader.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KRFILETREEVIEW_H 0009 #define KRFILETREEVIEW_H 0010 0011 #include <QList> 0012 #include <QModelIndex> 0013 #include <QTreeView> 0014 #include <QUrl> 0015 #include <QWidget> 0016 0017 #include <KConfigCore/KSharedConfig> 0018 #include <KIOFileWidgets/KDirSortFilterProxyModel> 0019 #include <KIOFileWidgets/KFilePlacesModel> 0020 #include <KIOWidgets/KDirModel> 0021 0022 /** 0023 * Show folders in a tree view. 0024 * 0025 * A context menu with settings is accessible through the header. 0026 * 0027 * Supports dragging from this view and dropping files on it. 0028 */ 0029 class KrFileTreeView : public QTreeView 0030 { 0031 friend class KrDirModel; 0032 Q_OBJECT 0033 0034 public: 0035 explicit KrFileTreeView(QWidget *parent = nullptr); 0036 ~KrFileTreeView() override = default; 0037 0038 void setCurrentUrl(const QUrl &url); 0039 0040 void saveSettings(KConfigGroup cfg) const; 0041 void restoreSettings(const KConfigGroup &cfg); 0042 0043 signals: 0044 void urlActivated(const QUrl &url); 0045 0046 private slots: 0047 void slotActivated(const QModelIndex &index); 0048 void slotExpanded(const QModelIndex &); 0049 void showHeaderContextMenu(); 0050 void slotCustomContextMenuRequested(const QPoint &point); 0051 0052 protected: 0053 void dropEvent(QDropEvent *event) override; 0054 0055 private: 0056 QUrl urlForProxyIndex(const QModelIndex &index) const; 0057 void dropMimeData(const QList<QUrl> &lst, const QUrl &url) const; 0058 void copyToClipBoard(const KFileItem &fileItem, bool cut) const; 0059 void deleteFile(const KFileItem &fileItem, bool moveToTrash = true) const; 0060 bool briefMode() const; 0061 void setBriefMode(bool brief); // show only column with directory names 0062 void setTree(bool startFromCurrent, bool startFromPlace); 0063 void setTreeRoot(const QUrl &rootBase); 0064 bool isVisible(const QUrl &url); 0065 0066 KDirModel *mSourceModel; 0067 KDirSortFilterProxyModel *mProxyModel; 0068 KFilePlacesModel *mFilePlacesModel; 0069 QUrl mCurrentUrl; 0070 QUrl mCurrentTreeBase; 0071 0072 bool mStartTreeFromCurrent; // NAND... 0073 bool mStartTreeFromPlace; 0074 }; 0075 0076 #endif // KRFILETREEVIEW_H