]> cloud.milkyroute.net Git - dolphin.git/blob - src/bookmarkssidebarpage.h
adaptions to the cleaned up interface of KUrlNavigator
[dolphin.git] / src / bookmarkssidebarpage.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
3 * *
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. *
8 * *
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. *
13 * *
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 ***************************************************************************/
19 #ifndef _BOOKMARKSSIDEBARPAGE_H_
20 #define _BOOKMARKSSIDEBARPAGE_H_
21
22 #include <q3listbox.h>
23 //Added by qt3to4:
24 #include <QPaintEvent>
25 #include <QPixmap>
26
27 #include "sidebarpage.h"
28
29 class KUrl;
30 class BookmarksListBox;
31
32 /**
33 * @brief Sidebar page for accessing bookmarks.
34 *
35 * It is possible to add, remove and edit bookmarks
36 * by a context menu. The selection of the bookmark
37 * is automatically adjusted to the Url given by
38 * the active view.
39 */
40 class BookmarksSidebarPage : public SidebarPage
41 {
42 Q_OBJECT
43
44 public:
45 BookmarksSidebarPage(QWidget* parent=0);
46 virtual ~BookmarksSidebarPage();
47
48 public slots:
49 void setUrl(const KUrl& url);
50
51 private slots:
52 /** Fills the listbox with the bookmarks stored in DolphinSettings. */
53 void updateBookmarks();
54
55 /**
56 * Checks whether the left mouse button has been clicked above a bookmark.
57 * If this is the case, the Url for the currently active view is adjusted.
58 */
59 void slotMouseButtonClicked(int button, Q3ListBoxItem* item);
60
61 /** @see QListBox::slotContextMenuRequested */
62 void slotContextMenuRequested(Q3ListBoxItem* item, const QPoint& pos);
63
64 private:
65 /**
66 * Updates the selection dependent from the given Url \a url. The
67 * Url must not match exactly to one of the available bookmarks:
68 * The bookmark which is equal to the Url or at least is a parent Url
69 * is selected. If there are more than one possible parent Url candidates,
70 * the bookmark which covers the bigger range of the Url is selected.
71 */
72 void adjustSelection(const KUrl& url);
73
74 BookmarksListBox* m_bookmarksList;
75 };
76
77 /**
78 * @brief Listbox which contains a list of bookmarks.
79 *
80 * Only QListBox::paintEvent() has been overwritten to prevent
81 * that a (not wanted) frameborder is drawn.
82 */
83 class BookmarksListBox : public Q3ListBox
84 {
85 Q_OBJECT
86
87 public:
88 BookmarksListBox(QWidget* parent);
89 virtual ~BookmarksListBox();
90
91 protected:
92 /** @see QWidget::paintEvent() */
93 virtual void paintEvent(QPaintEvent* event);
94 };
95
96 /**
97 * @brief Item which can be added to a BookmarksListBox.
98 *
99 * Only QListBoxPixmap::height() has been overwritten to get
100 * a spacing between the items.
101 */
102 class BookmarkItem : public Q3ListBoxPixmap
103 {
104 public:
105 BookmarkItem(const QPixmap& pixmap, const QString& text);
106 virtual ~BookmarkItem();
107 virtual int height(const Q3ListBox* listBox) const;
108 };
109
110 #endif // _BOOKMARKSSIDEBARPAGE_H_