add more spacing
[personal-kdebase.git] / apps / dolphin / src / panels / folders / folderspanel.h
blob90f506fd0c572c6d70ce496f18d60c8bc4ce994d
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
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 ***************************************************************************/
20 #ifndef FOLDERSPANEL_H
21 #define FOLDERSPANEL_H
23 #include <kurl.h>
24 #include <panels/panel.h>
26 class KDirLister;
27 class DolphinModel;
29 class DolphinSortFilterProxyModel;
30 class PanelTreeView;
31 class QModelIndex;
33 /**
34 * @brief Shows a tree view of the directories starting from
35 * the currently selected place.
37 * The tree view is always synchronized with the currently active view
38 * from the main window.
40 class FoldersPanel : public Panel
42 Q_OBJECT
44 public:
45 FoldersPanel(QWidget* parent = 0);
46 virtual ~FoldersPanel();
48 /** @see QWidget::sizeHint() */
49 virtual QSize sizeHint() const;
51 void setShowHiddenFiles(bool show);
52 bool showHiddenFiles() const;
54 void rename(const KFileItem& item);
56 signals:
57 /**
58 * Is emitted if the an URL change is requested.
60 void changeUrl(const KUrl& url, Qt::MouseButtons buttons);
62 /**
63 * This signal is emitted when the panel requests a change in the
64 * current selection. The file-management view recieving this signal is
65 * not required to select all listed files, limiting the selection to
66 * e.g. the current folder. The new selection will be reported via the
67 * setSelection slot.
69 void changeSelection(const KFileItemList& selection);
71 public slots:
72 /**
73 * Changes the current selection inside the tree to \a url.
75 virtual void setUrl(const KUrl& url);
77 protected:
78 /** @see QWidget::showEvent() */
79 virtual void showEvent(QShowEvent* event);
81 /** @see QWidget::contextMenuEvent() */
82 virtual void contextMenuEvent(QContextMenuEvent* event);
84 private slots:
85 /**
86 * Updates the active view to the URL
87 * which is given by the item with the index \a index.
89 void updateActiveView(const QModelIndex& index);
91 /**
92 * Is emitted if URLs have been dropped
93 * to the index \a index.
95 void dropUrls(const QModelIndex& index, QDropEvent* event);
97 /**
98 * Expands the treeview to show the directory
99 * specified by \a index.
101 void expandToDir(const QModelIndex& index);
104 * Assures that the leaf folder gets visible.
106 void scrollToLeaf();
108 void updateMouseButtons();
110 private:
112 * Initializes the base URL of the tree and expands all
113 * directories until \a url.
114 * @param url URL of the leaf directory that should get expanded.
116 void loadTree(const KUrl& url);
119 * Selects the current leaf directory m_leafDir and assures
120 * that the directory is visible if the leaf has been set by
121 * FoldersPanel::setUrl().
123 void selectLeafDirectory();
125 private:
126 bool m_setLeafVisible;
127 Qt::MouseButtons m_mouseButtons;
128 KDirLister* m_dirLister;
129 DolphinModel* m_dolphinModel;
130 DolphinSortFilterProxyModel* m_proxyModel;
131 PanelTreeView* m_treeView;
132 KUrl m_leafDir;
135 #endif // FOLDERSPANEL_H