1 /***************************************************************************
2 * Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
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. *
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. *
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 <kglobalsettings.h>
31 #include <kurlnavigator.h>
33 #include <QtGui/QKeyEvent>
34 #include <QtCore/QLinkedList>
35 #include <QtGui/QListView>
36 #include <QtGui/QBoxLayout>
37 #include <QtGui/QWidget>
43 class DolphinDirLister
;
44 class DolphinSortFilterProxyModel
;
45 class DolphinStatusBar
;
48 * @short Represents a view for the directory content
49 * including the navigation bar, filter bar and status bar.
51 * View modes for icons, details and columns are supported. Currently
52 * Dolphin allows to have up to two views inside the main window.
57 * @see DolphinStatusBar
59 class DolphinViewContainer
: public QWidget
64 DolphinViewContainer(const KUrl
& url
, QWidget
* parent
);
65 virtual ~DolphinViewContainer();
68 * Returns the current active URL, where all actions are applied.
69 * The URL navigator is synchronized with this URL.
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.
77 void setActive(bool active
);
78 bool isActive() const;
80 const DolphinStatusBar
* statusBar() const;
81 DolphinStatusBar
* statusBar();
83 const KUrlNavigator
* urlNavigator() const;
84 KUrlNavigator
* urlNavigator();
86 const DolphinView
* view() const;
90 * Refreshes the view container to get synchronized with the (updated) Dolphin settings.
94 /** Returns true, if the filter bar is visible. */
95 bool isFilterBarVisible() const;
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()
103 * @see DolphinViewContainer::urlNavigator()
105 void setUrl(const KUrl
& url
);
108 * Popups the filter bar above the status bar if \a show is true.
110 void showFilterBar(bool show
);
114 * Is emitted whenever the filter bar has changed its visibility state.
116 void showFilterBarChanged(bool shown
);
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
123 void writeStateChanged(bool isFolderWritable
);
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.
133 void delayedStatusBarUpdate();
136 * Is invoked by DolphinViewContainer::delayedStatusBarUpdate() and
137 * updates the status bar synchronously.
139 void updateStatusBar();
141 void initializeProgress();
143 void updateProgress(int percent
);
146 * Assures that the viewport position is restored and updates the
147 * statusbar to reflect the current content.
149 void slotDirListerCompleted();
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.
156 void slotItemTriggered(const KFileItem
& item
);
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.
163 void openFile(const KUrl
& url
);
166 * Shows the information for the item \a item inside the statusbar. If the
167 * item is null, the default statusbar information is shown.
169 void showItemInfo(const KFileItem
& item
);
171 /** Shows the information \a msg inside the statusbar. */
172 void showInfoMessage(const QString
& msg
);
174 /** Shows the error message \a msg inside the statusbar. */
175 void showErrorMessage(const QString
& msg
);
177 /** Shows the "operation completed" message \a msg inside the statusbar. */
178 void showOperationCompletedMessage(const QString
& msg
);
180 void closeFilterBar();
183 * Filters the currently shown items by \a nameFilter. All items
184 * which contain the given filter string will be shown.
186 void setNameFilter(const QString
& nameFilter
);
188 void restoreViewState();
191 * Marks the view container as active
192 * (see DolphinViewContainer::setActive()).
197 * Saves the state of the current view: contents position,
200 void saveViewState();
203 * Restores the current view to show \a url and assures
204 * that the root URL of the view is respected.
206 void slotUrlNavigatorLocationChanged(const KUrl
& url
);
209 * Is connected with the URL navigator and drops the URLs
210 * above the destination \a destination.
212 void dropUrls(const KUrl
& destination
, QDropEvent
* event
);
215 * Is invoked when a redirection is done and changes the
216 * URL of the URL navigator to \a newUrl without triggering
217 * a reloading of the directory.
219 void redirect(const KUrl
& oldUrl
, const KUrl
& newUrl
);
221 /** Requests the focus for the view \a m_view. */
225 * Saves the currently used URL completion mode of
228 void saveUrlCompletionMode(KGlobalSettings::Completion completion
);
230 void slotHistoryChanged();
233 bool m_isFolderWritable
;
235 QVBoxLayout
* m_topLayout
;
236 KUrlNavigator
* m_urlNavigator
;
240 FilterBar
* m_filterBar
;
242 DolphinStatusBar
* m_statusBar
;
243 QTimer
* m_statusBarTimer
;
245 DolphinModel
* m_dolphinModel
;
246 DolphinDirLister
* m_dirLister
;
247 DolphinSortFilterProxyModel
* m_proxyModel
;
250 inline const DolphinStatusBar
* DolphinViewContainer::statusBar() const
255 inline DolphinStatusBar
* DolphinViewContainer::statusBar()
260 inline const KUrlNavigator
* DolphinViewContainer::urlNavigator() const
262 return m_urlNavigator
;
265 inline KUrlNavigator
* DolphinViewContainer::urlNavigator()
267 return m_urlNavigator
;
270 inline const DolphinView
* DolphinViewContainer::view() const
275 inline DolphinView
* DolphinViewContainer::view()
280 #endif // DOLPHINVIEWCONTAINER_H