]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/folders/folderspanel.h
Folderspanel's context-menu option "Limit to Home Directory" is always visible
[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 <QUrl>
24 #include <panels/panel.h>
25
26 class KFileItemModel;
27 class KItemListController;
28 class QGraphicsSceneDragDropEvent;
29 class KFileItem;
30 /**
31 * @brief Shows a tree view of the directories starting from
32 * the currently selected place.
33 *
34 * The tree view is always synchronized with the currently active view
35 * from the main window.
36 */
37 class FoldersPanel : public Panel
38 {
39 Q_OBJECT
40
41 public:
42 explicit FoldersPanel(QWidget* parent = nullptr);
43 virtual ~FoldersPanel();
44
45 void setShowHiddenFiles(bool show);
46 void setLimitFoldersPanelToHome(bool enable);
47 bool showHiddenFiles() const;
48 bool limitFoldersPanelToHome() const;
49
50 void setAutoScrolling(bool enable);
51 bool autoScrolling() const;
52
53 void rename(const KFileItem& item);
54
55 signals:
56 void folderActivated(const QUrl& url);
57 void folderMiddleClicked(const QUrl& url);
58 void errorMessage(const QString& error);
59
60 protected:
61 /** @see Panel::urlChanged() */
62 virtual bool urlChanged() Q_DECL_OVERRIDE;
63
64 /** @see QWidget::showEvent() */
65 virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
66
67 /** @see QWidget::keyPressEvent() */
68 virtual void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
69
70 private slots:
71 void slotItemActivated(int index);
72 void slotItemMiddleClicked(int index);
73 void slotItemContextMenuRequested(int index, const QPointF& pos);
74 void slotViewContextMenuRequested(const QPointF& pos);
75 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
76 void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
77
78 void slotLoadingCompleted();
79
80 /**
81 * Increases the opacity of the view step by step until it is fully
82 * opaque.
83 */
84 void startFadeInAnimation();
85
86
87 private:
88 /**
89 * Indicate if it is allowed to leave current location.
90 */
91 enum NavigationBehaviour {
92 StayWhereYouAre, ///< Don't leave current location.
93 AllowJumpHome ///< Go Home only when context menu option got checked.
94 };
95 /**
96 * Initializes the base URL of the tree and expands all
97 * directories until \a url.
98 * @param url URL of the leaf directory that should get expanded.
99 * @param navigationBehaviour Navigation behaviour \see NavigationBehaviour
100 */
101 void loadTree(const QUrl& url, NavigationBehaviour navigationBehaviour = StayWhereYouAre);
102
103 void reloadTree();
104
105 /**
106 * Sets the item with the index \a index as current item, selects
107 * the item and assures that the item will be visible.
108 */
109 void updateCurrentItem(int index);
110
111 private:
112 bool m_updateCurrentItem;
113 KItemListController* m_controller;
114 KFileItemModel* m_model;
115 };
116
117 #endif // FOLDERSPANEL_H