]> cloud.milkyroute.net Git - dolphin.git/blob - src/bookmarkselector.h
use flat buttons for the information sidebar page (TODO: this code has been duplicate...
[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 /** @see QWidget::sizeHint() */
74 virtual QSize sizeHint() const;
75
76 signals:
77 /**
78 * Is send when a bookmark has been activated by the user.
79 * @param index Index of the selected bookmark.
80 */
81 void bookmarkActivated(int index);
82
83 protected:
84 /**
85 * Draws the icon of the selected Url as content of the Url
86 * selector.
87 */
88 virtual void paintEvent(QPaintEvent* event);
89
90 private slots:
91 /**
92 * Updates the selected index and the icon if a bookmark
93 * has been activated by the user.
94 */
95 void slotBookmarkActivated(int index);
96
97 private:
98 int m_selectedIndex;
99 Q3PopupMenu* m_bookmarksMenu;
100
101 };
102
103 #endif