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 #include <qglobal.h>    // For uint
00024 #include <qstring.h>
00025 
00026 class QVariant;
00027 class KConfigBase;
00028 class KInstance;
00029 class KKeySequence;
00030 class KShortcut;
00031 
00032 /**********************************************************************
00033 * This is a wrapper class which allows a function to use one interface
00034 * to KActionCollection, KAccelActions, and KActionPtrList.
00035 **********************************************************************/
00036 
00047 class KShortcutList
00048 {
00049  public:
00053     KShortcutList();
00054     virtual ~KShortcutList();
00055 
00060     virtual uint count() const = 0;
00061 
00067     virtual QString name( uint index ) const = 0;
00068 
00074     virtual QString label( uint index ) const = 0;
00075 
00081     virtual QString whatsThis( uint index ) const = 0;
00082 
00089     virtual const KShortcut& shortcut( uint index ) const = 0;
00090 
00097     virtual const KShortcut& shortcutDefault( uint index ) const = 0;
00098 
00104     virtual bool isConfigurable( uint index ) const = 0;
00105 
00111     virtual bool setShortcut( uint index, const KShortcut &shortcut ) = 0;
00112 
00119     virtual bool isGlobal( uint index ) const;
00120 
00126     virtual int index( const QString& sName ) const;
00127 
00133     virtual int index( const KKeySequence& keySeq ) const;
00134 
00139     virtual const KInstance* instance() const;
00140 
00141     // These are here in order to handle expansion.
00142     enum Other { };
00144     virtual QVariant getOther( Other, uint index ) const = 0;
00146     virtual bool setOther( Other, uint index, QVariant ) = 0;
00147 
00152     virtual bool save() const = 0;
00153 
00161     virtual bool readSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 );
00162 
00172     virtual bool writeSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0,
00173             bool bWriteAll = false, bool bGlobal = false ) const;
00174 
00175  protected:
00177         virtual void virtual_hook( int id, void* data );
00178  private:
00179     class KShortcutListPrivate* d;
00180 };
00181 
00182 //---------------------------------------------------------------------
00183 // KAccelShortcutList
00184 //---------------------------------------------------------------------
00185 
00186 class KAccel;
00187 class KAccelActions;
00188 class KGlobalAccel;
00189 
00194 class KAccelShortcutList : public KShortcutList
00195 {
00196  public:
00201     KAccelShortcutList( KAccel* accel );
00202 
00208     KAccelShortcutList( KGlobalAccel* accel );
00209 
00218     KAccelShortcutList( KAccelActions &actions, bool bGlobal );
00219     virtual ~KAccelShortcutList();
00220 
00221     virtual uint count() const;
00222     virtual QString name( uint index ) const;
00223     virtual QString label( uint index ) const;
00224     virtual QString whatsThis( uint index ) const;
00225     virtual const KShortcut& shortcut( uint index ) const;
00226     virtual const KShortcut& shortcutDefault( uint index ) const;
00227     virtual bool isConfigurable( uint index ) const;
00228     virtual bool setShortcut( uint index , const KShortcut& shortcut );
00229     virtual bool isGlobal( uint index ) const;
00230 
00232     virtual QVariant getOther( Other, uint index ) const;
00234     virtual bool setOther( Other, uint index, QVariant );
00235 
00236     virtual bool save() const;
00237 
00238  protected:
00239     KAccelActions& m_actions;
00240     bool m_bGlobal;
00241 
00242  protected:
00243     virtual void virtual_hook( int id, void* data );
00244  private:
00245     class KAccelShortcutListPrivate* d;
00246 };
00247 
00248 namespace KStdAccel {
00249 //---------------------------------------------------------------------
00250 // ShortcutList
00251 //---------------------------------------------------------------------
00252 
00257 class ShortcutList : public KShortcutList
00258 {
00259  public:
00263     ShortcutList();
00264     virtual ~ShortcutList();
00265 
00266     virtual uint count() const;
00267     virtual QString name( uint index ) const;
00268     virtual QString label( uint index ) const;
00269     virtual QString whatsThis( uint index ) const;
00270     virtual const KShortcut& shortcut( uint index ) const;
00271     virtual const KShortcut& shortcutDefault( uint index ) const;
00272     virtual bool isConfigurable( uint index ) const;
00273     virtual bool setShortcut( uint index , const KShortcut& shortcut );
00274 
00276     virtual QVariant getOther( Other, uint index ) const;
00278     virtual bool setOther( Other, uint index, QVariant );
00279 
00280     virtual bool save() const;
00281 
00282  protected:
00283     virtual void virtual_hook( int id, void* data );
00284  private:
00285     class ShortcutListPrivate* d;
00286 };
00287 }
00288 
00289 #endif // __KSHORTCUTLIST_H
KDE Logo
This file is part of the documentation for kdecore Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed May 5 07:15:44 2004 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003