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 <kfileitem.h>
27 #include <kfileitemdelegate.h>
30 #include <kurlnavigator.h>
32 #include <QtGui/QKeyEvent>
33 #include <QtCore/QLinkedList>
34 #include <QtGui/QListView>
35 #include <QtGui/QBoxLayout>
36 #include <QtGui/QWidget>
42 class DolphinDirLister
;
43 class DolphinMainWindow
;
44 class DolphinSortFilterProxyModel
;
45 class DolphinStatusBar
;
49 * @short Represents a view for the directory content
50 * including the navigation bar, filter bar and status bar.
52 * View modes for icons, details and columns are supported. Currently
53 * Dolphin allows to have up to two views inside the main window.
58 * @see DolphinStatusBar
60 class DolphinViewContainer
: public QWidget
65 DolphinViewContainer(DolphinMainWindow
* mainwindow
,
69 virtual ~DolphinViewContainer();
72 * Sets the current active URL, where all actions are applied. The
73 * URL navigator is synchronized with this URL. The signals
74 * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
76 * @see DolphinViewContainer::urlNavigator()
78 void setUrl(const KUrl
& url
);
81 * Returns the current active URL, where all actions are applied.
82 * The URL navigator is synchronized with this URL.
84 const KUrl
& url() const;
87 * If \a active is true, the view container will marked as active. The active
88 * view container is defined as view where all actions are applied to.
90 void setActive(bool active
);
91 bool isActive() const;
93 KFileItem
fileItem(const QModelIndex
& index
) const;
95 const DolphinStatusBar
* statusBar() const;
96 DolphinStatusBar
* statusBar();
99 * Returns true, if the URL shown by the navigation bar is editable.
102 bool isUrlEditable() const;
104 const KUrlNavigator
* urlNavigator() const;
105 KUrlNavigator
* urlNavigator();
107 const DolphinView
* view() const;
110 /** Returns true, if the filter bar is visible. */
111 bool isFilterBarVisible() const;
114 * Return the DolphinMainWindow this View belongs to. It is guaranteed
117 const DolphinMainWindow
* mainWindow() const;
121 * Popups the filter bar above the status bar if \a show is true.
123 void showFilterBar(bool show
);
126 * Updates the number of items (= number of files + number of
127 * directories) in the statusbar. If files are selected, the number
128 * of selected files and the sum of the filesize is shown.
130 void updateStatusBar();
134 * Is emitted whenever the filter bar has changed its visibility state.
136 void showFilterBarChanged(bool shown
);
139 void updateProgress(int percent
);
142 * Assures that the viewport position is restored and updates the
143 * statusbar to reflect the current content.
145 void slotDirListerCompleted();
148 * Handles clicking on an item
150 void slotItemTriggered(const KFileItem
& item
);
153 * Shows the information for the item \a item inside the statusbar. If the
154 * item is null, the default statusbar information is shown.
156 void showItemInfo(const KFileItem
& item
);
158 /** Shows the information \a msg inside the statusbar. */
159 void showInfoMessage(const QString
& msg
);
161 /** Shows the error message \a msg inside the statusbar. */
162 void showErrorMessage(const QString
& msg
);
164 /** Shows the "operation completed" message \a msg inside the statusbar. */
165 void showOperationCompletedMessage(const QString
& msg
);
167 void closeFilterBar();
170 * Filters the currently shown items by \a nameFilter. All items
171 * which contain the given filter string will be shown.
173 void setNameFilter(const QString
& nameFilter
);
176 * Opens the context menu on the current mouse position.
177 * @item File item context. If item is 0, the context menu
178 * should be applied to \a url.
179 * @url URL which contains \a item.
181 void openContextMenu(const KFileItem
& item
, const KUrl
& url
);
184 * Saves the position of the contents to the
185 * current history element.
187 void saveContentsPos(int x
, int y
);
190 * Restores the contents position of the view, if the view
191 * is part of the history.
193 void restoreContentsPos();
196 * Marks the view container as active
197 * (see DolphinViewContainer::setActive()).
202 * Restores the current view to show \a url and assures
203 * that the root URL of the view is respected.
205 void restoreView(const KUrl
& url
);
208 * Saves the root URL of the current URL \a url
209 * into the URL navigator.
211 void saveRootUrl(const KUrl
& url
);
215 * Returns the default text of the status bar, if no item is
218 QString
defaultStatusBarText() const;
221 * Returns the text for the status bar, if at least one item
224 QString
selectionStatusBarText() const;
229 DolphinMainWindow
* m_mainWindow
;
230 QVBoxLayout
* m_topLayout
;
231 KUrlNavigator
* m_urlNavigator
;
235 FilterBar
* m_filterBar
;
236 DolphinStatusBar
* m_statusBar
;
238 DolphinModel
* m_dolphinModel
;
239 DolphinDirLister
* m_dirLister
;
240 DolphinSortFilterProxyModel
* m_proxyModel
;
243 inline const DolphinStatusBar
* DolphinViewContainer::statusBar() const
248 inline DolphinStatusBar
* DolphinViewContainer::statusBar()
253 inline const KUrlNavigator
* DolphinViewContainer::urlNavigator() const
255 return m_urlNavigator
;
258 inline KUrlNavigator
* DolphinViewContainer::urlNavigator()
260 return m_urlNavigator
;
263 inline const DolphinView
* DolphinViewContainer::view() const
268 inline DolphinView
* DolphinViewContainer::view()
273 inline const DolphinMainWindow
* DolphinViewContainer::mainWindow() const
278 #endif // DOLPHINVIEWCONTAINER_H