]>
cloud.milkyroute.net Git - dolphin.git/blob - src/urlnavigator.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 *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
22 #ifndef URLNAVIGATOR_H
23 #define URLNAVIGATOR_H
28 class KBookmarkManager
;
32 * @brief Navigation bar which contains the current shown URL.
34 * The URL navigator offers two modes:
35 * - Editable: Represents the 'classic' mode, where the current URL
36 * is editable inside a line editor.
37 * - Non editable: The URL is represented by a number of buttons, where
38 * clicking on a button results in activating the URL
39 * the button represents. This mode also supports drag
42 * The mode can be changed by a toggle button located on the left side of
45 * The URL navigator also remembers the URL history and allows to go
46 * back and forward within this history.
48 class UrlNavigator
: public QWidget
53 UrlNavigator(KBookmarkManager
* bookmarkManager
, const KUrl
& url
, QWidget
* parent
);
54 virtual ~UrlNavigator();
56 /** Returns the current active URL. */
57 const KUrl
& url() const;
59 /** Returns the portion of the current active URL up to the button at index. */
60 KUrl
url(int index
) const;
62 /** Returns the amount of items in the history */
63 int historySize() const;
65 /** Returns the saved position from the history */
66 QPoint
savedPosition() const;
69 * Goes back one step in the URL history. The signals
70 * UrlNavigator::urlChanged and UrlNavigator::historyChanged
76 * Goes forward one step in the URL history. The signals
77 * UrlNavigator::urlChanged and UrlNavigator::historyChanged
83 * Goes up one step of the URL path. The signals
84 * UrlNavigator::urlChanged and UrlNavigator::historyChanged
90 * Goes to the home URL. The signals UrlNavigator::urlChanged
91 * and UrlNavigator::historyChanged are submitted.
96 * Sets the home URL used by goHome().
98 void setHomeUrl(const QString
& homeUrl
);
101 * @return True, if the URL is editable by the user within a line editor.
102 * If false is returned, each part of the URL is presented by a button
103 * for fast navigation.
105 bool isUrlEditable() const;
108 * Allows to edit the URL of the navigation bar if \a editable
109 * is true, and sets the focus accordingly.
110 * If \a editable is false, each part of
111 * the URL is presented by a button for a fast navigation.
113 void setUrlEditable(bool editable
);
116 * Set the URL navigator to the active mode, if \a active
117 * is true. The active mode is default. Using the URL navigator
118 * in the inactive mode is useful when having split views,
119 * where the inactive view is indicated by an inactive URL
120 * navigator visually.
122 void setActive(bool active
);
125 * Returns true, if the URL navigator is in the active mode.
126 * @see UrlNavigator::setActive()
128 bool isActive() const;
131 * Sets whether or not to show hidden files in lists
133 void setShowHiddenFiles( bool show
);
136 * Returns true if the URL navigator is set to show hidden files
138 bool showHiddenFiles() const; // TODO rename, looks like a verb
141 * Handles the dropping of the URLs \a urls to the given
142 * destination \a destination and emits the signal urlsDropped.
144 void dropUrls(const KUrl::List
& urls
,
145 const KUrl
& destination
);
149 * Sets the current active URL.
150 * The signals UrlNavigator::urlChanged and UrlNavigator::historyChanged
153 void setUrl(const KUrl
& url
);
156 * Activates the URL navigator (UrlNavigator::isActive() will return true)
157 * and emits the signal 'activationChanged()'.
159 void requestActivation();
162 * Stores the coordinates of the contents into
163 * the current history element.
165 void storeContentsPosition(int x
, int y
);
169 * Is emitted, if the URL navigator has been activated by
170 * a user interaction.
175 * Is emitted, if the URL has been changed e. g. by
179 void urlChanged(const KUrl
& url
);
182 * Is emitted, if the history has been changed. Usually
183 * the history is changed if a new URL has been selected.
185 void historyChanged();
188 * Is emitted if the URLs \a urls have been dropped
189 * to the destination \a destination.
191 void urlsDropped(const KUrl::List
& urls
,
192 const KUrl
& destination
);
196 * If the Escape key is pressed, the navigation bar should switch
197 * to the browse mode.
199 virtual void keyReleaseEvent(QKeyEvent
* event
);
202 * Paste the clipboard content as URL, if the middle mouse
203 * button has been clicked.
205 virtual void mouseReleaseEvent(QMouseEvent
* event
);
208 Q_PRIVATE_SLOT(d
, void slotReturnPressed(const QString
& text
))
209 Q_PRIVATE_SLOT(d
, void slotRemoteHostActivated())
210 Q_PRIVATE_SLOT(d
, void slotProtocolChanged(const QString
& protocol
))
211 Q_PRIVATE_SLOT(d
, void switchView())
212 //Q_PRIVATE_SLOT(d, void slotRedirection(const KUrl&, const KUrl&))
218 Q_DISABLE_COPY( UrlNavigator
)