]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/folders/folderspanel.h
mediawidget: bind arrow keys to slide in media
[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 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