]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/folders/folderspanel.h
Build with QT_NO_KEYWORDS
[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 folderMiddleClicked(const QUrl& url);
46 void errorMessage(const QString& error);
47
48 protected:
49 /** @see Panel::urlChanged() */
50 bool urlChanged() override;
51
52 /** @see QWidget::showEvent() */
53 void showEvent(QShowEvent* event) override;
54
55 /** @see QWidget::keyPressEvent() */
56 void keyPressEvent(QKeyEvent* event) override;
57
58 private Q_SLOTS:
59 void slotItemActivated(int index);
60 void slotItemMiddleClicked(int index);
61 void slotItemContextMenuRequested(int index, const QPointF& pos);
62 void slotViewContextMenuRequested(const QPointF& pos);
63 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
64 void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
65
66 void slotLoadingCompleted();
67
68 /**
69 * Increases the opacity of the view step by step until it is fully
70 * opaque.
71 */
72 void startFadeInAnimation();
73
74
75 private:
76 /**
77 * Indicate if it is allowed to leave current location.
78 */
79 enum NavigationBehaviour {
80 StayWhereYouAre, ///< Don't leave current location.
81 AllowJumpHome ///< Go Home only when context menu option got checked.
82 };
83 /**
84 * Initializes the base URL of the tree and expands all
85 * directories until \a url.
86 * @param url URL of the leaf directory that should get expanded.
87 * @param navigationBehaviour Navigation behaviour \see NavigationBehaviour
88 */
89 void loadTree(const QUrl& url, NavigationBehaviour navigationBehaviour = StayWhereYouAre);
90
91 void reloadTree();
92
93 /**
94 * Sets the item with the index \a index as current item, selects
95 * the item and assures that the item will be visible.
96 */
97 void updateCurrentItem(int index);
98
99 private:
100 bool m_updateCurrentItem;
101 KItemListController* m_controller;
102 KFileItemModel* m_model;
103 };
104
105 #endif // FOLDERSPANEL_H