kdecore Library API Documentation

KKey Class Reference

A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win). More...

#include <kshortcut.h>

List of all members.

Public Types

enum  
enum  ModFlag

Public Methods

 KKey ()
 KKey (int keyQt)
 KKey (const QKeySequence &keySeq)
 KKey (const QKeyEvent *keyEvent)
 KKey (const KKey &key)
 KKey (const QString &key)
void clear ()
bool init (int keyQt)
bool init (const QKeySequence &keySeq)
bool init (const QKeyEvent *keyEvent)
bool init (const KKey &key)
bool init (const QString &key)
KKey & operator= (const KKey &key)
bool isNull () const
int compare (const KKey &key) const
bool operator== (const KKey &key) const
bool operator!= (const KKey &key) const
bool operator< (const KKey &key) const
int keyCodeQt () const
QString toString () const

Static Public Methods

KKey & null ()
QString modFlagLabel (ModFlag f)


Detailed Description

A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win).

It can represent both keys which are understood by Qt as well as those which are additionally supported by the underlying system (e.g. X11).

See also:
KKeyNative , KKeySequence , KShortcut

Definition at line 39 of file kshortcut.h.


Member Enumeration Documentation

anonymous enum
 

The number of flags.

See also:
ModFlag

Definition at line 46 of file kshortcut.h.

enum KKey::ModFlag
 

Flags to represent the modifiers.

You can combine modifiers by ORing them.

Definition at line 52 of file kshortcut.h.


Constructor & Destructor Documentation

KKey::KKey  
 

Creates a new null KKey.

See also:
clear() , isNull() , null()

Definition at line 44 of file kshortcut.cpp.

References clear().

KKey::KKey int    keyQt
 

Creates a new key for the given Qt key code.

Parameters:
keyQt  the qt keycode
See also:
Qt::Key

Definition at line 46 of file kshortcut.cpp.

References init().

KKey::KKey const QKeySequence   keySeq
 

Creates a new key from the first key code of the given key sequence.

Parameters:
keySeq  the key sequence that contains the key

Definition at line 47 of file kshortcut.cpp.

References init().

KKey::KKey const QKeyEvent   keyEvent
 

Extracts the key from the given key event.

Parameters:
keyEvent  the key event to get the key from

Definition at line 48 of file kshortcut.cpp.

References init().

KKey::KKey const KKey &    key
 

Copy constructor.

Definition at line 49 of file kshortcut.cpp.

References init(), and KStdAccel::key().

KKey::KKey const QString   key
 

Creates a new key from the given description.

The form of the description is "[modifier+[modifier+]]+key", for example "e", "CTRL+q" or "CTRL+ALT+DEL". Allowed modifiers are "SHIFT", "CTRL", "ALT", "WIN" and "META". "WIN" and "META" are equivalent. Modifiers are not case-sensitive.

Parameters:
key  the description of the key
See also:
KKeyServer::Sym::init()

Definition at line 50 of file kshortcut.cpp.

References init().


Member Function Documentation

void KKey::clear  
 

Clears the key.

The key is null after calling this function.

See also:
isNull()

Definition at line 56 of file kshortcut.cpp.

Referenced by init(), KKey(), and null().

bool KKey::init int    keyQt
 

Initializes the key with the given Qt key code.

Parameters:
keyQt  the qt keycode
Returns:
true if successful, false otherwise
See also:
Qt::Key

Definition at line 69 of file kshortcut.cpp.

References KKeyServer::keyQtToMod(), and KKeyServer::keyQtToSym().

Referenced by KKeySequence::init(), init(), KKey(), operator=(), and KKeySequence::setKey().

bool KKey::init const QKeySequence   keySeq
 

Initializes the key with the first key code of the given key sequence.

Parameters:
keySeq  the key sequence that contains the key
Returns:
true if successful, false otherwise

Definition at line 84 of file kshortcut.cpp.

References init(), and KStdAccel::key().

bool KKey::init const QKeyEvent   keyEvent
 

