]>
cloud.milkyroute.net Git - dolphin.git/blob - src/kurlnavigator.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (<peter.penz@gmx.at>) *
3 * Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>) *
4 * Copyright (C) 2006 by Patrice Tremblay *
5 * Copyright (C) 2007 by Kevin Ottens (ervin@kde.org) *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
21 ***************************************************************************/
23 #ifndef KURLNAVIGATOR_H
24 #define KURLNAVIGATOR_H
29 class KFilePlacesModel
;
33 * @brief Navigation bar which contains the current shown URL.
35 * The URL navigator offers two modes:
36 * - Editable: Represents the 'classic' mode, where the current URL
37 * is editable inside a line editor.
38 * - Non editable: The URL is represented by a number of buttons, where
39 * clicking on a button results in activating the URL
40 * the button represents. This mode also supports drag
43 * The mode can be changed by a toggle button located on the left side of
46 * The URL navigator also remembers the URL history and allows to go
47 * back and forward within this history.
49 class KUrlNavigator
: public QWidget
54 KUrlNavigator(KFilePlacesModel
* placesModel
, const KUrl
& url
, QWidget
* parent
);
55 virtual ~KUrlNavigator();
57 /** Returns the current active URL. */
58 const KUrl
& url() const;
60 /** Returns the portion of the current active URL up to the button at index. */
61 KUrl
url(int index
) const;
63 /** Returns the amount of items in the history */
64 int historySize() const;
66 /** Returns the saved position from the history */
67 QPoint
savedPosition() const;
70 * Goes back one step in the URL history. The signals
71 * UrlNavigator::urlChanged and UrlNavigator::historyChanged
77 * Goes forward one step in the URL history. The signals
78 * UrlNavigator::urlChanged and UrlNavigator::historyChanged
84 * Goes up one step of the URL path. The signals
85 * UrlNavigator::urlChanged and UrlNavigator::historyChanged
91 * Goes to the home URL. The signals UrlNavigator::urlChanged
92 * and UrlNavigator::historyChanged are submitted.
97 * Sets the home URL used by goHome().
99 void setHomeUrl(const QString
& homeUrl
);
102 * @return True, if the URL is editable by the user within a line editor.
103 * If false is returned, each part of the URL is presented by a button
104 * for fast navigation.
106 bool isUrlEditable() const;
109 * Allows to edit the URL of the navigation bar if \a editable
110 * is true, and sets the focus accordingly.
111 * If \a editable is false, each part of
112 * the URL is presented by a button for a fast navigation.
114 void setUrlEditable(bool editable
);
117 * Set the URL navigator to the active mode, if \a active
118 * is true. The active mode is default. Using the URL navigator
119 * in the inactive mode is useful when having split views,
120 * where the inactive view is indicated by an inactive URL
121 * navigator visually.
123 void setActive(bool active
);
126 * Returns true, if the URL navigator is in the active mode.
127 * @see UrlNavigator::setActive()
129 bool isActive() const;
132 * Sets whether or not to show hidden files in lists
134 void setShowHiddenFiles( bool show
);
137 * Returns true if the URL navigator is set to show hidden files
139 bool showHiddenFiles() const; // TODO rename, looks like a verb
142 * Handles the dropping of the URLs \a urls to the given
143 * destination \a destination and emits the signal urlsDropped.
145 void dropUrls(const KUrl::List
& urls
,
146 const KUrl
& destination
);
150 * Sets the current active URL.
151 * The signals UrlNavigator::urlChanged and UrlNavigator::historyChanged
154 void setUrl(const KUrl
& url
);
157 * Activates the URL navigator (UrlNavigator::isActive() will return true)
158 * and emits the signal 'activationChanged()'.
160 void requestActivation();
163 * Stores the coordinates of the contents into
164 * the current history element.
166 void storeContentsPosition(int x
, int y
);
170 * Is emitted, if the URL navigator has been activated by
171 * a user interaction.
176 * Is emitted, if the URL has been changed e. g. by
180 void urlChanged(const KUrl
& url
);
183 * Is emitted, if the history has been changed. Usually
184 * the history is changed if a new URL has been selected.
186 void historyChanged();
189 * Is emitted if the URLs \a urls have been dropped
190 * to the destination \a destination.
192 void urlsDropped(const KUrl::List
& urls
,
193 const KUrl
& destination
);
197 * If the Escape key is pressed, the navigation bar should switch
198 * to the browse mode.
200 virtual void keyReleaseEvent(QKeyEvent
* event
);
203 * Paste the clipboard content as URL, if the middle mouse
204 * button has been clicked.
206 virtual void mouseReleaseEvent(QMouseEvent
* event
);
209 Q_PRIVATE_SLOT(d
, void slotReturnPressed(const QString
& text
))
210 Q_PRIVATE_SLOT(d
, void slotRemoteHostActivated())
211 Q_PRIVATE_SLOT(d
, void slotProtocolChanged(const QString
& protocol
))
212 Q_PRIVATE_SLOT(d
, void switchView())
213 //Q_PRIVATE_SLOT(d, void slotRedirection(const KUrl&, const KUrl&))
219 Q_DISABLE_COPY( KUrlNavigator
)