]> cloud.milkyroute.net Git - dolphin.git/blob - src/bookmarkselector.h
commited initial version of Dolphin
[dolphin.git] / src / bookmarkselector.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
3 * peter.penz@gmx.at *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #ifndef BOOKMARKSELECTOR_H
22 #define BOOKMARKSELECTOR_H
23
24 #include <kbookmark.h>
25 #include <urlbutton.h>
26 //Added by qt3to4:
27 #include <Q3PopupMenu>
28
29 class URLNavigator;
30 class Q3PopupMenu;
31 class KUrl;
32
33 /**
34 * @brief Allows to select a bookmark from a popup menu.
35 *
36 * The icon from the current selected bookmark is shown
37 * inside the bookmark selector.
38 *
39 * @see URLNavigator
40 * @author Peter Penz <peter.penz@gmx.at>
41 */
42 class BookmarkSelector : public URLButton
43 {
44 Q_OBJECT
45
46 public:
47 /**
48 * @param parent Parent widget where the bookmark selector
49 * is embedded into.
50 */
51 BookmarkSelector(URLNavigator* parent);
52
53 virtual ~BookmarkSelector();
54
55 /**
56 * Updates the selection dependent from the given URL \a url. The
57 * URL must not match exactly to one of the available bookmarks:
58 * The bookmark which is equal to the URL or at least is a parent URL
59 * is selected. If there are more than one possible parent URL candidates,
60 * the bookmark which covers the bigger range of the URL is selected.
61 */
62 void updateSelection(const KUrl& url);
63
64 /**
65 * Returns the index of the selected bookmark. To get
66 * the bookmark, use BookmarkSelector::selectedBookmark().
67 */
68 int selectedIndex() const { return m_selectedIndex; }
69
70 /** Returns the selected bookmark. */
71 KBookmark selectedBookmark() const;
72
73 signals:
74 /**
75 * Is send when a bookmark has been activated by the user.
76 * @param index Index of the selected bookmark.
77 */
78 void bookmarkActivated(int index);
79
80 protected:
81 /**
82 * Draws the icon of the selected URL as content of the URL
83 * selector.
84 */
85 virtual void drawButton(QPainter* painter);
86
87 private slots:
88 /**
89 * Updates the selected index and the icon if a bookmark
90 * has been activated by the user.
91 */
92 void slotBookmarkActivated(int index);
93
94 private:
95 int m_selectedIndex;
96 Q3PopupMenu* m_bookmarksMenu;
97
98 };
99
100 #endif