]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/folders/folderspanel.h
Merge branch 'Applications/19.04'
[dolphin.git] / src / panels / folders / folderspanel.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef FOLDERSPANEL_H
21 #define FOLDERSPANEL_H
22
23 #include "panels/panel.h"
24
25 #include <QUrl>
26
27 class KFileItemModel;
28 class KItemListController;
29 class QGraphicsSceneDragDropEvent;
30 class KFileItem;
31 /**
32 * @brief Shows a tree view of the directories starting from
33 * the currently selected place.
34 *
35 * The tree view is always synchronized with the currently active view
36 * from the main window.
37 */
38 class FoldersPanel : public Panel
39 {
40 Q_OBJECT
41
42 public:
43 explicit FoldersPanel(QWidget* parent = nullptr);
44 ~FoldersPanel() override;
45
46 void setShowHiddenFiles(bool show);
47 void setLimitFoldersPanelToHome(bool enable);
48 bool showHiddenFiles() const;
49 bool limitFoldersPanelToHome() const;
50
51 void setAutoScrolling(bool enable);
52 bool autoScrolling() const;
53
54 void rename(const KFileItem& item);
55
56 signals:
57 void folderActivated(const QUrl& url);
58 void folderMiddleClicked(const QUrl& url);
59 void errorMessage(const QString& error);
60
61 protected:
62 /** @see Panel::urlChanged() */
63 bool urlChanged() override;
64
65 /** @see QWidget::showEvent() */
66 void showEvent(QShowEvent* event) override;
67
68 /** @see QWidget::keyPressEvent() */
69 void keyPressEvent(QKeyEvent* event) override;
70
71 private slots:
72 void slotItemActivated(int index);
73 void slotItemMiddleClicked(int index);
74 void slotItemContextMenuRequested(int index, const QPointF& pos);
75 void slotViewContextMenuRequested(const QPointF& pos);
76 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
77 void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
78
79 void slotLoadingCompleted();
80
81 /**
82 * Increases the opacity of the view step by step until it is fully
83 * opaque.
84 */
85 void startFadeInAnimation();
86
87
88 private:
89 /**
90 * Indicate if it is allowed to leave current location.
91 */
92 enum NavigationBehaviour {
93 StayWhereYouAre, ///< Don't leave current location.
94 AllowJumpHome ///< Go Home only when context menu option got checked.
95 };
96 /**
97 * Initializes the base URL of the tree and expands all
98 * directories until \a url.
99 * @param url URL of the leaf directory that should get expanded.
100 * @param navigationBehaviour Navigation behaviour \see NavigationBehaviour
101 */
102 void loadTree(const QUrl& url, NavigationBehaviour navigationBehaviour = StayWhereYouAre);
103
104 void reloadTree();
105
106 /**
107 * Sets the item with the index \a index as current item, selects
108 * the item and assures that the item will be visible.
109 */
110 void updateCurrentItem(int index);
111
112 private:
113 bool m_updateCurrentItem;
114 KItemListController* m_controller;
115 KFileItemModel* m_model;
116 };
117
118 #endif // FOLDERSPANEL_H