File indexing completed on 2024-04-28 05:45:12
0001 /* 0002 * SPDX-FileCopyrightText: 2006 Peter Penz <peter.penz19@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef FOLDERSPANEL_H 0008 #define FOLDERSPANEL_H 0009 0010 #include "panels/panel.h" 0011 0012 #include <QUrl> 0013 0014 class KFileItemModel; 0015 class KItemListController; 0016 class QGraphicsSceneDragDropEvent; 0017 class KFileItem; 0018 /** 0019 * @brief Shows a tree view of the directories starting from 0020 * the currently selected place. 0021 * 0022 * The tree view is always synchronized with the currently active view 0023 * from the main window. 0024 */ 0025 class FoldersPanel : public Panel 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 explicit FoldersPanel(QWidget *parent = nullptr); 0031 ~FoldersPanel() override; 0032 0033 void setShowHiddenFiles(bool show); 0034 void setLimitFoldersPanelToHome(bool enable); 0035 bool showHiddenFiles() const; 0036 bool limitFoldersPanelToHome() const; 0037 0038 void setAutoScrolling(bool enable); 0039 bool autoScrolling() const; 0040 0041 void rename(const KFileItem &item); 0042 0043 Q_SIGNALS: 0044 void folderActivated(const QUrl &url); 0045 void folderInNewTab(const QUrl &url); 0046 void folderInNewActiveTab(const QUrl &url); 0047 void errorMessage(const QString &error); 0048 0049 protected: 0050 /** @see Panel::urlChanged() */ 0051 bool urlChanged() override; 0052 0053 /** @see QWidget::showEvent() */ 0054 void showEvent(QShowEvent *event) override; 0055 0056 /** @see QWidget::keyPressEvent() */ 0057 void keyPressEvent(QKeyEvent *event) override; 0058 0059 private Q_SLOTS: 0060 void slotItemActivated(int index); 0061 void slotItemMiddleClicked(int index); 0062 void slotItemContextMenuRequested(int index, const QPointF &pos); 0063 void slotViewContextMenuRequested(const QPointF &pos); 0064 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent *event); 0065 void slotRoleEditingFinished(int index, const QByteArray &role, const QVariant &value); 0066 0067 void slotLoadingCompleted(); 0068 0069 /** 0070 * Increases the opacity of the view step by step until it is fully 0071 * opaque. 0072 */ 0073 void startFadeInAnimation(); 0074 0075 private: 0076 /** 0077 * Indicate if it is allowed to leave current location. 0078 */ 0079 enum NavigationBehaviour { 0080 StayWhereYouAre, ///< Don't leave current location. 0081 AllowJumpHome ///< Go Home only when context menu option got checked. 0082 }; 0083 /** 0084 * Initializes the base URL of the tree and expands all 0085 * directories until \a url. 0086 * @param url URL of the leaf directory that should get expanded. 0087 * @param navigationBehaviour Navigation behaviour \see NavigationBehaviour 0088 */ 0089 void loadTree(const QUrl &url, NavigationBehaviour navigationBehaviour = StayWhereYouAre); 0090 0091 void reloadTree(); 0092 0093 /** 0094 * Sets the item with the index \a index as current item, selects 0095 * the item and assures that the item will be visible. 0096 */ 0097 void updateCurrentItem(int index); 0098 0099 private: 0100 bool m_updateCurrentItem; 0101 KItemListController *m_controller; 0102 KFileItemModel *m_model; 0103 }; 0104 0105 #endif // FOLDERSPANEL_H