]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewcontainer.h
Adapt Dolphin Nepomuk support to namespace changes.
[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 <kparts/part.h>
27 #include <kfileitem.h>
28 #include <kfileitemdelegate.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 DolphinController;
40 class FilterBar;
41 class KFileItemDelegate;
42 class KUrl;
43 class KDirModel;
44 class KUrlNavigator;
45 class DolphinColumnView;
46 class DolphinDetailsView;
47 class DolphinDirLister;
48 class DolphinIconsView;
49 class DolphinMainWindow;
50 class DolphinSortFilterProxyModel;
51 class DolphinStatusBar;
52 class QModelIndex;
53 class ViewProperties;
54
55 /**
56 * @short Represents a view for the directory content
57 * including the navigation bar, filter bar and status bar.
58 *
59 * View modes for icons, details and columns are supported. Currently
60 * Dolphin allows to have up to two views inside the main window.
61 *
62 * @see DolphinView
63 * @see FilterBar
64 * @see KUrlNavigator
65 * @see DolphinStatusBar
66 */
67 class DolphinViewContainer : public QWidget
68 {
69 Q_OBJECT
70
71 public:
72 DolphinViewContainer(DolphinMainWindow* mainwindow,
73 QWidget *parent,
74 const KUrl& url,
75 DolphinView::Mode mode = DolphinView::IconsView,
76 bool showHiddenFiles = false);
77
78 virtual ~DolphinViewContainer();
79
80 /**
81 * Sets the current active URL, where all actions are applied. The
82 * URL navigator is synchronized with this URL. The signals
83 * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
84 * are emitted.
85 * @see DolphinViewContainer::urlNavigator()
86 */
87 void setUrl(const KUrl& url);
88
89 /**
90 * Returns the current active URL, where all actions are applied.
91 * The URL navigator is synchronized with this URL.
92 */
93 const KUrl& url() const;
94
95 /**
96 * If \a active is true, the view container will marked as active. The active
97 * view container is defined as view where all actions are applied to.
98 */
99 void setActive(bool active);
100 bool isActive() const;
101
102 /**
103 * Triggers the renaming of the currently selected items, where
104 * the user must input a new name for the items.
105 */
106 void renameSelectedItems();
107
108 KFileItem* fileItem(const QModelIndex index) const;
109
110 DolphinStatusBar* statusBar() const;
111
112 /**
113 * Returns true, if the URL shown by the navigation bar is editable.
114 * @see KUrlNavigator
115 */
116 bool isUrlEditable() const;
117
118 inline KUrlNavigator* urlNavigator() const;
119
120 inline DolphinView* view() const;
121
122 /** Returns true, if the filter bar is visible. */
123 bool isFilterBarVisible() const;
124
125 /**
126 * Return the DolphinMainWindow this View belongs to. It is guaranteed
127 * that we have one.
128 */
129 DolphinMainWindow* mainWindow() const ;
130
131 public slots:
132 /**
133 * Popups the filter bar above the status bar if \a show is true.
134 */
135 void showFilterBar(bool show);
136
137 /**
138 * Updates the number of items (= number of files + number of
139 * directories) in the statusbar. If files are selected, the number
140 * of selected files and the sum of the filesize is shown.
141 */
142 void updateStatusBar();
143
144 signals:
145 /**
146 * Is emitted whenever the filter bar has changed its visibility state.
147 */
148 void showFilterBarChanged(bool shown);
149
150 private slots:
151 void updateProgress(int percent);
152
153 /**
154 * Updates the number of items (= number of directories + number of files)
155 * and shows this information in the statusbar.
156 */
157 void updateItemCount();
158
159 /**
160 * Shows the item information for the URL \a url inside the statusbar. If the
161 * URL is empty, the default statusbar information is shown.
162 */
163 void showItemInfo(const KUrl& url);
164
165 /** Shows the information \a msg inside the statusbar. */
166 void showInfoMessage(const QString& msg);
167
168 /** Shows the error message \a msg inside the statusbar. */
169 void showErrorMessage(const QString& msg);
170
171 void closeFilterBar();
172
173 /**
174 * Filters the currently shown items by \a nameFilter. All items
175 * which contain the given filter string will be shown.
176 */
177 void changeNameFilter(const QString& nameFilter);
178
179 /**
180 * Opens the context menu on the current mouse postition.
181 * @item File item context. If item is 0, the context menu
182 * should be applied to \a url.
183 * @url URL which contains \a item.
184 */
185 void openContextMenu(KFileItem* item, const KUrl& url);
186
187 /**
188 * Saves the position of the contents to the
189 * current history element.
190 */
191 void saveContentsPos(int x, int y);
192
193 /**
194 * Restores the contents position of the view, if the view
195 * is part of the history.
196 */
197 void restoreContentsPos();
198
199 private:
200 /**
201 * Returns the default text of the status bar, if no item is
202 * selected.
203 */
204 QString defaultStatusBarText() const;
205
206 /**
207 * Returns the text for the status bar, if at least one item
208 * is selected.
209 */
210 QString selectionStatusBarText() const;
211
212 private:
213 bool m_showProgress;
214
215 int m_iconSize;
216 int m_folderCount;
217 int m_fileCount;
218
219 DolphinMainWindow* m_mainWindow;
220 QVBoxLayout* m_topLayout;
221 KUrlNavigator* m_urlNavigator;
222
223 DolphinView* m_view;
224
225 FilterBar* m_filterBar;
226 DolphinStatusBar* m_statusBar;
227
228 KDirModel* m_dirModel;
229 DolphinDirLister* m_dirLister;
230 DolphinSortFilterProxyModel* m_proxyModel;
231 };
232
233 KUrlNavigator* DolphinViewContainer::urlNavigator() const
234 {
235 return m_urlNavigator;
236 }
237
238 DolphinView* DolphinViewContainer::view() const
239 {
240 return m_view;
241 }
242
243 #endif // DOLPHINVIEWCONTAINER_H