]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewcontainer.h
remove (another) unused method
[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 <kio/job.h>
29
30 #include <kurlnavigator.h>
31
32 #include <QtGui/QKeyEvent>
33 #include <QtCore/QLinkedList>
34 #include <QtGui/QListView>
35 #include <QtGui/QBoxLayout>
36 #include <QtGui/QWidget>
37
38 class FilterBar;
39 class KUrl;
40 class DolphinModel;
41 class KUrlNavigator;
42 class DolphinDirLister;
43 class DolphinMainWindow;
44 class DolphinSortFilterProxyModel;
45 class DolphinStatusBar;
46 class QModelIndex;
47
48 /**
49 * @short Represents a view for the directory content
50 * including the navigation bar, filter bar and status bar.
51 *
52 * View modes for icons, details and columns are supported. Currently
53 * Dolphin allows to have up to two views inside the main window.
54 *
55 * @see DolphinView
56 * @see FilterBar
57 * @see KUrlNavigator
58 * @see DolphinStatusBar
59 */
60 class DolphinViewContainer : public QWidget
61 {
62 Q_OBJECT
63
64 public:
65 DolphinViewContainer(DolphinMainWindow* mainwindow,
66 QWidget *parent,
67 const KUrl& url);
68
69 virtual ~DolphinViewContainer();
70
71 /**
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()
75 * are emitted.
76 * @see DolphinViewContainer::urlNavigator()
77 */
78 void setUrl(const KUrl& url);
79
80 /**
81 * Returns the current active URL, where all actions are applied.
82 * The URL navigator is synchronized with this URL.
83 */
84 const KUrl& url() const;
85
86 /**
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.
89 */
90 void setActive(bool active);
91 bool isActive() const;
92
93 const DolphinStatusBar* statusBar() const;
94 DolphinStatusBar* statusBar();
95
96 /**
97 * Returns true, if the URL shown by the navigation bar is editable.
98 * @see KUrlNavigator
99 */
100 bool isUrlEditable() const;
101
102 const KUrlNavigator* urlNavigator() const;
103 KUrlNavigator* urlNavigator();
104
105 const DolphinView* view() const;
106 DolphinView* view();
107
108 /** Returns true, if the filter bar is visible. */
109 bool isFilterBarVisible() const;
110
111 public slots:
112 /**
113 * Popups the filter bar above the status bar if \a show is true.
114 */
115 void showFilterBar(bool show);
116
117 /**
118 * Updates the number of items (= number of files + number of
119 * directories) in the statusbar. If files are selected, the number
120 * of selected files and the sum of the filesize is shown.
121 */
122 void updateStatusBar();
123
124 signals:
125 /**
126 * Is emitted whenever the filter bar has changed its visibility state.
127 */
128 void showFilterBarChanged(bool shown);
129
130 private slots:
131 void updateProgress(int percent);
132
133 /**
134 * Assures that the viewport position is restored and updates the
135 * statusbar to reflect the current content.
136 */
137 void slotDirListerCompleted();
138
139 /**
140 * Handles clicking on an item
141 */
142 void slotItemTriggered(const KFileItem& item);
143
144 /**
145 * Shows the information for the item \a item inside the statusbar. If the
146 * item is null, the default statusbar information is shown.
147 */
148 void showItemInfo(const KFileItem& item);
149
150 /** Shows the information \a msg inside the statusbar. */
151 void showInfoMessage(const QString& msg);
152
153 /** Shows the error message \a msg inside the statusbar. */
154 void showErrorMessage(const QString& msg);
155
156 /** Shows the "operation completed" message \a msg inside the statusbar. */
157 void showOperationCompletedMessage(const QString& msg);
158
159 void closeFilterBar();
160
161 /**
162 * Filters the currently shown items by \a nameFilter. All items
163 * which contain the given filter string will be shown.
164 */
165 void setNameFilter(const QString& nameFilter);
166
167 /**
168 * Opens the context menu on the current mouse position.
169 * @item File item context. If item is 0, the context menu
170 * should be applied to \a url.
171 * @url URL which contains \a item.
172 */
173 void openContextMenu(const KFileItem& item, const KUrl& url);
174
175 /**
176 * Saves the position of the contents to the
177 * current history element.
178 */
179 void saveContentsPos(int x, int y);
180
181 /**
182 * Restores the contents position of the view, if the view
183 * is part of the history.
184 */
185 void restoreContentsPos();
186
187 /**
188 * Marks the view container as active
189 * (see DolphinViewContainer::setActive()).
190 */
191 void activate();
192
193 /**
194 * Restores the current view to show \a url and assures
195 * that the root URL of the view is respected.
196 */
197 void restoreView(const KUrl& url);
198
199 /**
200 * Saves the root URL of the current URL \a url
201 * into the URL navigator.
202 */
203 void saveRootUrl(const KUrl& url);
204
205 private:
206 /**
207 * Returns the default text of the status bar, if no item is
208 * selected.
209 */
210 QString defaultStatusBarText() const;
211
212 /**
213 * Returns the text for the status bar, if at least one item
214 * is selected.
215 */
216 QString selectionStatusBarText() const;
217
218 private:
219 bool m_showProgress;
220
221 DolphinMainWindow* m_mainWindow;
222 QVBoxLayout* m_topLayout;
223 KUrlNavigator* m_urlNavigator;
224
225 DolphinView* m_view;
226
227 FilterBar* m_filterBar;
228 DolphinStatusBar* m_statusBar;
229
230 DolphinModel* m_dolphinModel;
231 DolphinDirLister* m_dirLister;
232 DolphinSortFilterProxyModel* m_proxyModel;
233 };
234
235 inline const DolphinStatusBar* DolphinViewContainer::statusBar() const
236 {
237 return m_statusBar;
238 }
239
240 inline DolphinStatusBar* DolphinViewContainer::statusBar()
241 {
242 return m_statusBar;
243 }
244
245 inline const KUrlNavigator* DolphinViewContainer::urlNavigator() const
246 {
247 return m_urlNavigator;
248 }
249
250 inline KUrlNavigator* DolphinViewContainer::urlNavigator()
251 {
252 return m_urlNavigator;
253 }
254
255 inline const DolphinView* DolphinViewContainer::view() const
256 {
257 return m_view;
258 }
259
260 inline DolphinView* DolphinViewContainer::view()
261 {
262 return m_view;
263 }
264
265 #endif // DOLPHINVIEWCONTAINER_H