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>
28 #include <kglobalsettings.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;
94 const DolphinStatusBar
* statusBar() const;
95 DolphinStatusBar
* statusBar();
98 * Returns true, if the URL shown by the navigation bar is editable.
101 bool isUrlEditable() const;
103 const KUrlNavigator
* urlNavigator() const;
104 KUrlNavigator
* urlNavigator();
106 const DolphinView
* view() const;
110 * Refreshes the view container to get synchronized with the (updated) Dolphin settings.
114 /** Returns true, if the filter bar is visible. */
115 bool isFilterBarVisible() const;
119 * Popups the filter bar above the status bar if \a show is true.
121 void showFilterBar(bool show
);
124 * Updates the number of items (= number of files + number of
125 * directories) in the statusbar. If files are selected, the number
126 * of selected files and the sum of the filesize is shown.
128 void updateStatusBar();
132 * Is emitted whenever the filter bar has changed its visibility state.
134 void showFilterBarChanged(bool shown
);
137 void updateProgress(int percent
);
140 * Assures that the viewport position is restored and updates the
141 * statusbar to reflect the current content.
143 void slotDirListerCompleted();
146 * Handles clicking on an item. If the item is a directory, the
147 * directory is opened in the view. If the item is a file, the file
148 * gets started by the corresponding application.
150 void slotItemTriggered(const KFileItem
& item
);
153 * Opens a the file \a url by opening the corresponding application.
154 * Is connected with the signal urlIsFile() from DolphinDirLister and will
155 * get invoked if the user manually has entered a file into the URL navigator.
157 void openFile(const KUrl
& url
);
160 * Shows the information for the item \a item inside the statusbar. If the
161 * item is null, the default statusbar information is shown.
163 void showItemInfo(const KFileItem
& item
);
165 /** Shows the information \a msg inside the statusbar. */
166 void showInfoMessage(const QString
& msg
);
168 /** Shows the error message \a msg inside the statusbar. */
169 void showErrorMessage(const QString
& msg
);
171 /** Shows the "operation completed" message \a msg inside the statusbar. */
172 void showOperationCompletedMessage(const QString
& msg
);
174 void closeFilterBar();
177 * Filters the currently shown items by \a nameFilter. All items
178 * which contain the given filter string will be shown.
180 void setNameFilter(const QString
& nameFilter
);
183 * Opens the context menu on the current mouse position.
184 * @item File item context. If item is null, the context menu
185 * should be applied to \a url.
186 * @url URL which contains \a item.
187 * @customActions Actions that should be added to the context menu,
188 * if the file item is null.
190 void openContextMenu(const KFileItem
& item
,
192 const QList
<QAction
*>& customActions
);
195 * Saves the position of the contents to the
196 * current history element.
198 void saveContentsPos(int x
, int y
);
201 * Restores the contents position of the view, if the view
202 * is part of the history.
204 void restoreContentsPos();
207 * Marks the view container as active
208 * (see DolphinViewContainer::setActive()).
213 * Restores the current view to show \a url and assures
214 * that the root URL of the view is respected.
216 void restoreView(const KUrl
& url
);
219 * Saves the root URL of the current URL \a url
220 * into the URL navigator.
222 void saveRootUrl(const KUrl
& url
);
225 * Is connected with the URL navigator and drops the URLs
226 * above the destination \a destination.
228 void dropUrls(const KUrl
& destination
, QDropEvent
* event
);
231 * Is invoked when a redirection is done and changes the
232 * URL of the URL navigator to \a newUrl without triggering
233 * a reloading of the directory.
235 void redirect(const KUrl
& oldUrl
, const KUrl
& newUrl
);
237 /** Requests the focus for the view \a m_view. */
241 * Saves the currently used URL completion mode of
244 void saveUrlCompletionMode(KGlobalSettings::Completion completion
);
248 bool m_isFolderWritable
;
250 DolphinMainWindow
* m_mainWindow
;
251 QVBoxLayout
* m_topLayout
;
252 KUrlNavigator
* m_urlNavigator
;
256 FilterBar
* m_filterBar
;
257 DolphinStatusBar
* m_statusBar
;
259 DolphinModel
* m_dolphinModel
;
260 DolphinDirLister
* m_dirLister
;
261 DolphinSortFilterProxyModel
* m_proxyModel
;
264 inline const DolphinStatusBar
* DolphinViewContainer::statusBar() const
269 inline DolphinStatusBar
* DolphinViewContainer::statusBar()
274 inline const KUrlNavigator
* DolphinViewContainer::urlNavigator() const
276 return m_urlNavigator
;
279 inline KUrlNavigator
* DolphinViewContainer::urlNavigator()
281 return m_urlNavigator
;
284 inline const DolphinView
* DolphinViewContainer::view() const
289 inline DolphinView
* DolphinViewContainer::view()
294 #endif // DOLPHINVIEWCONTAINER_H