]> cloud.milkyroute.net Git - dolphin.git/blob - src/bookmarkssidebarpage.h
As KURL has been renamed to KUrl all classes and methods, which use the term 'URL...
[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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
19 #ifndef _BOOKMARKSSIDEBARPAGE_H_
20 #define _BOOKMARKSSIDEBARPAGE_H_
21
22 #include <sidebarpage.h>
23 #include <q3listbox.h>
24 //Added by qt3to4:
25 #include <QPaintEvent>
26 #include <QPixmap>
27
28 class KUrl;
29 class BookmarksListBox;
30
31 /**
32 * @brief Sidebar page for accessing bookmarks.
33 *
34 * It is possible to add, remove and edit bookmarks
35 * by a context menu. The selection of the bookmark
36 * is automatically adjusted to the Url given by
37 * the active view.
38 */
39 class BookmarksSidebarPage : public SidebarPage
40 {
41 Q_OBJECT
42
43 public:
44 BookmarksSidebarPage(QWidget* parent);
45 virtual ~BookmarksSidebarPage();
46
47 protected:
48 /** @see SidebarPage::activeViewChanged() */
49 virtual void activeViewChanged();
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 /**
65 * Is invoked whenever the Url of the active view has been changed. Adjusts
66 * the selection of the listbox to the bookmark which is part of the current Url.
67 */
68 void slotUrlChanged(const KUrl& url);
69
70 private:
71 /**
72 * Updates the selection dependent from the given Url \a url. The
73 * Url must not match exactly to one of the available bookmarks:
74 * The bookmark which is equal to the Url or at least is a parent Url
75 * is selected. If there are more than one possible parent Url candidates,
76 * the bookmark which covers the bigger range of the Url is selected.
77 */
78 void adjustSelection(const KUrl& url);
79
80 /**
81 * Connects to signals from the currently active Dolphin view to get
82 * informed about Url and bookmark changes.
83 */
84 void connectToActiveView();
85
86 BookmarksListBox* m_bookmarksList;
87 };
88
89 /**
90 * @brief Listbox which contains a list of bookmarks.
91 *
92 * Only QListBox::paintEvent() has been overwritten to prevent
93 * that a (not wanted) frameborder is drawn.
94 */
95 class BookmarksListBox : public Q3ListBox
96 {
97 Q_OBJECT
98
99 public:
100 BookmarksListBox(QWidget* parent);
101 virtual ~BookmarksListBox();
102
103 protected:
104 /** @see QWidget::paintEvent() */
105 virtual void paintEvent(QPaintEvent* event);
106 };
107
108 /**
109 * @brief Item which can be added to a BookmarksListBox.
110 *
111 * Only QListBoxPixmap::height() has been overwritten to get
112 * a spacing between the items.
113 */
114 class BookmarkItem : public Q3ListBoxPixmap
115 {
116 public:
117 BookmarkItem(const QPixmap& pixmap, const QString& text);
118 virtual ~BookmarkItem();
119 virtual int height(const Q3ListBox* listBox) const;
120 };
121
122 #endif // _BOOKMARKSSIDEBARPAGE_H_