kdecore Library API Documentation

kshortcutlist.h

00001 /*  This file is part of the KDE libraries
00002     Copyright (C) 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 __KSHORTCUTLIST_H
00021 #define __KSHORTCUTLIST_H
00022 
00023 class QString;
00024 class QVariant;
00025 class KInstance;
00026 class KShortcut;
00027 
00028 /**********************************************************************
00029 * This is a wrapper class which allows a function to use one interface
00030 * to KActionCollection, KAccelActions, and KActionPtrList.
00031 **********************************************************************/
00032 
00043 class KShortcutList
00044 {
00045  public:
00049     KShortcutList();
00050     virtual ~KShortcutList();
00051 
00056     virtual uint count() const = 0;
00057 
00063     virtual QString name( uint index ) const = 0;
00064 
00070     virtual QString label( uint index ) const = 0;
00071 
00077     virtual QString whatsThis( uint index ) const = 0;
00078 
00085     virtual const KShortcut& shortcut( uint index ) const = 0;
00086 
00093     virtual const KShortcut& shortcutDefault( uint index ) const = 0;
00094 
00100     virtual bool isConfigurable( uint index ) const = 0;
00101 
00107     virtual bool setShortcut( uint index, const KShortcut &shortcut ) = 0;
00108 
00115     virtual bool isGlobal( uint index ) const;
00116 
00122     virtual int index( const QString& sName ) const;
00123 
00129     virtual int index( const KKeySequence& keySeq ) const;
00130 
00135     virtual const KInstance* instance() const;
00136 
00137     // These are here in order to handle expansion.
00138     enum Other { };
00140     virtual QVariant getOther( Other, uint index ) const = 0;
00142     virtual bool setOther( Other, uint index, QVariant ) = 0;
00143 
00148     virtual bool save() const = 0;
00149 
00157     virtual bool readSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 );
00158 
00168     virtual bool writeSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0,
00169             bool bWriteAll = false, bool bGlobal = false ) const;
00170 
00171  protected:
00173         virtual void virtual_hook( int id, void* data );
00174  private:
00175     class KShortcutListPrivate* d;
00176 };
00177 
00178 //---------------------------------------------------------------------
00179 // KAccelShortcutList
00180 //---------------------------------------------------------------------
00181 
00182 class KAccel;
00183 class KAccelActions;
00184 class KGlobalAccel;
00185 
00190 class KAccelShortcutList : public KShortcutList
00191 {
00192  public:
00197     KAccelShortcutList( KAccel* accel );
00198 
00204     KAccelShortcutList( KGlobalAccel* accel );
00205 
00214     KAccelShortcutList( KAccelActions &actions, bool bGlobal );
00215     virtual ~KAccelShortcutList();
00216 
00217     virtual uint count() const;
00218     virtual QString name( uint index ) const;
00219     virtual QString label( uint index ) const;
00220     virtual QString whatsThis( uint index ) const;
00221     virtual const KShortcut& shortcut( uint index ) const;
00222     virtual const KShortcut& shortcutDefault( uint index ) const;
00223     virtual bool isConfigurable( uint index ) const;
00224     virtual bool setShortcut( uint index , const KShortcut& shortcut );
00225     virtual bool isGlobal( uint index ) const;
00226 
00228     virtual QVariant getOther( Other, uint index ) const;
00230     virtual bool setOther( Other, uint index, QVariant );
00231 
00232     virtual bool save() const;
00233 
00234  protected:
00235     KAccelActions& m_actions;
00236     bool m_bGlobal;
00237 
00238  protected:
00239     virtual void virtual_hook( int id, void* data );
00240  private:
00241     class KAccelShortcutListPrivate* d;
00242 };
00243 
00244 namespace KStdAccel {
00245 //---------------------------------------------------------------------
00246 // ShortcutList
00247 //---------------------------------------------------------------------
00248 
00253 class ShortcutList : public KShortcutList
00254 {
00255  public:
00259     ShortcutList();
00260     virtual ~ShortcutList();
00261 
00262     virtual uint count() const;
00263     virtual QString name( uint index ) const;
00264     virtual QString label( uint index ) const;
00265     virtual QString whatsThis( uint index ) const;
00266     virtual const KShortcut& shortcut( uint index ) const;
00267     virtual const KShortcut& shortcutDefault( uint index ) const;
00268     virtual bool isConfigurable( uint index ) const;
00269     virtual bool setShortcut( uint index , const KShortcut& shortcut );
00270 
00272     virtual QVariant getOther( Other, uint index ) const;
00274     virtual bool setOther( Other, uint index, QVariant );
00275 
00276     virtual bool save() const;
00277 
00278  protected:
00279     virtual void virtual_hook( int id, void* data );
00280  private:
00281     class ShortcutListPrivate* d;
00282 };
00283 };
00284 
00285 #endif // __KSHORTCUTLIST_H
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:20:41 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001