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 //$Id: kactioncollection.h,v 1.178 2004/01/05 11:05:55 bhards Exp $
00025 
00026 #ifndef __kactioncollection_h__
00027 #define __kactioncollection_h__
00028 
00029 #include <kaction.h>
00030 
00031 #include <qkeysequence.h>
00032 #include <qobject.h>
00033 #include <qvaluelist.h>
00034 #include <qguardedptr.h>
00035 #include <kguiitem.h>
00036 #include <kshortcut.h>
00037 #include <kstdaction.h>
00038 #include <kicontheme.h>
00039 
00040 class QMenuBar;
00041 class QPopupMenu;
00042 class QComboBox;
00043 class QPoint;
00044 class QIconSet;
00045 class QString;
00046 class KToolBar;
00047 
00048 class KAccel;
00049 class KAccelActions;
00050 class KConfig;
00051 class KConfigBase;
00052 class KURL;
00053 class KInstance;
00054 class KToolBar;
00055 class KActionCollection;
00056 class KPopupMenu;
00057 class KMainWindow;
00058 
00059 typedef QValueList<KAction *> KActionPtrList;
00060 
00064 class KActionCollection : public QObject
00065 {
00066   friend class KAction;
00067   friend class KXMLGUIClient;
00068 
00069   Q_OBJECT
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 
00191   void setXMLFile( const QString& );
00193   const QString& xmlFile() const;
00194 
00203   void setHighlightingEnabled( bool enable );
00212   bool highlightingEnabled() const;
00213 
00224   void connectHighlight( QWidget *container, KAction *action );
00235   void disconnectHighlight( QWidget *container, KAction *action );
00236 
00237 signals:
00238   void inserted( KAction* );
00239   void removed( KAction* );
00240 
00248   void actionHighlighted( KAction *action );
00256   void actionHighlighted( KAction *action, bool highlight );
00257 
00258   void actionStatusText( const QString &text );
00259   void clearStatusText();
00260 
00261 private:
00268   void beginXMLPlug( QWidget *widget );
00269   void endXMLPlug();
00271   void prepareXMLUnplug();
00272   void unplugShortcuts( KAccel* kaccel );
00273 
00274   void _clear();
00275   void _insert( KAction* );
00276   void _remove( KAction* );
00277   KAction* _take( KAction* );
00278 
00279 private slots:
00280    void slotMenuItemHighlighted( int id );
00281    void slotToolBarButtonHighlighted( int id, bool highlight );
00282    void slotMenuAboutToHide();
00283    void slotDestroyed();
00284 
00285 private:
00286    KAction *findAction( QWidget *container, int id );
00287 
00288 #ifndef KDE_NO_COMPAT
00289 public:
00290   KActionCollection( QObject *parent, const char *name = 0, KInstance *instance = 0 );
00291 #endif
00292 
00293 public:
00304   void insert( KAction* action);
00305 
00312   void remove( KAction* action );
00313 
00321   KAction* take( KAction* action );
00322 
00323 #ifndef KDE_NO_COMPAT
00324   KActionCollection operator+ ( const KActionCollection& ) const;
00325   KActionCollection& operator= ( const KActionCollection& );
00326   KActionCollection& operator+= ( const KActionCollection& );
00327 
00328 public slots:
00333   void clear();
00334 #endif // !KDE_NO_COMPAT
00335 protected:
00336     virtual void virtual_hook( int id, void* data );
00337 private:
00338     class KActionCollectionPrivate;
00339     KActionCollectionPrivate *d;
00340 };
00341 
00342 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed May 5 07:16:05 2004 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003