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 <KUrl> |
24 | #include <panels/panel.h> |
25 | |
26 | class KFileItemModel; |
27 | class KItemListController; |
28 | class QGraphicsSceneDragDropEvent; |
29 | |
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 | FoldersPanel(QWidget* parent = 0); |
43 | virtual ~FoldersPanel(); |
44 | |
45 | void setShowHiddenFiles(bool show); |
46 | bool showHiddenFiles() const; |
47 | |
48 | void setAutoScrolling(bool enable); |
49 | bool autoScrolling() const; |
50 | |
51 | void rename(const KFileItem& item); |
52 | |
53 | signals: |
54 | void folderActivated(const KUrl& url); |
55 | void folderMiddleClicked(const KUrl& url); |
56 | void errorMessage(const QString& error); |
57 | |
58 | protected: |
59 | /** @see Panel::urlChanged() */ |
60 | virtual bool urlChanged(); |
61 | |
62 | /** @see QWidget::showEvent() */ |
63 | virtual void showEvent(QShowEvent* event); |
64 | |
65 | /** @see QWidget::keyPressEvent() */ |
66 | virtual void keyPressEvent(QKeyEvent* event); |
67 | |
68 | private slots: |
69 | void slotItemActivated(int index); |
70 | void slotItemMiddleClicked(int index); |
71 | void (int index, const QPointF& pos); |
72 | void (const QPointF& pos); |
73 | void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); |
74 | void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value); |
75 | |
76 | void slotLoadingCompleted(); |
77 | |
78 | /** |
79 | * Increases the opacity of the view step by step until it is fully |
80 | * opaque. |
81 | */ |
82 | void startFadeInAnimation(); |
83 | |
84 | private: |
85 | /** |
86 | * Initializes the base URL of the tree and expands all |
87 | * directories until \a url. |
88 | * @param url URL of the leaf directory that should get expanded. |
89 | */ |
90 | void loadTree(const KUrl& url); |
91 | |
92 | /** |
93 | * Sets the item with the index \a index as current item, selects |
94 | * the item and assures that the item will be visible. |
95 | */ |
96 | void updateCurrentItem(int index); |
97 | |
98 | private: |
99 | bool m_updateCurrentItem; |
100 | KItemListController* m_controller; |
101 | KFileItemModel* m_model; |
102 | }; |
103 | |
104 | #endif // FOLDERSPANEL_H |
105 | |