1 /***************************************************************************
2 * Copyright (C) 2006 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 ***************************************************************************/
20 #ifndef BOOKMARKSELECTOR_H
21 #define BOOKMARKSELECTOR_H
23 #include <kbookmark.h>
24 #include <urlbutton.h>
31 * @brief Allows to select a bookmark from a popup menu.
33 * The icon from the current selected bookmark is shown
34 * inside the bookmark selector.
38 class BookmarkSelector
: public UrlButton
44 * @param parent Parent widget where the bookmark selector
47 BookmarkSelector(UrlNavigator
* parent
, KBookmarkManager
* bookmarkManager
);
49 virtual ~BookmarkSelector();
52 * Updates the selection dependent from the given URL \a url. The
53 * URL must not match exactly to one of the available bookmarks:
54 * The bookmark which is equal to the URL or at least is a parent URL
55 * is selected. If there are more than one possible parent URL candidates,
56 * the bookmark which covers the bigger range of the URL is selected.
58 void updateSelection(const KUrl
& url
);
60 /** Returns the selected bookmark. */
61 KBookmark
selectedBookmark() const;
63 /** @see QWidget::sizeHint() */
64 virtual QSize
sizeHint() const;
68 * Is send when a bookmark has been activated by the user.
69 * @param url URL of the selected bookmark.
71 void bookmarkActivated(const KUrl
& url
);
75 * Draws the icon of the selected Url as content of the Url
78 virtual void paintEvent(QPaintEvent
* event
);
82 * Updates the selected index and the icon to the bookmark
83 * which is indicated by the triggered action \a action.
85 void activateBookmark(QAction
* action
);
88 QString m_selectedAddress
;
89 UrlNavigator
* m_urlNavigator
;
90 KMenu
* m_bookmarksMenu
;
91 KBookmarkManager
* m_bookmarkManager
;