1 | // -*- c-basic-offset:4; indent-tabs-mode:nil -*- |
2 | // vim: set ts=4 sts=4 sw=4 et: |
3 | /* This file is part of the KDE project |
4 | Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
5 | Copyright (C) 2006 Daniel Teske <teske@squorn.de> |
6 | |
7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef __kbookmarkmenu_h__ |
24 | #define __kbookmarkmenu_h__ |
25 | |
26 | #include <sys/types.h> |
27 | |
28 | #include <QtCore/QObject> |
29 | #include <QtCore/QStack> |
30 | |
31 | #include <klocale.h> |
32 | #include <kaction.h> |
33 | #include <kactionmenu.h> |
34 | #include <kicon.h> |
35 | #include <krun.h> |
36 | #include <kmenu.h> |
37 | |
38 | #include "kbookmark.h" |
39 | #include "kbookmarkmanager.h" |
40 | |
41 | class QString; |
42 | class ; |
43 | class KBookmark; |
44 | class KAction; |
45 | class QAction; |
46 | class ; |
47 | class KActionCollection; |
48 | class KBookmarkOwner; |
49 | class KBookmarkMenu; |
50 | class ; |
51 | class KBookmarkActionInterface; |
52 | |
53 | class ; // Not implemented |
54 | |
55 | namespace KIO { class Job; } |
56 | |
57 | /** |
58 | * This class provides a bookmark menu. It is typically used in |
59 | * cooperation with KActionMenu but doesn't have to be. |
60 | * |
61 | * If you use this class by itself, then it will use KDE defaults for |
62 | * everything -- the bookmark path, bookmark editor, bookmark launcher.. |
63 | * everything. These defaults reside in the classes |
64 | * KBookmarkOwner (editing bookmarks) and KBookmarkManager |
65 | * (almost everything else). If you wish to change the defaults in |
66 | * any way, you must reimplement either this class or KBookmarkOwner. |
67 | * |
68 | * Using this class is very simple: |
69 | * |
70 | * 1) Create a popup menu (either KActionMenu or KMenu will do) |
71 | * 2) Instantiate a new KBookmarkMenu object using the above popup |
72 | * menu as a parameter |
73 | * 3) Insert your (now full) popup menu wherever you wish |
74 | * |
75 | */ |
76 | class KIO_EXPORT : public QObject |
77 | { |
78 | Q_OBJECT |
79 | public: |
80 | /** |
81 | * Fills a bookmark menu |
82 | * (one instance of KBookmarkMenu is created for the toplevel menu, |
83 | * but also one per submenu). |
84 | * |
85 | * @param mgr The bookmark manager to use (i.e. for reading and writing) |
86 | * @param owner implementation of the KBookmarkOwner callback interface. |
87 | * Note: If you pass a null KBookmarkOwner to the constructor, the |
88 | * openBookmark signal is not emitted, instead KRun is used to open the bookmark. |
89 | * @param parentMenu menu to be filled |
90 | * @param collec parent collection for the KActions. |
91 | * |
92 | * @todo KDE 5: give ownership of the bookmarkmenu to another qobject, e.g. parentMenu. |
93 | * Currently this is a QObject without a parent, use setParent to benefit from automatic deletion. |
94 | */ |
95 | ( KBookmarkManager* mgr, KBookmarkOwner * owner, KMenu * , KActionCollection *collec); |
96 | |
97 | /** |
98 | * Creates a bookmark submenu |
99 | * |
100 | * @todo KDE 5: give ownership of the bookmarkmenu to another qobject, e.g. parentMenu. |
101 | * Currently this is a QObject without a parent, use setParent to benefit from automatic deletion. |
102 | */ |
103 | ( KBookmarkManager* mgr, KBookmarkOwner * owner, |
104 | KMenu * , const QString & parentAddress); |
105 | |
106 | (); |
107 | |
108 | /** |
109 | * Call ensureUpToDate() if you need KBookmarkMenu to adjust to its |
110 | * final size before it is executed. |
111 | **/ |
112 | void (); |
113 | |
114 | public Q_SLOTS: |
115 | // public for KonqBookmarkBar |
116 | void ( const QString & ); |
117 | |
118 | protected Q_SLOTS: |
119 | void (); |
120 | void (); |
121 | void (); |
122 | void (); |
123 | void (); |
124 | |
125 | protected: |
126 | virtual void (); |
127 | virtual void (); |
128 | virtual QAction* (const KBookmark &bm); |
129 | virtual KMenu * (QAction * action ); |
130 | |
131 | void (); |
132 | void (); |
133 | void (); |
134 | void (); |
135 | void (); |
136 | void (); |
137 | void (); |
138 | |
139 | |
140 | bool () const; |
141 | bool () const; |
142 | |
143 | /** |
144 | * Parent bookmark for this menu. |
145 | */ |
146 | QString () const; |
147 | |
148 | KBookmarkManager * () const; |
149 | KBookmarkOwner * () const; |
150 | /** |
151 | * The menu in which we insert our actions |
152 | * Supplied in the constructor. |
153 | */ |
154 | KMenu * () const; |
155 | |
156 | /** |
157 | * List of our sub menus |
158 | */ |
159 | QList<KBookmarkMenu *> ; |
160 | |
161 | // This is used to "export" our actions into an actionlist |
162 | // we got in the constructor. So that the program can show our |
163 | // actions in their shortcut dialog |
164 | KActionCollection * ; |
165 | /** |
166 | * List of our actions. |
167 | */ |
168 | QList<QAction *> ; |
169 | |
170 | |
171 | private Q_SLOTS: |
172 | void ( const QPoint & ); |
173 | |
174 | private: |
175 | KBookmarkMenuPrivate* ; |
176 | |
177 | bool ; |
178 | bool ; |
179 | KBookmarkManager * ; |
180 | KBookmarkOwner * ; |
181 | |
182 | KMenu * ; |
183 | |
184 | private: |
185 | QString ; |
186 | }; |
187 | |
188 | class KIO_EXPORT : public KMenu |
189 | { |
190 | Q_OBJECT |
191 | |
192 | public: |
193 | (const KBookmark & bm, KBookmarkManager * manager, KBookmarkOwner *owner, QWidget * parent = 0); |
194 | virtual (); |
195 | virtual void (); |
196 | |
197 | public Q_SLOTS: |
198 | void (); |
199 | void (); |
200 | void (); |
201 | void (); |
202 | void (); |
203 | void (); |
204 | |
205 | protected: |
206 | void (); |
207 | void (); |
208 | void (); |
209 | void (); |
210 | void (); |
211 | |
212 | KBookmarkManager * () const; |
213 | KBookmarkOwner * () const; |
214 | KBookmark () const; |
215 | |
216 | private Q_SLOTS: |
217 | void (); |
218 | |
219 | private: |
220 | KBookmark ; |
221 | KBookmarkManager * ; |
222 | KBookmarkOwner * ; |
223 | }; |
224 | |
225 | class KIO_EXPORT KBookmarkActionInterface |
226 | { |
227 | public: |
228 | KBookmarkActionInterface(const KBookmark &bk); |
229 | virtual ~KBookmarkActionInterface(); |
230 | const KBookmark bookmark() const; |
231 | private: |
232 | KBookmark bm; |
233 | }; |
234 | |
235 | /*** |
236 | * A wrapper around KActionMenu to provide a nice constructor for bookmark groups. |
237 | * |
238 | */ |
239 | |
240 | class KIO_EXPORT : public KActionMenu, public KBookmarkActionInterface |
241 | { |
242 | public: |
243 | (const KBookmark &bm, QObject *parent); |
244 | (const KBookmark &bm, const QString & text, QObject *parent); |
245 | virtual (); |
246 | }; |
247 | |
248 | /*** |
249 | * This class is a KAction for bookmarks. |
250 | * It provides a nice constructor. |
251 | * And on triggered uses the owner to open the bookmark. |
252 | * |
253 | */ |
254 | |
255 | class KIO_EXPORT KBookmarkAction : public KAction, public KBookmarkActionInterface |
256 | { |
257 | Q_OBJECT |
258 | public: |
259 | KBookmarkAction(const KBookmark &bk, KBookmarkOwner* owner, QObject *parent); |
260 | virtual ~KBookmarkAction(); |
261 | |
262 | public Q_SLOTS: |
263 | void slotSelected(Qt::MouseButtons mb, Qt::KeyboardModifiers km); |
264 | |
265 | private: |
266 | KBookmarkOwner* m_pOwner; |
267 | }; |
268 | |
269 | #endif |
270 | |