]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewcontainer.h
Remove all code that is related to DolphinController's
[dolphin.git] / src / dolphinviewcontainer.h
1 /***************************************************************************
2 * Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
3 * *
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. *
8 * *
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. *
13 * *
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 ***************************************************************************/
19
20
21 #ifndef DOLPHINVIEWCONTAINER_H
22 #define DOLPHINVIEWCONTAINER_H
23
24 #include "dolphinview.h"
25
26 #include <kfileitem.h>
27 #include <kfileitemdelegate.h>
28 #include <kglobalsettings.h>
29 #include <kio/job.h>
30
31 #include <kurlnavigator.h>
32
33 #include <QtGui/QKeyEvent>
34 #include <QtCore/QLinkedList>
35 #include <QtGui/QListView>
36 #include <QtGui/QBoxLayout>
37 #include <QtGui/QWidget>
38
39 class FilterBar;
40 class KUrl;
41 class DolphinModel;
42 class KUrlNavigator;
43 class DolphinDirLister;
44 class DolphinSortFilterProxyModel;
45 class DolphinStatusBar;
46
47 /**
48 * @short Represents a view for the directory content
49 * including the navigation bar, filter bar and status bar.
50 *
51 * View modes for icons, details and columns are supported. Currently
52 * Dolphin allows to have up to two views inside the main window.
53 *
54 * @see DolphinView
55 * @see FilterBar
56 * @see KUrlNavigator
57 * @see DolphinStatusBar
58 */
59 class DolphinViewContainer : public QWidget
60 {
61 Q_OBJECT
62
63 public:
64 DolphinViewContainer(const KUrl& url, QWidget* parent);
65 virtual ~DolphinViewContainer();
66
67 /**
68 * Returns the current active URL, where all actions are applied.
69 * The URL navigator is synchronized with this URL.
70 */
71 KUrl url() const;
72
73 /**
74 * If \a active is true, the view container will marked as active. The active
75 * view container is defined as view where all actions are applied to.
76 */
77 void setActive(bool active);
78 bool isActive() const;
79
80 const DolphinStatusBar* statusBar() const;
81 DolphinStatusBar* statusBar();
82
83 const KUrlNavigator* urlNavigator() const;
84 KUrlNavigator* urlNavigator();
85
86 const DolphinView* view() const;
87 DolphinView* view();
88
89 /**
90 * Refreshes the view container to get synchronized with the (updated) Dolphin settings.
91 */
92 void refresh();
93
94 /** Returns true, if the filter bar is visible. */
95 bool isFilterBarVisible() const;
96
97 public slots:
98 /**
99 * Sets the current active URL, where all actions are applied. The
100 * URL navigator is synchronized with this URL. The signals
101 * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
102 * are emitted.
103 * @see DolphinViewContainer::urlNavigator()
104 */
105 void setUrl(const KUrl& url);
106
107 /**
108 * Popups the filter bar above the status bar if \a show is true.
109 */
110 void showFilterBar(bool show);
111
112 signals:
113 /**
114 * Is emitted whenever the filter bar has changed its visibility state.
115 */
116 void showFilterBarChanged(bool shown);
117
118 /**
119 * Is emitted when the write state of the folder has been changed. The application
120 * should disable all actions like "Create New..." that depend on the write
121 * state.
122 */
123 void writeStateChanged(bool isFolderWritable);
124
125 private slots:
126 /**
127 * Updates the number of items (= number of files + number of
128 * directories) in the statusbar. If files are selected, the number
129 * of selected files and the sum of the filesize is shown. The update
130 * is done asynchronously, as getting the sum of the
131 * filesizes can be an expensive operation.
132 */
133 void delayedStatusBarUpdate();
134
135 /**
136 * Is invoked by DolphinViewContainer::delayedStatusBarUpdate() and
137 * updates the status bar synchronously.
138 */
139 void updateStatusBar();
140
141 void initializeProgress();
142
143 void updateProgress(int percent);
144
145 /**
146 * Assures that the viewport position is restored and updates the
147 * statusbar to reflect the current content.
148 */
149 void slotDirListerCompleted();
150
151 /**
152 * Handles clicking on an item. If the item is a directory, the
153 * directory is opened in the view. If the item is a file, the file
154 * gets started by the corresponding application.
155 */
156 void slotItemTriggered(const KFileItem& item);
157
158 /**
159 * Opens a the file \a url by opening the corresponding application.
160 * Is connected with the signal urlIsFile() from DolphinDirLister and will
161 * get invoked if the user manually has entered a file into the URL navigator.
162 */
163 void openFile(const KUrl& url);
164
165 /**
166 * Shows the information for the item \a item inside the statusbar. If the
167 * item is null, the default statusbar information is shown.
168 */
169 void showItemInfo(const KFileItem& item);
170
171 /** Shows the information \a msg inside the statusbar. */
172 void showInfoMessage(const QString& msg);
173
174 /** Shows the error message \a msg inside the statusbar. */
175 void showErrorMessage(const QString& msg);
176
177 /** Shows the "operation completed" message \a msg inside the statusbar. */
178 void showOperationCompletedMessage(const QString& msg);
179
180 void closeFilterBar();
181
182 /**
183 * Filters the currently shown items by \a nameFilter. All items
184 * which contain the given filter string will be shown.
185 */
186 void setNameFilter(const QString& nameFilter);
187
188 /**
189 * Marks the view container as active
190 * (see DolphinViewContainer::setActive()).
191 */
192 void activate();
193
194 /**
195 * Saves the state of the current view: contents position,
196 * root URL, ...
197 */
198 void saveViewState();
199
200 /**
201 * Restores the current view to show \a url and assures
202 * that the root URL of the view is respected.
203 */
204 void slotUrlNavigatorLocationChanged(const KUrl& url);
205
206 /**
207 * Is connected with the URL navigator and drops the URLs
208 * above the destination \a destination.
209 */
210 void dropUrls(const KUrl& destination, QDropEvent* event);
211
212 /**
213 * Is invoked when a redirection is done and changes the
214 * URL of the URL navigator to \a newUrl without triggering
215 * a reloading of the directory.
216 */
217 void redirect(const KUrl& oldUrl, const KUrl& newUrl);
218
219 /** Requests the focus for the view \a m_view. */
220 void requestFocus();
221
222 /**
223 * Saves the currently used URL completion mode of
224 * the URL navigator.
225 */
226 void saveUrlCompletionMode(KGlobalSettings::Completion completion);
227
228 void slotHistoryChanged();
229
230 private:
231 bool m_isFolderWritable;
232
233 QVBoxLayout* m_topLayout;
234 KUrlNavigator* m_urlNavigator;
235
236 DolphinView* m_view;
237
238 FilterBar* m_filterBar;
239
240 DolphinStatusBar* m_statusBar;
241 QTimer* m_statusBarTimer;
242
243 DolphinModel* m_dolphinModel;
244 DolphinDirLister* m_dirLister;
245 DolphinSortFilterProxyModel* m_proxyModel;
246 };
247
248 inline const DolphinStatusBar* DolphinViewContainer::statusBar() const
249 {
250 return m_statusBar;
251 }
252
253 inline DolphinStatusBar* DolphinViewContainer::statusBar()
254 {
255 return m_statusBar;
256 }
257
258 inline const KUrlNavigator* DolphinViewContainer::urlNavigator() const
259 {
260 return m_urlNavigator;
261 }
262
263 inline KUrlNavigator* DolphinViewContainer::urlNavigator()
264 {
265 return m_urlNavigator;
266 }
267
268 inline const DolphinView* DolphinViewContainer::view() const
269 {
270 return m_view;
271 }
272
273 inline DolphinView* DolphinViewContainer::view()
274 {
275 return m_view;
276 }
277
278 #endif // DOLPHINVIEWCONTAINER_H