1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/***************************************************************************
* Copyright (C) 2006 by Peter Penz <[email protected]>
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef _BOOKMARKSSIDEBARPAGE_H_
#define _BOOKMARKSSIDEBARPAGE_H_
#include <sidebarpage.h>
#include <tqlistbox.h>
#include <kurl.h>
#include <kbookmark.h>
#include <kiconloader.h>
class BookmarksListBox;
/**
* @brief Sidebar page for accessing bookmarks.
*
* It is possible to add, remove and edit bookmarks
* by a context menu. The selection of the bookmark
* is automatically adjusted to the URL given by
* the active view.
*/
class BookmarksSidebarPage : public SidebarPage
{
Q_OBJECT
TQ_OBJECT
public:
BookmarksSidebarPage(TQWidget* tqparent);
virtual ~BookmarksSidebarPage();
protected:
/** @see SidebarPage::activeViewChanged() */
virtual void activeViewChanged();
private slots:
/** Fills the listbox with the bookmarks stored in DolphinSettings. */
void updateBookmarks();
/**
* Checks whether the left mouse button has been clicked above a bookmark.
* If this is the case, the URL for the currently active view is adjusted.
*/
void slotMouseButtonClicked(int button, TQListBoxItem* item);
/** @see TQListBox::slotContextMenuRequested */
void slotContextMenuRequested(TQListBoxItem* item, const TQPoint& pos);
/**
* Is invoked whenever the URL of the active view has been changed. Adjusts
* the selection of the listbox to the bookmark which is part of the current URL.
*/
void slotURLChanged(const KURL& url);
private:
/**
* Updates the selection dependent from the given URL \a url. The
* URL must not match exactly to one of the available bookmarks:
* The bookmark which is equal to the URL or at least is a tqparent URL
* is selected. If there are more than one possible tqparent URL candidates,
* the bookmark which covers the bigger range of the URL is selected.
*/
void adjustSelection(const KURL& url);
/**
* Connects to signals from the currently active Dolphin view to get
* informed about URL and bookmark changes.
*/
void connectToActiveView();
BookmarksListBox* m_bookmarksList;
};
/**
* @brief Listbox which contains a list of bookmarks.
*
* Only TQListBox::paintEvent() has been overwritten to prevent
* that a (not wanted) frameborder is drawn.
*/
class BookmarksListBox : public TQListBox
{
Q_OBJECT
TQ_OBJECT
public:
BookmarksListBox(TQWidget* tqparent);
virtual ~BookmarksListBox();
protected:
//drag
void contentsMousePressEvent(TQMouseEvent *event);
void contentsMouseMoveEvent(TQMouseEvent *event);
//drop
void dragEnterEvent( TQDragEnterEvent *evt );
void dropEvent( TQDropEvent *evt );
// void mousePressEvent( TQMouseEvent *evt );
// void mouseMoveEvent( TQMouseEvent * );
/** @see TQWidget::paintEvent() */
virtual void paintEvent(TQPaintEvent* event);
private:
TQPoint dragPos;
void startDrag();
};
/**
* @brief Item which can be added to a BookmarksListBox.
*
* Only TQListBoxPixmap::height() has been overwritten to get
* a spacing between the items.
*/
class BookmarkItem : public TQListBoxPixmap
{
public:
BookmarkItem(const TQPixmap& pixmap, const TQString& text, const KURL& url);
virtual ~BookmarkItem();
virtual int height(const TQListBox* listBox) const;
const KURL& url() const;
static BookmarkItem* fromKbookmark(const KBookmark& bookmark, const KIconLoader& iconLoader);
private:
KURL m_url;
};
#endif // _BOOKMARKSSIDEBARPAGE_H_
|