summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kactioncollection.h
Unidiff
Diffstat (limited to 'microkde/kdeui/kactioncollection.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kactioncollection.h329
1 files changed, 329 insertions, 0 deletions
diff --git a/microkde/kdeui/kactioncollection.h b/microkde/kdeui/kactioncollection.h
new file mode 100644
index 0000000..b9466d0
--- a/dev/null
+++ b/microkde/kdeui/kactioncollection.h
@@ -0,0 +1,329 @@
1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public
12 License version 2 as published by the Free Software Foundation.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.
23*/
24//$Id$
25
26#ifndef __kactioncollection_h__
27#define __kactioncollection_h__
28
29#include <kaction.h>
30
31//US #include <qkeysequence.h>
32#include <qobject.h>
33//US#include <qvaluelist.h>
34//US#include <qguardedptr.h>
35//US #include <kguiitem.h>
36//US#include <kshortcut.h>
37//US#include <kstdaction.h>
38//US#include <kicontheme.h>
39
40//USclass QMenuBar;
41//USclass QPopupMenu;
42//USclass QComboBox;
43//USclass QPoint;
44//USclass QIconSet;
45//USclass QString;
46//USclass KToolBar;
47
48//USclass KAccel;
49//USclass KAccelActions;
50//USclass KConfig;
51//USclass KConfigBase;
52//USclass KURL;
53//USclass KInstance;
54//USclass KToolBar;
55//USclass KActionCollection;
56//USclass KPopupMenu;
57//USclass KMainWindow;
58
59//US added inclidefiles
60class QWidget;
61
62
63typedef QValueList<KAction *> KActionPtrList;
64
65/**
66 * A managed set of KAction objects.
67 */
68class KActionCollection : public QObject
69{
70 friend class KAction;
71 friend class KXMLGUIClient;
72
73 Q_OBJECT
74public:
75 KActionCollection( QWidget *parent, const char *name = 0/*US , KInstance *instance = 0 */);
76 /**
77 * Use this constructor if you want the collection's actions to restrict
78 * their accelerator keys to @p watch rather than the @p parent. If
79 * you don't require shortcuts, you can pass a null to the @p watch parameter.
80 */
81 KActionCollection( QWidget *watch, QObject* parent, const char *name = 0/*US, KInstance *instance = 0 */);
82 KActionCollection( const KActionCollection &copy );
83 virtual ~KActionCollection();
84
85 /**
86 * This sets the widget to which the keyboard shortcuts should be attached.
87 * You only need to call this if a null pointer was passed in the constructor.
88 */
89 virtual void setWidget( QWidget *widget );
90
91 /**
92 * This indicates whether new actions which are created in this collection
93 * should have their keyboard shortcuts automatically connected on
94 * construction. Set to 'false' if you will be loading XML-based settings.
95 * This is automatically done by KParts. The default is 'true'.
96 * @see isAutoConnectShortcuts()
97 */
98 void setAutoConnectShortcuts( bool );
99
100 /**
101 * This indicates whether new actions which are created in this collection
102 * have their keyboard shortcuts automatically connected on
103 * construction.
104 * @see setAutoConnectShortcuts()
105 */
106 bool isAutoConnectShortcuts();
107
108 /**
109 * This sets the default shortcut scope for new actions created in this
110 * collection. The default is ScopeUnspecified. Ideally the default
111 * would have been ScopeWidget, but that would cause some backwards
112 * compatibility problems.
113 */
114 //void setDefaultScope( KAction::Scope );
115
116 /**
117 * Doc/View model. This lets you add the action collection of a document
118 * to a view's action collection.
119 */
120 bool addDocCollection( KActionCollection* pDoc );
121
122 /** Returns the number of widgets which this collection is associated with. */
123 //uint widgetCount() const;
124
125 /**
126 * Returns true if the collection has its own KAccel object. This will be
127 * the case if it was constructed with a valid widget ptr or if setWidget()
128 * was called.
129 */
130 //bool ownsKAccel() const;
131
132 /** @deprecated Deprecated because of ambiguous name. Use kaccel() */
133 virtual KAccel* accel();
134 /** @deprecated Deprecated because of ambiguous name. Use kaccel() */
135 virtual const KAccel* accel() const;
136
137 /** Returns the KAccel object of the most recently set widget. */
138 KAccel* kaccel();
139 /** Returns the KAccel object of the most recently set widget. Const version for convenience. */
140 const KAccel* kaccel() const;
141
142 /** @internal, for KAction::kaccelCurrent() */
143 KAccel* builderKAccel() const;
144 /** Returns the KAccel object associated with widget #. */
145 //KAccel* widgetKAccel( uint i );
146 //const KAccel* widgetKAccel( uint i ) const;
147
148 /** Returns the number of actions in the collection */
149 virtual uint count() const;
150 bool isEmpty() const { return count() == 0; }
151 /**
152 * Return the KAction* at position "index" in the action collection.
153 * @see count()
154 */
155 virtual KAction* action( int index ) const;
156 /**
157 * Find an action (optionally, of a given subclass of KAction) in the action collection.
158 * @param name Name of the KAction.
159 * @param classname Name of the KAction subclass.
160 * @return A pointer to the first KAction in the collection which matches the parameters or
161 * null if nothing matches.
162 */
163 virtual KAction* action( const char* name, const char* classname = 0 ) const;
164
165 /** Returns a list of all the groups of all the KActions in this action collection.
166 * @see KAction::group()
167 * @see KAction::setGroup()
168 */
169 virtual QStringList groups() const;
170 /**
171 * Returns the list of actions in a particular managed by this action collection.
172 * @param group The name of the group.
173 */
174 virtual KActionPtrList actions( const QString& group ) const;
175 /** Returns the list of actions managed by this action collection. */
176 virtual KActionPtrList actions() const;
177
178 /**
179 * Used for reading shortcut configuration from a non-XML rc file.
180 */
181//US bool readShortcutSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 );
182 /**
183 * Used for writing shortcut configuration to a non-XML rc file.
184 */
185//US bool writeShortcutSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 ) const;
186
187//US void setInstance( KInstance *instance );
188 /** The instance with which this class is associated. */
189//US KInstance *instance() const;
190
191 /**
192 * Use this to tell the KActionCollection what rc file its configuration
193 * is stored in.
194 */
195 void setXMLFile( const QString& );
196 /** The rc file in which the current configuration is stored. */
197 const QString& xmlFile() const;
198
199 /**
200 * Enable highlighting notification for specific KActions.
201 * @see connectHighlight()
202 * @see disconnectHighlight()
203 * @see actionHighlighted()
204 * @see actionHighlighted()
205 * @see highlightingEnabled()
206 */
207 void setHighlightingEnabled( bool enable );
208 /**
209 * Return whether highlighting notifications are enabled.
210 * @see connectHighlight()
211 * @see disconnectHighlight()
212 * @see actionHighlighted()
213 * @see setHighlightingEnabled()
214 * @see actionHighlighted()
215 */
216 bool highlightingEnabled() const;
217
218 /**
219 * Call this function if you want to receive a signal whenever a KAction is highlighted in a menu or a toolbar.
220 * @param container A container in which the KAction is plugged (must inherit QPopupMenu or KToolBar)
221 * @param action The action you are interested in
222 * @see disconnectHighlight()
223 * @see actionHighlighted()
224 * @see setHighlightingEnabled()
225 * @see highlightingEnabled()
226 * @see actionHighlighted()
227 */
228 void connectHighlight( QWidget *container, KAction *action );
229 /**
230 * Disconnect highlight notifications for a particular pair of contianer and action.
231 * @param container A container in which the KAction is plugged (must inherit QPopupMenu or KToolBar)
232 * @param action The action you are interested in
233 * @see connectHighlight()
234 * @see actionHighlighted()
235 * @see setHighlightingEnabled()
236 * @see highlightingEnabled()
237 * @see actionHighlighted()
238 */
239 void disconnectHighlight( QWidget *container, KAction *action );
240
241signals:
242 void inserted( KAction* );
243 void removed( KAction* );
244
245 /** Emitted when "action" is highlighted.
246 * @see connectHighlight()
247 * @see disconnectHighlight()
248 * @see actionHighlighted()
249 * @see setHighlightingEnabled()
250 * @see highlightingEnabled()
251 */
252 void actionHighlighted( KAction *action );
253 /** Emitted when "action" is highlighed or loses highlighting.
254 * @see connectHighlight()
255 * @see disconnectHighlight()
256 * @see actionHighlighted()
257 * @see setHighlightingEnabled()
258 * @see highlightingEnabled()
259 */
260 void actionHighlighted( KAction *action, bool highlight );
261
262 void actionStatusText( const QString &text );
263 void clearStatusText();
264
265private:
266 /**
267 * @internal Only to be called by KXMLGUIFactory::addClient().
268 * When actions are being connected, KAction needs to know what
269 * widget it should connect widget-scope actions to, and what
270 * main window it should connect
271 */
272 void beginXMLPlug( QWidget *widget );
273 void endXMLPlug();
274 /** @internal. Only to be called by KXMLGUIFactory::removeClient() */
275 void prepareXMLUnplug();
276 void unplugShortcuts( KAccel* kaccel );
277
278 void _clear();
279 void _insert( KAction* );
280 void _remove( KAction* );
281 KAction* _take( KAction* );
282
283private slots:
284 void slotMenuItemHighlighted( int id );
285 void slotToolBarButtonHighlighted( int id, bool highlight );
286 void slotMenuAboutToHide();
287 void slotDestroyed();
288
289private:
290 KAction *findAction( QWidget *container, int id );
291
292#ifndef KDE_NO_COMPAT
293public:
294 KActionCollection( QObject *parent, const char *name = 0 /*US, KInstance *instance = 0 */);
295
296 void insert( KAction* );
297
298 /**
299 * @deprecated Removes an action from the collection and deletes it.
300 * @param action The KAction to remove.
301 */
302 void remove( KAction* action );
303
304 /**
305 * @deprecated Removes an action from the collection.
306 * @return NULL if not found else returns action.
307 * @param action the KAction to remove.
308 */
309 KAction* take( KAction* action );
310
311 KActionCollection operator+ ( const KActionCollection& ) const;
312 KActionCollection& operator= ( const KActionCollection& );
313 KActionCollection& operator+= ( const KActionCollection& );
314
315public slots:
316 /**
317 * Clears the entire actionCollection, deleting all actions.
318 * @see #remove
319 */
320 void clear();
321#endif // !KDE_NO_COMPAT
322protected:
323 virtual void virtual_hook( int id, void* data );
324private:
325 class KActionCollectionPrivate;
326 KActionCollectionPrivate *d;
327};
328
329#endif