1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
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 TREEVIEWSIDEBARPAGE_H
21 #define TREEVIEWSIDEBARPAGE_H
24 #include <sidebarpage.h>
29 class DolphinSortFilterProxyModel
;
30 class SidebarTreeView
;
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 TreeViewSidebarPage
: public SidebarPage
45 TreeViewSidebarPage(QWidget
* parent
= 0);
46 virtual ~TreeViewSidebarPage();
48 /** @see QWidget::sizeHint() */
49 virtual QSize
sizeHint() const;
51 void setShowHiddenFiles(bool show
);
52 bool showHiddenFiles() const;
56 * Is emitted if the an URL change is requested.
58 void changeUrl(const KUrl
& url
, Qt::MouseButtons buttons
);
61 * This signal is emitted when the sidebar requests a change in the
62 * current selection. The file-management view recieving this signal is
63 * not required to select all listed files, limiting the selection to
64 * e.g. the current folder. The new selection will be reported via the
67 void changeSelection(const KFileItemList
& selection
);
70 * This signal is emitted whenever a drop action on this widget needs the
71 * MainWindow's attention.
73 void urlsDropped(const KUrl::List
& urls
, const KUrl
& destination
);
77 * Changes the current selection inside the tree to \a url.
79 virtual void setUrl(const KUrl
& url
);
82 /** @see QWidget::showEvent() */
83 virtual void showEvent(QShowEvent
* event
);
85 /** @see QWidget::contextMenuEvent() */
86 virtual void contextMenuEvent(QContextMenuEvent
* event
);
90 * Updates the active view to the URL
91 * which is given by the item with the index \a index.
93 void updateActiveView(const QModelIndex
& index
);
96 * Is emitted if the URLs \a urls have been dropped
97 * to the index \a index. */
98 void dropUrls(const KUrl::List
& urls
,
99 const QModelIndex
& index
);
102 * Invokes expandToLeafDir() asynchronously (the expanding
103 * may not be done in the context of this slot).
105 void triggerExpanding();
108 * Invokes loadSubTree() asynchronously (the loading
109 * may not be done in the context of this slot).
111 void triggerLoadSubTree();
114 * Expands all directories to make m_leafDir visible and
115 * adjusts the selection.
117 void expandToLeafDir();
120 * Loads the sub tree to make m_leafDir visible. Is invoked
121 * indirectly by loadTree() after the directory lister has
122 * finished loading the root items.
127 * Assures that the leaf folder gets visible.
131 void updateMouseButtons();
135 * Initializes the base URL of the tree and expands all
136 * directories until \a url.
137 * @param url URL of the leaf directory that should get expanded.
139 void loadTree(const KUrl
& url
);
142 * Selects the current leaf directory m_leafDir and assures
143 * that the directory is visible if the leaf has been set by
144 * TreeViewSidebarPage::setUrl().
146 void selectLeafDirectory();
149 bool m_setLeafVisible
;
150 Qt::MouseButtons m_mouseButtons
;
151 KDirLister
* m_dirLister
;
152 DolphinModel
* m_dolphinModel
;
153 DolphinSortFilterProxyModel
* m_proxyModel
;
154 SidebarTreeView
* m_treeView
;
158 #endif // TREEVIEWSIDEBARPAGE_H