]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/folders/folderspanel.h
Merge branch 'release/21.12'
[dolphin.git] / src / panels / folders / folderspanel.h
1 /*
2 * SPDX-FileCopyrightText: 2006 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef FOLDERSPANEL_H
8 #define FOLDERSPANEL_H
9
10 #include "panels/panel.h"
11
12 #include <QUrl>
13
14 class KFileItemModel;
15 class KItemListController;
16 class QGraphicsSceneDragDropEvent;
17 class KFileItem;
18 /**
19 * @brief Shows a tree view of the directories starting from
20 * the currently selected place.
21 *
22 * The tree view is always synchronized with the currently active view
23 * from the main window.
24 */
25 class FoldersPanel : public Panel
26 {
27 Q_OBJECT
28
29 public:
30 explicit FoldersPanel(QWidget* parent = nullptr);
31 ~FoldersPanel() override;
32
33 void setShowHiddenFiles(bool show);
34 void setLimitFoldersPanelToHome(bool enable);
35 bool showHiddenFiles() const;
36 bool limitFoldersPanelToHome() const;
37
38 void setAutoScrolling(bool enable);
39 bool autoScrolling() const;
40
41 void rename(const KFileItem& item);
42
43 Q_SIGNALS:
44 void folderActivated(const QUrl& url);
45 void folderInNewTab(const QUrl &url);
46 void folderInNewActiveTab(const QUrl &url);
47 void errorMessage(const QString& error);
48
49 protected:
50 /** @see Panel::urlChanged() */
51 bool urlChanged() override;
52
53 /** @see QWidget::showEvent() */
54 void showEvent(QShowEvent* event) override;
55
56 /** @see QWidget::keyPressEvent() */
57 void keyPressEvent(QKeyEvent* event) override;
58
59 private Q_SLOTS:
60 void slotItemActivated(int index);
61 void slotItemMiddleClicked(int index);
62 void slotItemContextMenuRequested(int index, const QPointF& pos);
63 void slotViewContextMenuRequested(const QPointF& pos);
64 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
65 void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
66
67 void slotLoadingCompleted();
68
69 /**
70 * Increases the opacity of the view step by step until it is fully
71 * opaque.
72 */
73 void startFadeInAnimation();
74
75
76 private:
77 /**
78 * Indicate if it is allowed to leave current location.
79 */
80 enum NavigationBehaviour {
81 StayWhereYouAre, ///< Don't leave current location.
82 AllowJumpHome ///< Go Home only when context menu option got checked.
83 };
84 /**
85 * Initializes the base URL of the tree and expands all
86 * directories until \a url.
87 * @param url URL of the leaf directory that should get expanded.
88 * @param navigationBehaviour Navigation behaviour \see NavigationBehaviour
89 */
90 void loadTree(const QUrl& url, NavigationBehaviour navigationBehaviour = StayWhereYouAre);
91
92 void reloadTree();
93
94 /**
95 * Sets the item with the index \a index as current item, selects
96 * the item and assures that the item will be visible.
97 */
98 void updateCurrentItem(int index);
99
100 private:
101 bool m_updateCurrentItem;
102 KItemListController* m_controller;
103 KFileItemModel* m_model;
104 };
105
106 #endif // FOLDERSPANEL_H