1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
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. *
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. *
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 ***************************************************************************/
20 #ifndef FOLDERSPANEL_H
21 #define FOLDERSPANEL_H
23 #include "panels/panel.h"
28 class KItemListController
;
29 class QGraphicsSceneDragDropEvent
;
32 * @brief Shows a tree view of the directories starting from
33 * the currently selected place.
35 * The tree view is always synchronized with the currently active view
36 * from the main window.
38 class FoldersPanel
: public Panel
43 explicit FoldersPanel(QWidget
* parent
= nullptr);
44 ~FoldersPanel() override
;
46 void setShowHiddenFiles(bool show
);
47 void setLimitFoldersPanelToHome(bool enable
);
48 bool showHiddenFiles() const;
49 bool limitFoldersPanelToHome() const;
51 void setAutoScrolling(bool enable
);
52 bool autoScrolling() const;
54 void rename(const KFileItem
& item
);
57 void folderActivated(const QUrl
& url
);
58 void folderMiddleClicked(const QUrl
& url
);
59 void errorMessage(const QString
& error
);
62 /** @see Panel::urlChanged() */
63 bool urlChanged() override
;
65 /** @see QWidget::showEvent() */
66 void showEvent(QShowEvent
* event
) override
;
68 /** @see QWidget::keyPressEvent() */
69 void keyPressEvent(QKeyEvent
* event
) override
;
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
);
79 void slotLoadingCompleted();
82 * Increases the opacity of the view step by step until it is fully
85 void startFadeInAnimation();
90 * Indicate if it is allowed to leave current location.
92 enum NavigationBehaviour
{
93 StayWhereYouAre
, ///< Don't leave current location.
94 AllowJumpHome
///< Go Home only when context menu option got checked.
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
102 void loadTree(const QUrl
& url
, NavigationBehaviour navigationBehaviour
= StayWhereYouAre
);
107 * Sets the item with the index \a index as current item, selects
108 * the item and assures that the item will be visible.
110 void updateCurrentItem(int index
);
113 bool m_updateCurrentItem
;
114 KItemListController
* m_controller
;
115 KFileItemModel
* m_model
;
118 #endif // FOLDERSPANEL_H