]> cloud.milkyroute.net Git - dolphin.git/blob - src/bookmarkselector.h
don't trigger an item if the user does a selection by using the control- or shift...
[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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef BOOKMARKSELECTOR_H
22 #define BOOKMARKSELECTOR_H
23
24 #include <kbookmark.h>
25 #include <urlbutton.h>
26
27 class UrlNavigator;
28 class Q3PopupMenu;
29 class KUrl;
30
31 /**
32 * @brief Allows to select a bookmark from a popup menu.
33 *
34 * The icon from the current selected bookmark is shown
35 * inside the bookmark selector.
36 *
37 * @see UrlNavigator
38 * @author Peter Penz <peter.penz@gmx.at>
39 */
40 class BookmarkSelector : public UrlButton
41 {
42 Q_OBJECT
43
44 public:
45 /**
46 * @param parent Parent widget where the bookmark selector
47 * is embedded into.
48 */
49 BookmarkSelector(UrlNavigator* parent);
50
51 virtual ~BookmarkSelector();
52
53 /**
54 * Updates the selection dependent from the given Url \a url. The
55 * Url must not match exactly to one of the available bookmarks:
56 * The bookmark which is equal to the Url or at least is a parent Url
57 * is selected. If there are more than one possible parent Url candidates,
58 * the bookmark which covers the bigger range of the Url is selected.
59 */
60 void updateSelection(const KUrl& url);
61
62 /**
63 * Returns the index of the selected bookmark. To get
64 * the bookmark, use BookmarkSelector::selectedBookmark().
65 */
66 int selectedIndex() const { return m_selectedIndex; }
67
68 /** Returns the selected bookmark. */
69 KBookmark selectedBookmark() const;
70
71 /** @see QWidget::sizeHint() */
72 virtual QSize sizeHint() const;
73
74 signals:
75 /**
76 * Is send when a bookmark has been activated by the user.
77 * @param index Index of the selected bookmark.
78 */
79 void bookmarkActivated(int index);
80
81 protected:
82 /**
83 * Draws the icon of the selected Url as content of the Url
84 * selector.
85 */
86 virtual void paintEvent(QPaintEvent* event);
87
88 private slots:
89 /**
90 * Updates the selected index and the icon if a bookmark
91 * has been activated by the user.
92 */
93 void slotBookmarkActivated(int index);
94
95 private:
96 int m_selectedIndex;
97 Q3PopupMenu* m_bookmarksMenu;
98
99 };
100
101 #endif