kaccelaction.h Source File (kdecore Library)

| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kaccelaction.h

    00001 /* This file is part of the KDE libraries
    00002     Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org>
    00003
    00004     This library is free software; you can redistribute it and/or
    00005     modify it under the terms of the GNU Library General Public
    00006     License as published by the Free Software Foundation; either
    00007     version 2 of the License, or (at your option) any later version.
    00008
    00009     This library is distributed in the hope that it will be useful,
    00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012     Library General Public License for more details.
    00013
    00014     You should have received a copy of the GNU Library General Public License
    00015     along with this library; see the file COPYING.LIB.  If not, write to
    00016     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017     Boston, MA 02111-1307, USA.
    00018 */
    00019
    00020 #ifndef _KACCELACTION_H
    00021 #define _KACCELACTION_H
    00022
    00023 #include <qmap.h>
    00024 #include <qptrvector.h>
    00025 #include <qstring.h>
    00026 #include <qvaluevector.h>
    00027
    00028 #include <kshortcut.h>
    00029
    00030 class KAccelBase;
    00031
    00032 class QObject;
    00033 class KConfig;
    00034 class KConfigBase;
    00035
    00072 class KAccelAction
    00073 {
    00074  public:
    00079         KAccelAction();
    00080
    00084         KAccelAction( const KAccelAction& );
    00085
    00100         KAccelAction( const QString& sName, const QString& sLabel, const QString& sWhatsThis,
    00101                         const KShortcut& cutDef3, const KShortcut& cutDef4,
    00102                         const QObject* pObjSlot, const char* psMethodSlot,
    00103                         bool bConfigurable, bool bEnabled );
    00104         ~KAccelAction();
    00105
    00109         void clear();
    00110
    00126         bool init( const QString& sName, const QString& sLabel, const QString& sWhatsThis,
    00127                         const KShortcut& cutDef3, const KShortcut& cutDef4,
    00128                         const QObject* pObjSlot, const char* psMethodSlot,
    00129                         bool bConfigurable, bool bEnabled );
    00130
    00134         KAccelAction& operator=( const KAccelAction& );
    00135
    00141         const QString& name() const                { return m_sName; }
    00142
    00148         const QString& label() const               { return m_sLabel; }
    00149
    00155         const QString& whatsThis() const           { return m_sWhatsThis; }
    00156
    00162         const KShortcut& shortcut() const          { return m_cut; }
    00163
    00171         const KShortcut& shortcutDefault() const;
    00172
    00181         const KShortcut& shortcutDefault3() const  { return m_cutDefault3; }
    00182
    00191         const KShortcut& shortcutDefault4() const  { return m_cutDefault4; }
    00192
    00197         const QObject* objSlotPtr() const          { return m_pObjSlot; }
    00198
    00203         const char* methodSlotPtr() const          { return m_psMethodSlot; }
    00204
    00209         bool isConfigurable() const                { return m_bConfigurable; }
    00210
    00215         bool isEnabled() const                     { return m_bEnabled; }
    00216
    00221         void setName( const QString& name );
    00222
    00227         void setLabel( const QString& label );
    00228
    00233         void setWhatsThis( const QString& whatsThis );
    00234
    00240         bool setShortcut( const KShortcut& rgCuts );
    00241
    00247         void setSlot( const QObject* pObjSlot, const char* psMethodSlot );
    00248
    00253         void setConfigurable( bool configurable );
    00254
    00259         void setEnabled( bool enable );
    00260
    00265         int getID() const   { return m_nIDAccel; }
    00266
    00274         void setID( int n ) { m_nIDAccel = n; }
    00275
    00280         bool isConnected() const;
    00281
    00289         bool setKeySequence( uint i, const KKeySequence &keySeq );
    00290
    00296         void clearShortcut();
    00297
    00304         bool contains( const KKeySequence &keySeq );
    00305
    00311         QString toString() const;
    00312
    00316         QString toStringInternal() const;
    00317
    00322         static bool useFourModifierKeys();
    00323
    00329         static void useFourModifierKeys( bool use );
    00330
    00331  protected:
    00332         QString m_sName,
    00333                 m_sLabel,
    00334                 m_sWhatsThis;
    00335         KShortcut m_cut;
    00336         KShortcut m_cutDefault3, m_cutDefault4;
    00337         const QObject* m_pObjSlot;
    00338         const char* m_psMethodSlot;
    00339         bool m_bConfigurable,
    00340              m_bEnabled;
    00341         int m_nIDAccel;
    00342         uint m_nConnections;
    00343
    00344         void incConnections();
    00345         void decConnections();
    00346
    00347  private:
    00348         static int g_bUseFourModifierKeys;
    00349         class KAccelActionPrivate* d;
    00350
    00351         friend class KAccelActions;
    00352         friend class KAccelBase;
    00353 };
    00354
    00355 //---------------------------------------------------------------------
    00356 // KAccelActions
    00357 //---------------------------------------------------------------------
    00358
    00366 class KAccelActions
    00367 {
    00368  public:
    00372         KAccelActions();
    00373
    00377         KAccelActions( const KAccelActions& );
    00378         virtual ~KAccelActions();
    00379
    00383         void clear();
    00384
    00391         bool init( const KAccelActions &actions );
    00392
    00400         bool init( KConfigBase& config, const QString& sGroup );
    00401
    00408         void updateShortcuts( KAccelActions &shortcuts );
    00409
    00415         int actionIndex( const QString& sAction ) const;
    00416
    00424         KAccelAction* actionPtr( uint index );
    00425
    00433         const KAccelAction* actionPtr( uint index ) const;
    00434
    00441         KAccelAction* actionPtr( const QString& sAction );
    00442
    00449         const KAccelAction* actionPtr( const QString& sAction ) const;
    00450
    00457         KAccelAction* actionPtr( KKeySequence cut );
    00458
    00467         KAccelAction& operator []( uint index );
    00468
    00477         const KAccelAction& operator []( uint index ) const;
    00478
    00494         KAccelAction* insert( const QString& sAction, const QString& sLabel, const QString& sWhatsThis,
    00495                         const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4,
    00496                         const QObject* pObjSlot = 0, const char* psMethodSlot = 0,
    00497                         bool bConfigurable = true, bool bEnabled = true );
    00498
    00505         KAccelAction* insert( const QString& sName, const QString& sLabel );
    00506
    00512         bool remove( const QString& sAction );
    00513
    00521         bool readActions( const QString& sConfigGroup = "Shortcuts", KConfigBase* pConfig = 0 );
    00522
    00532         bool writeActions( const QString& sConfigGroup = "Shortcuts", KConfigBase* pConfig = 0,
    00533                         bool bWriteAll = false, bool bGlobal = false ) const;
    00534
    00538         void emitKeycodeChanged();
    00539
    00544         uint count() const;
    00545
    00546  protected:
    00547         KAccelBase* m_pKAccelBase;
    00548         KAccelAction** m_prgActions;
    00549         uint m_nSizeAllocated, m_nSize;
    00550
    00551         void resize( uint );
    00552         void insertPtr( KAccelAction* );
    00553
    00554  private:
    00555         class KAccelActionsPrivate* d;
    00556
    00557         KAccelActions( KAccelBase* );
    00558         void initPrivate( KAccelBase* );
    00559         KAccelActions& operator =( KAccelActions& );
    00560
    00561         friend class KAccelBase;
    00562 };
    00563
    00564 #endif // _KACCELACTION_H

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:46:18 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001