Initializes the key by extracting the code from the given key event.

Parameters:
keyEvent  the key event to get the key from
Returns:
true if successful, false otherwise

Definition at line 90 of file kshortcut.cpp.

References init(), QKeyEvent::key(), and QKeyEvent::state().

bool KKey::init const KKey &    key
 

Copies the given key.

Parameters:
key  the key to copy
Returns:
true if successful, false otherwise

Definition at line 100 of file kshortcut.cpp.

References KStdAccel::key(), m_mod, and m_sym.

bool KKey::init const QString   key
 

Initializes the key with the given description.

The form of the description is "[modifier+[modifier+]]+key", for example "e", "CTRL+q" or "CTRL+ALT+DEL". Allowed modifiers are "SHIFT", "CTRL", "ALT", "WIN" and "META". "WIN" and "META" are equivalent. Modifiers are not case-sensitive.

Parameters:
key  the description of the key
Returns:
true if successful, false otherwise
See also:
KKeyServer::Sym::init()

Definition at line 107 of file kshortcut.cpp.

References clear(), endl(), QString::endsWith(), QString::left(), QString::length(), KKeyServer::Sym::m_sym, QString::mid(), QString::number(), QStringList::split(), QString::startsWith(), and QString::stripWhiteSpace().

KKey& KKey::operator= const KKey &    key [inline]
 

Copies the key.

Definition at line 161 of file kshortcut.h.

References init(), and KStdAccel::key().

bool KKey::isNull  
 

Returns true if the key is null (after clear() or empty constructor).

Returns:
true if the key is null
See also:
clear() , null()

Definition at line 146 of file kshortcut.cpp.

Referenced by KKeySequence::init(), and null().

int KKey::compare const KKey &    key const
 

Compares this key with the given KKey object.

Returns a negative number if the given KKey is larger, 0 if they are equal and a positive number this KKey is larger. The returned value is the difference between the symbol or, if the symbols are equal, the difference between the encoded modifiers.

Parameters:
key  the key to compare with this key
Returns:
a negative number if the given KKey is larger, 0 if they are equal and a positive number this KKey is larger

Definition at line 150 of file kshortcut.cpp.

References m_mod, and m_sym.

Referenced by KKeySequence::compare(), operator!=(), operator<(), and operator==().

bool KKey::operator== const KKey &    key const [inline]
 

Compares the symbol and modifiers of both keys.

See also:
compare()

Definition at line 200 of file kshortcut.h.

References compare(), and KStdAccel::key().

bool KKey::operator!= const KKey &    key const [inline]
 

Compares the symbol and modifiers of both keys.

See also:
compare()

Definition at line 206 of file kshortcut.h.

References compare(), and KStdAccel::key().

bool KKey::operator< const KKey &    key const [inline]
 

Compares the symbol and modifiers of both keys.

See also:
compare()

Definition at line 212 of file kshortcut.h.

References compare(), and KStdAccel::key().

int KKey::keyCodeQt  
 

Returns the qt key code.

Returns:
the qt key code or 0 if there is no key set.
See also:
Qt::Key

Definition at line 159 of file kshortcut.cpp.

QString KKey::toString  
 

Returns a human-readable representation of the key in the form "modifier+key".

Returns:
the string representation of the key

Definition at line 164 of file kshortcut.cpp.

References QString::isEmpty(), and KKeyServer::modToStringUser().

Referenced by KKeySequence::toString().

KKey & KKey::null   [static]
 

Returns a null key.

Returns:
the null key
See also:
isNull() , clear()

Definition at line 190 of file kshortcut.cpp.

References clear(), and isNull().

Referenced by KKeySequence::key().

QString KKey::modFlagLabel ModFlag    f [static]
 

Returns a user-readable representation of the given modifiers.

Parameters:
f  the modifiers to convert
Returns:
the string representation of the modifiers

Definition at line 199 of file kshortcut.cpp.

References KKeyServer::modToStringUser().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdecore Library Version 3.2.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Feb 4 12:33:56 2004 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2003