]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewcontainer.h
don't delete inactive columns when reloading the column-view
[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 /**
94 * Triggers the renaming of the currently selected items, where
95 * the user must input a new name for the items.
96 */
97 void renameSelectedItems();
98
99 KFileItem fileItem(const QModelIndex& index) const;
100
101 inline const DolphinStatusBar* statusBar() const;
102 inline DolphinStatusBar* statusBar();
103
104 /**
105 * Returns true, if the URL shown by the navigation bar is editable.
106 * @see KUrlNavigator
107 */
108 bool isUrlEditable() const;
109
110 inline const KUrlNavigator* urlNavigator() const;
111 inline KUrlNavigator* urlNavigator();
112
113 inline const DolphinView* view() const;
114 inline DolphinView* view();
115
116 /** Returns true, if the filter bar is visible. */
117 bool isFilterBarVisible() const;
118
119 /**
120 * Return the DolphinMainWindow this View belongs to. It is guaranteed
121 * that we have one.
122 */
123 inline const DolphinMainWindow* mainWindow() const;
124
125 public slots:
126 /**
127 * Popups the filter bar above the status bar if \a show is true.
128 */
129 void showFilterBar(bool show);
130
131 /**
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.
135 */
136 void updateStatusBar();
137
138 signals:
139 /**
140 * Is emitted whenever the filter bar has changed its visibility state.
141 */
142 void showFilterBarChanged(bool shown);
143
144 private slots:
145 void updateProgress(int percent);
146
147 /**
148 * Updates the number of items (= number of directories + number of files)
149 * and shows this information in the statusbar.
150 */
151 void updateItemCount();
152
153 /**
154 * Handles clicking on an item
155 */
156 void slotItemTriggered(const KFileItem& item);
157
158 /**
159 * Shows the information for the item \a item inside the statusbar. If the
160 * item is null, the default statusbar information is shown.
161 */
162 void showItemInfo(const KFileItem& item);
163
164 /** Shows the information \a msg inside the statusbar. */
165 void showInfoMessage(const QString& msg);
166
167 /** Shows the error message \a msg inside the statusbar. */
168 void showErrorMessage(const QString& msg);
169
170 void closeFilterBar();
171
172 /**
173 * Filters the currently shown items by \a nameFilter. All items
174 * which contain the given filter string will be shown.
175 */
176 void changeNameFilter(const QString& nameFilter);
177
178 /**
179 * Opens the context menu on the current mouse position.
180 * @item File item context. If item is 0, the context menu
181 * should be applied to \a url.
182 * @url URL which contains \a item.
183 */
184 void openContextMenu(const KFileItem& item, const KUrl& url);
185
186 /**
187 * Saves the position of the contents to the
188 * current history element.
189 */
190 void saveContentsPos(int x, int y);
191
192 /**
193 * Restores the contents position of the view, if the view
194 * is part of the history.
195 */
196 void restoreContentsPos();
197
198 /**
199 * Marks the view container as active
200 * (see DolphinViewContainer::setActive()).
201 */
202 void activate();
203
204 private:
205 /**
206 * Returns the default text of the status bar, if no item is
207 * selected.
208 */
209 QString defaultStatusBarText() const;
210
211 /**
212 * Returns the text for the status bar, if at least one item
213 * is selected.
214 */
215 QString selectionStatusBarText() const;
216
217 private:
218 bool m_showProgress;
219
220 int m_iconSize;
221 int m_folderCount;
222 int m_fileCount;
223
224 DolphinMainWindow* m_mainWindow;
225 QVBoxLayout* m_topLayout;
226 KUrlNavigator* m_urlNavigator;
227
228 DolphinView* m_view;
229
230 FilterBar* m_filterBar;
231 DolphinStatusBar* m_statusBar;
232
233 DolphinModel* m_dolphinModel;
234 DolphinDirLister* m_dirLister;
235 DolphinSortFilterProxyModel* m_proxyModel;
236 };
237
238 const DolphinStatusBar* DolphinViewContainer::statusBar() const
239 {
240 return m_statusBar;
241 }
242
243 DolphinStatusBar* DolphinViewContainer::statusBar()
244 {
245 return m_statusBar;
246 }
247
248 const KUrlNavigator* DolphinViewContainer::urlNavigator() const
249 {
250 return m_urlNavigator;
251 }
252
253 KUrlNavigator* DolphinViewContainer::urlNavigator()
254 {
255 return m_urlNavigator;
256 }
257
258 const DolphinView* DolphinViewContainer::view() const
259 {
260 return m_view;
261 }
262
263 DolphinView* DolphinViewContainer::view()
264 {
265 return m_view;
266 }
267
268 const DolphinMainWindow* DolphinViewContainer::mainWindow() const
269 {
270 return m_mainWindow;
271 }
272 #endif // DOLPHINVIEWCONTAINER_H