kdeui Library API Documentation

kactioncollection.h

00001 /* This file is part of the KDE libraries
00002     Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
00003               (C) 1999 Simon Hausmann <hausmann@kde.org>
00004               (C) 2000 Nicolas Hadacek <haadcek@kde.org>
00005               (C) 2000 Kurt Granroth <granroth@kde.org>
00006               (C) 2000 Michael Koch <koch@kde.org>
00007               (C) 2001 Holger Freyther <freyther@kde.org>
00008               (C) 2002 Ellis Whitehead <ellis@kde.org>
00009 
00010     This library is free software; you can redistribute it and/or
00011     modify it under the terms of the GNU Library General Public
00012     License version 2 as published by the Free Software Foundation.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Library General Public License for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with this library; see the file COPYING.LIB.  If not, write to
00021     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022     Boston, MA 02111-1307, USA.
00023 */
00024 
00025 #ifndef __kactioncollection_h__
00026 #define __kactioncollection_h__
00027 
00028 #include <kaction.h>
00029 
00030 #include <qkeysequence.h>
00031 #include <qobject.h>
00032 #include <qvaluelist.h>
00033 #include <qguardedptr.h>
00034 #include <kguiitem.h>
00035 #include <kshortcut.h>
00036 #include <kstdaction.h>
00037 #include <kicontheme.h>
00038 
00039 class QMenuBar;
00040 class QPopupMenu;
00041 class QComboBox;
00042 class QPoint;
00043 class QIconSet;
00044 class QString;
00045 class KToolBar;
00046 
00047 class KAccel;
00048 class KAccelActions;
00049 class KConfig;
00050 class KConfigBase;
00051 class KURL;
00052 class KInstance;
00053 class KToolBar;
00054 class KActionCollection;
00055 class KPopupMenu;
00056 class KMainWindow;
00057 
00058 typedef QValueList<KAction *> KActionPtrList;
00059 
00063 class KDEUI_EXPORT KActionCollection : public QObject
00064 {
00065   friend class KAction;
00066   friend class KXMLGUIClient;
00067 
00068   Q_OBJECT
00069 
00070 public:
00071   KActionCollection( QWidget *parent, const char *name = 0, KInstance *instance = 0 );
00077   KActionCollection( QWidget *watch, QObject* parent, const char *name = 0, KInstance *instance = 0 );
00078   KActionCollection( const KActionCollection &copy );
00079   virtual ~KActionCollection();
00080 
00085   virtual void setWidget( QWidget *widget );
00086 
00094   void setAutoConnectShortcuts( bool );
00095 
00102   bool isAutoConnectShortcuts();
00103 
00110   //void setDefaultScope( KAction::Scope );
00111 
00116   bool addDocCollection( KActionCollection* pDoc );
00117 
00119   //uint widgetCount() const;
00120 
00126   //bool ownsKAccel() const;
00127 
00129   virtual KAccel* accel() KDE_DEPRECATED;
00131   virtual const KAccel* accel() const KDE_DEPRECATED;
00132 
00134   KAccel* kaccel();
00136   const KAccel* kaccel() const;
00137 
00139   KAccel* builderKAccel() const;
00141   //KAccel* widgetKAccel( uint i );
00142   //const KAccel* widgetKAccel( uint i ) const;
00143 
00145   virtual uint count() const;
00146   bool isEmpty() const { return (count() == 0); }
00151   virtual KAction* action( int index ) const;
00159   virtual KAction* action( const char* name, const char* classname = 0 ) const;
00160 
00165   virtual QStringList groups() const;
00170   virtual KActionPtrList actions( const QString& group ) const;
00172   virtual KActionPtrList actions() const;
00173 
00177   bool readShortcutSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 );
00181   bool writeShortcutSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 ) const;
00182 
00183   void setInstance( KInstance *instance );
00185   KInstance *instance() const;
00186 
00190   void setXMLFile( const QString& );
00194   const QString& xmlFile() const;
00195 
00204   void setHighlightingEnabled( bool enable );
00213   bool highlightingEnabled() const;
00214 
00225   void connectHighlight( QWidget *container, KAction *action );
00236   void disconnectHighlight( QWidget *container, KAction *action );
00237 
00241   const KXMLGUIClient *parentGUIClient() const;
00242 
00243 signals:
00244   void inserted( KAction* );
00245   void removed( KAction* );
00246 
00254   void actionHighlighted( KAction *action );
00262   void actionHighlighted( KAction *action, bool highlight );
00263 
00264   void actionStatusText( const QString &text );
00265   void clearStatusText();
00266 
00267 private:
00274   void beginXMLPlug( QWidget *widget );
00275   void endXMLPlug();
00277   void prepareXMLUnplug();
00278   void unplugShortcuts( KAccel* kaccel );
00279 
00280   void _clear();
00281   void _insert( KAction* );
00282   void _remove( KAction* );
00283   KAction* _take( KAction* );
00284 
00285 private slots:
00286    void slotMenuItemHighlighted( int id );
00287    void slotToolBarButtonHighlighted( int id, bool highlight );
00288    void slotMenuAboutToHide();
00289    void slotDestroyed();
00290 
00291 private:
00292    KAction *findAction( QWidget *container, int id );
00293 
00294 #ifndef KDE_NO_COMPAT
00295 public:
00296   KActionCollection( QObject *parent, const char *name = 0, KInstance *instance = 0 );
00297 #endif
00298 
00299 public:
00310   void insert( KAction* action);
00311 
00318   void remove( KAction* action );
00319 
00327   KAction* take( KAction* action );
00328 
00329 #ifndef KDE_NO_COMPAT
00330   KActionCollection operator+ ( const KActionCollection& ) const;
00331   KActionCollection& operator= ( const KActionCollection& );
00332   KActionCollection& operator+= ( const KActionCollection& );
00333 #endif // !KDE_NO_COMPAT
00334 
00335   // KDE4: clear() doesn't need to be a slot
00336 public slots:
00341   void clear();
00342 
00343 protected:
00344     virtual void virtual_hook( int id, void* data );
00345 private:
00346     KActionCollection( const char* name, const KXMLGUIClient* parent );
00347     class KActionCollectionPrivate;
00348     KActionCollectionPrivate *d;
00349 };
00350 
00351 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:11:58 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003