]>
cloud.milkyroute.net Git - dolphin.git/blob - src/bookmarkssidebarpage.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
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. *
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. *
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_
22 #include <sidebarpage.h>
23 #include <q3listbox.h>
25 #include <QPaintEvent>
29 class BookmarksListBox
;
32 * @brief Sidebar page for accessing bookmarks.
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
39 class BookmarksSidebarPage
: public SidebarPage
44 BookmarksSidebarPage(DolphinMainWindow
*mainWindow
, QWidget
* parent
=0);
45 virtual ~BookmarksSidebarPage();
48 /** @see SidebarPage::activeViewChanged() */
49 virtual void activeViewChanged();
52 /** Fills the listbox with the bookmarks stored in DolphinSettings. */
53 void updateBookmarks();
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.
59 void slotMouseButtonClicked(int button
, Q3ListBoxItem
* item
);
61 /** @see QListBox::slotContextMenuRequested */
62 void slotContextMenuRequested(Q3ListBoxItem
* item
, const QPoint
& pos
);
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.
68 void slotUrlChanged(const KUrl
& url
);
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.
78 void adjustSelection(const KUrl
& url
);
81 * Connects to signals from the currently active Dolphin view to get
82 * informed about Url and bookmark changes.
84 void connectToActiveView();
86 BookmarksListBox
* m_bookmarksList
;
90 * @brief Listbox which contains a list of bookmarks.
92 * Only QListBox::paintEvent() has been overwritten to prevent
93 * that a (not wanted) frameborder is drawn.
95 class BookmarksListBox
: public Q3ListBox
100 BookmarksListBox(QWidget
* parent
);
101 virtual ~BookmarksListBox();
104 /** @see QWidget::paintEvent() */
105 virtual void paintEvent(QPaintEvent
* event
);
109 * @brief Item which can be added to a BookmarksListBox.
111 * Only QListBoxPixmap::height() has been overwritten to get
112 * a spacing between the items.
114 class BookmarkItem
: public Q3ListBoxPixmap
117 BookmarkItem(const QPixmap
& pixmap
, const QString
& text
);
118 virtual ~BookmarkItem();
119 virtual int height(const Q3ListBox
* listBox
) const;
122 #endif // _BOOKMARKSSIDEBARPAGE_H_