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
,
69 DolphinView::Mode mode
= DolphinView::IconsView
,
70 bool showHiddenFiles
= false);
72 virtual ~DolphinViewContainer();
75 * Sets the current active URL, where all actions are applied. The
76 * URL navigator is synchronized with this URL. The signals
77 * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
79 * @see DolphinViewContainer::urlNavigator()
81 void setUrl(const KUrl
& url
);
84 * Returns the current active URL, where all actions are applied.
85 * The URL navigator is synchronized with this URL.
87 const KUrl
& url() const;
90 * If \a active is true, the view container will marked as active. The active
91 * view container is defined as view where all actions are applied to.
93 void setActive(bool active
);
94 bool isActive() const;
97 * Triggers the renaming of the currently selected items, where
98 * the user must input a new name for the items.
100 void renameSelectedItems();
102 KFileItem
* fileItem(const QModelIndex index
) const;
104 DolphinStatusBar
* statusBar() const;
107 * Returns true, if the URL shown by the navigation bar is editable.
110 bool isUrlEditable() const;
112 inline KUrlNavigator
* urlNavigator() const;
114 inline DolphinView
* view() const;
116 /** Returns true, if the filter bar is visible. */
117 bool isFilterBarVisible() const;
120 * Return the DolphinMainWindow this View belongs to. It is guaranteed
123 DolphinMainWindow
* mainWindow() const ;
127 * Popups the filter bar above the status bar if \a show is true.
129 void showFilterBar(bool show
);
132 * Updates the number of items (= number of files + number of
133 * directories) in the statusbar. If files are selected, the number
134 * of selected files and the sum of the filesize is shown.
136 void updateStatusBar();
140 * Is emitted whenever the filter bar has changed its visibility state.
142 void showFilterBarChanged(bool shown
);
145 void updateProgress(int percent
);
148 * Updates the number of items (= number of directories + number of files)
149 * and shows this information in the statusbar.
151 void updateItemCount();
154 * Shows the item information for the URL \a url inside the statusbar. If the
155 * URL is empty, the default statusbar information is shown.
157 void showItemInfo(const KUrl
& url
);
159 /** Shows the information \a msg inside the statusbar. */
160 void showInfoMessage(const QString
& msg
);
162 /** Shows the error message \a msg inside the statusbar. */
163 void showErrorMessage(const QString
& msg
);
165 void closeFilterBar();
168 * Filters the currently shown items by \a nameFilter. All items
169 * which contain the given filter string will be shown.
171 void changeNameFilter(const QString
& nameFilter
);
174 * Opens the context menu on the current mouse postition.
175 * @item File item context. If item is 0, the context menu
176 * should be applied to \a url.
177 * @url URL which contains \a item.
179 void openContextMenu(KFileItem
* item
, const KUrl
& url
);
182 * Saves the position of the contents to the
183 * current history element.
185 void saveContentsPos(int x
, int y
);
188 * Restores the contents position of the view, if the view
189 * is part of the history.
191 void restoreContentsPos();
194 * Marks the view container as active
195 * (see DolphinViewContainer::setActive()).
201 * Returns the default text of the status bar, if no item is
204 QString
defaultStatusBarText() const;
207 * Returns the text for the status bar, if at least one item
210 QString
selectionStatusBarText() const;
219 DolphinMainWindow
* m_mainWindow
;
220 QVBoxLayout
* m_topLayout
;
221 KUrlNavigator
* m_urlNavigator
;
225 FilterBar
* m_filterBar
;
226 DolphinStatusBar
* m_statusBar
;
228 KDirModel
* m_dirModel
;
229 DolphinDirLister
* m_dirLister
;
230 DolphinSortFilterProxyModel
* m_proxyModel
;
233 KUrlNavigator
* DolphinViewContainer::urlNavigator() const
235 return m_urlNavigator
;
238 DolphinView
* DolphinViewContainer::view() const
243 #endif // DOLPHINVIEWCONTAINER_H