1 /***************************************************************************
2 * Copyright (C) 2007 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 ***************************************************************************/
21 #ifndef DOLPHINVIEWCONTAINER_H
22 #define DOLPHINVIEWCONTAINER_H
24 #include "dolphinview.h"
26 #include <kparts/part.h>
27 #include <kfileitem.h>
28 #include <kfileitemdelegate.h>
31 #include <kurlnavigator.h>
33 #include <QtGui/QKeyEvent>
34 #include <QtCore/QLinkedList>
35 #include <QtGui/QListView>
36 #include <QtGui/QBoxLayout>
37 #include <QtGui/QWidget>
43 class DolphinDirLister
;
44 class DolphinMainWindow
;
45 class DolphinSortFilterProxyModel
;
46 class DolphinStatusBar
;
50 * @short Represents a view for the directory content
51 * including the navigation bar, filter bar and status bar.
53 * View modes for icons, details and columns are supported. Currently
54 * Dolphin allows to have up to two views inside the main window.
59 * @see DolphinStatusBar
61 class DolphinViewContainer
: public QWidget
66 DolphinViewContainer(DolphinMainWindow
* mainwindow
,
70 virtual ~DolphinViewContainer();
73 * Sets the current active URL, where all actions are applied. The
74 * URL navigator is synchronized with this URL. The signals
75 * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
77 * @see DolphinViewContainer::urlNavigator()
79 void setUrl(const KUrl
& url
);
82 * Returns the current active URL, where all actions are applied.
83 * The URL navigator is synchronized with this URL.
85 const KUrl
& url() const;
88 * If \a active is true, the view container will marked as active. The active
89 * view container is defined as view where all actions are applied to.
91 void setActive(bool active
);
92 bool isActive() const;
95 * Triggers the renaming of the currently selected items, where
96 * the user must input a new name for the items.
98 void renameSelectedItems();
100 KFileItem
* fileItem(const QModelIndex index
) const;
102 inline const DolphinStatusBar
* statusBar() const;
103 inline DolphinStatusBar
* statusBar();
106 * Returns true, if the URL shown by the navigation bar is editable.
109 bool isUrlEditable() const;
111 inline const KUrlNavigator
* urlNavigator() const;
112 inline KUrlNavigator
* urlNavigator();
114 inline const DolphinView
* view() const;
115 inline DolphinView
* view();
117 /** Returns true, if the filter bar is visible. */
118 bool isFilterBarVisible() const;
121 * Return the DolphinMainWindow this View belongs to. It is guaranteed
124 inline const DolphinMainWindow
* mainWindow() const;
128 * Popups the filter bar above the status bar if \a show is true.
130 void showFilterBar(bool show
);
133 * Updates the number of items (= number of files + number of
134 * directories) in the statusbar. If files are selected, the number
135 * of selected files and the sum of the filesize is shown.
137 void updateStatusBar();
141 * Is emitted whenever the filter bar has changed its visibility state.
143 void showFilterBarChanged(bool shown
);
146 void updateProgress(int percent
);
149 * Updates the number of items (= number of directories + number of files)
150 * and shows this information in the statusbar.
152 void updateItemCount();
155 * Shows the information for the item \a item inside the statusbar. If the
156 * item is null, the default statusbar information is shown.
158 void showItemInfo(const KFileItem
& item
);
160 /** Shows the information \a msg inside the statusbar. */
161 void showInfoMessage(const QString
& msg
);
163 /** Shows the error message \a msg inside the statusbar. */
164 void showErrorMessage(const QString
& msg
);
166 void closeFilterBar();
169 * Filters the currently shown items by \a nameFilter. All items
170 * which contain the given filter string will be shown.
172 void changeNameFilter(const QString
& nameFilter
);
175 * Opens the context menu on the current mouse postition.
176 * @item File item context. If item is 0, the context menu
177 * should be applied to \a url.
178 * @url URL which contains \a item.
180 void openContextMenu(KFileItem
* item
, const KUrl
& url
);
183 * Saves the position of the contents to the
184 * current history element.
186 void saveContentsPos(int x
, int y
);
189 * Restores the contents position of the view, if the view
190 * is part of the history.
192 void restoreContentsPos();
195 * Marks the view container as active
196 * (see DolphinViewContainer::setActive()).
202 * Returns the default text of the status bar, if no item is
205 QString
defaultStatusBarText() const;
208 * Returns the text for the status bar, if at least one item
211 QString
selectionStatusBarText() const;
220 DolphinMainWindow
* m_mainWindow
;
221 QVBoxLayout
* m_topLayout
;
222 KUrlNavigator
* m_urlNavigator
;
226 FilterBar
* m_filterBar
;
227 DolphinStatusBar
* m_statusBar
;
229 KDirModel
* m_dirModel
;
230 DolphinDirLister
* m_dirLister
;
231 DolphinSortFilterProxyModel
* m_proxyModel
;
234 const DolphinStatusBar
* DolphinViewContainer::statusBar() const
239 DolphinStatusBar
* DolphinViewContainer::statusBar()
244 const KUrlNavigator
* DolphinViewContainer::urlNavigator() const
246 return m_urlNavigator
;
249 KUrlNavigator
* DolphinViewContainer::urlNavigator()
251 return m_urlNavigator
;
254 const DolphinView
* DolphinViewContainer::view() const
259 DolphinView
* DolphinViewContainer::view()
264 const DolphinMainWindow
* DolphinViewContainer::mainWindow() const
268 #endif // DOLPHINVIEWCONTAINER_H