delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / apps / dolphin / src / dolphinviewcontainer.h
blobeb70c37e1aca5da2f010d50fd0841b7f44a89350
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 ***************************************************************************/
21 #ifndef DOLPHINVIEWCONTAINER_H
22 #define DOLPHINVIEWCONTAINER_H
24 #include "dolphinview.h"
26 #include <kfileitem.h>
27 #include <kfileitemdelegate.h>
28 #include <kio/job.h>
30 #include <kurlnavigator.h>
32 #include <QtGui/QKeyEvent>
33 #include <QtCore/QLinkedList>
34 #include <QtGui/QListView>
35 #include <QtGui/QBoxLayout>
36 #include <QtGui/QWidget>
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;
48 /**
49 * @short Represents a view for the directory content
50 * including the navigation bar, filter bar and status bar.
52 * View modes for icons, details and columns are supported. Currently
53 * Dolphin allows to have up to two views inside the main window.
55 * @see DolphinView
56 * @see FilterBar
57 * @see KUrlNavigator
58 * @see DolphinStatusBar
60 class DolphinViewContainer : public QWidget
62 Q_OBJECT
64 public:
65 DolphinViewContainer(DolphinMainWindow* mainwindow,
66 QWidget *parent,
67 const KUrl& url);
69 virtual ~DolphinViewContainer();
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()
78 void setUrl(const KUrl& url);
80 /**
81 * Returns the current active URL, where all actions are applied.
82 * The URL navigator is synchronized with this URL.
84 const KUrl& url() const;
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.
90 void setActive(bool active);
91 bool isActive() const;
93 const DolphinStatusBar* statusBar() const;
94 DolphinStatusBar* statusBar();
96 /**
97 * Returns true, if the URL shown by the navigation bar is editable.
98 * @see KUrlNavigator
100 bool isUrlEditable() const;
102 const KUrlNavigator* urlNavigator() const;
103 KUrlNavigator* urlNavigator();
105 const DolphinView* view() const;
106 DolphinView* view();
109 * Refreshes the view container to get synchronized with the (updated) Dolphin settings.
111 void refresh();
113 /** Returns true, if the filter bar is visible. */
114 bool isFilterBarVisible() const;
116 public slots:
118 * Popups the filter bar above the status bar if \a show is true.
120 void showFilterBar(bool show);
123 * Updates the number of items (= number of files + number of
124 * directories) in the statusbar. If files are selected, the number
125 * of selected files and the sum of the filesize is shown.
127 void updateStatusBar();
129 signals:
131 * Is emitted whenever the filter bar has changed its visibility state.
133 void showFilterBarChanged(bool shown);
135 private slots:
136 void updateProgress(int percent);
139 * Assures that the viewport position is restored and updates the
140 * statusbar to reflect the current content.
142 void slotDirListerCompleted();
145 * Handles clicking on an item. If the item is a directory, the
146 * directory is opened in the view. If the item is a file, the file
147 * gets started by the corresponding application.
149 void slotItemTriggered(const KFileItem& item);
152 * Opens a the file \a url by opening the corresponding application.
153 * Is connected with the signal urlIsFile() from DolphinDirLister and will
154 * get invoked if the user manually has entered a file into the URL navigator.
156 void openFile(const KUrl& url);
159 * Shows the information for the item \a item inside the statusbar. If the
160 * item is null, the default statusbar information is shown.
162 void showItemInfo(const KFileItem& item);
164 /** Shows the information \a msg inside the statusbar. */
165 void showInfoMessage(const QString& msg);
167 /** Shows the error message \a msg inside the statusbar. */
168 void showErrorMessage(const QString& msg);
170 /** Shows the "operation completed" message \a msg inside the statusbar. */
171 void showOperationCompletedMessage(const QString& msg);
173 void closeFilterBar();
176 * Filters the currently shown items by \a nameFilter. All items
177 * which contain the given filter string will be shown.
179 void setNameFilter(const QString& nameFilter);
182 * Opens the context menu on the current mouse position.
183 * @item File item context. If item is 0, the context menu
184 * should be applied to \a url.
185 * @url URL which contains \a item.
187 void openContextMenu(const KFileItem& item, const KUrl& url);
190 * Saves the position of the contents to the
191 * current history element.
193 void saveContentsPos(int x, int y);
196 * Restores the contents position of the view, if the view
197 * is part of the history.
199 void restoreContentsPos();
202 * Marks the view container as active
203 * (see DolphinViewContainer::setActive()).
205 void activate();
208 * Restores the current view to show \a url and assures
209 * that the root URL of the view is respected.
211 void restoreView(const KUrl& url);
214 * Saves the root URL of the current URL \a url
215 * into the URL navigator.
217 void saveRootUrl(const KUrl& url);
220 * Is connected with the URL navigator and drops the URLs
221 * above the destination \a destination.
223 void dropUrls(const KUrl& destination, QDropEvent* event);
226 * Is invoked when a redirection is done and changes the
227 * URL of the URL navigator to \a newUrl without triggering
228 * a reloading of the directory.
230 void redirect(const KUrl& oldUrl, const KUrl& newUrl);
232 /** Requests the focus for the view \a m_view. */
233 void requestFocus();
235 private:
236 bool m_showProgress;
238 DolphinMainWindow* m_mainWindow;
239 QVBoxLayout* m_topLayout;
240 KUrlNavigator* m_urlNavigator;
242 DolphinView* m_view;
244 FilterBar* m_filterBar;
245 DolphinStatusBar* m_statusBar;
247 DolphinModel* m_dolphinModel;
248 DolphinDirLister* m_dirLister;
249 DolphinSortFilterProxyModel* m_proxyModel;
252 inline const DolphinStatusBar* DolphinViewContainer::statusBar() const
254 return m_statusBar;
257 inline DolphinStatusBar* DolphinViewContainer::statusBar()
259 return m_statusBar;
262 inline const KUrlNavigator* DolphinViewContainer::urlNavigator() const
264 return m_urlNavigator;
267 inline KUrlNavigator* DolphinViewContainer::urlNavigator()
269 return m_urlNavigator;
272 inline const DolphinView* DolphinViewContainer::view() const
274 return m_view;
277 inline DolphinView* DolphinViewContainer::view()
279 return m_view;
282 #endif // DOLPHINVIEWCONTAINER_H