kdecore Library API Documentation

KShortcut Class Reference

The KShortcut class is used to represent a keyboard shortcut to an action. More...

#include <kshortcut.h>

List of all members.

Public Types

enum  { MAX_SEQUENCES = 2 }

Public Member Functions

 KShortcut ()
 KShortcut (int keyQt)
 KShortcut (const QKeySequence &keySeq)
 KShortcut (const KKey &key)
 KShortcut (const KKeySequence &keySeq)
 KShortcut (const KShortcut &shortcut)
 KShortcut (const char *shortcut)
 KShortcut (const QString &shortcut)
void clear ()
bool init (int keyQt)
bool init (const QKeySequence &keySeq)
bool init (const KKey &key)
bool init (const KKeySequence &keySeq)
bool init (const KShortcut &shortcut)
bool init (const QString &shortcut)
KShortcutoperator= (const KShortcut &cut)
uint count () const
const KKeySequenceseq (uint i) const
int keyCodeQt () const
bool isNull () const
int compare (const KShortcut &shortcut) const
bool operator== (const KShortcut &cut) const
bool operator!= (const KShortcut &cut) const
bool operator< (const KShortcut &cut) const
bool contains (const KKey &key) const
bool contains (const KKeyNative &key) const
bool contains (const KKeySequence &keySeq) const
bool setSeq (uint i, const KKeySequence &keySeq)
bool append (const KKeySequence &keySeq)
bool append (const KKey &spec)
bool append (const KShortcut &cut)
 operator QKeySequence () const
QString toString () const
QString toStringInternal (const KShortcut *pcutDefault=0) const
 operator int () const

Static Public Member Functions

KShortcutnull ()

Protected Attributes

uint m_nSeqs
KKeySequence m_rgseq [MAX_SEQUENCES]


Detailed Description

The KShortcut class is used to represent a keyboard shortcut to an action.

A shortcut is normally a single key with modifiers, such as Ctrl+V. A KShortcut object may also contain an alternate key which will also activate the action it's associated to, as long as no other actions have defined that key as their primary key. Ex: Ctrl+V;Shift+Insert.

Definition at line 524 of file kshortcut.h.


Member Enumeration Documentation

anonymous enum
 

The maximum number of key sequences that can be contained in a KShortcut.

Definition at line 531 of file kshortcut.h.


Constructor & Destructor Documentation

KShortcut::KShortcut  ) 
 

Creates a new null shortcut.

See also:
null()

isNull()

clear()

Definition at line 416 of file kshortcut.cpp.

References clear().

KShortcut::KShortcut int  keyQt  ) 
 

Creates a new shortcut with the given Qt key code as the only key sequence.

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

Definition at line 417 of file kshortcut.cpp.

References init().

KShortcut::KShortcut const QKeySequence keySeq  ) 
 

Creates a new shortcut that contains only the given qt key sequence.

Parameters:
keySeq the qt key sequence to add

Definition at line 418 of file kshortcut.cpp.

References init().

KShortcut::KShortcut const KKey key  ) 
 

Creates a new shortcut that contains only the given key in its only sequence.

Parameters:
key the key to add

Definition at line 419 of file kshortcut.cpp.

References init().

KShortcut::KShortcut const KKeySequence keySeq  ) 
 

Creates a new shortcut that contains only the given key sequence.

Parameters:
keySeq the key sequence to add

Definition at line 420 of file kshortcut.cpp.

References init().

KShortcut::KShortcut const KShortcut shortcut  ) 
 

Copies the given shortcut.

Parameters:
shortcut the shortcut to add

Definition at line 421 of file kshortcut.cpp.

References init().

KShortcut::KShortcut const char *  shortcut  ) 
 

Creates a new key sequence that contains the given key sequence.

The description consists of semicolon-separated keys as used in KKeySequence::KKeySequence(const QString&).

Parameters:
shortcut the description of the key
See also:
KKeySequence::KKeySequence(const QString&)

Definition at line 422 of file kshortcut.cpp.

References init().

KShortcut::KShortcut const QString shortcut  ) 
 

Creates a new key sequence that contains the given key sequence.

The description consists of semicolon-separated keys as used in KKeySequence::KKeySequence(const QString&).

Parameters:
shortcut the description of the key
See also:
KKeySequence::KKeySequence(const QString&)

Definition at line 423 of file kshortcut.cpp.

References init().


Member Function Documentation

void KShortcut::clear  ) 
 

Clears the shortcut.

The shortcut is null after calling this function.

See also:
isNull()

Definition at line 429 of file kshortcut.cpp.

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

bool KShortcut::init int  keyQt  ) 
 

Initializes the shortcut with the given Qt key code as the only key sequence.

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

Definition at line 434 of file kshortcut.cpp.

References clear(), KKeySequence::init(), and init().

Referenced by init(), and KShortcut().

bool KShortcut::init const QKeySequence keySeq  ) 
 

Initializes the shortcut with the given qt key sequence.

Parameters:
keySeq the qt key sequence to add

Definition at line 444 of file kshortcut.cpp.

References KKeySequence::init(), and init().

bool KShortcut::init const KKey key  ) 
 

Initializes the shortcut with the given key as its only sequence.

Parameters:
key the key to add

Definition at line 451 of file kshortcut.cpp.

References KKeySequence::init(), and init().

bool KShortcut::init const KKeySequence keySeq  ) 
 

Initializes the shortcut with the given qt key sequence.

Parameters:
keySeq the qt key sequence to add

Definition at line 458 of file kshortcut.cpp.

References init().

bool KShortcut::init const KShortcut shortcut  ) 
 

Copies the given shortcut.

Parameters:
shortcut the shortcut to add

Definition at line 465 of file kshortcut.cpp.

References init().

bool KShortcut::init const QString shortcut  ) 
 

Initializes the key sequence with the given key sequence.

The description consists of semicolon-separated keys as used in KKeySequence::KKeySequence(const QString&).

Parameters:
shortcut the description of the key
See also:
KKeySequence::KKeySequence(const QString&)

Definition at line 473 of file kshortcut.cpp.

References clear(), KKeyServer::Variations::count(), endl(), KKeyServer::Variations::init(), KKeySequence::init(), init(), QString::isEmpty(), QString::length(), KKeyServer::Variations::m_rgkey, QString::mid(), and QString::startsWith().

KShortcut& KShortcut::operator= const KShortcut cut  )  [inline]
 

Copies the given shortcut over this shortcut.

Definition at line 646 of file kshortcut.h.

uint KShortcut::count  )  const
 

Returns the number of sequences that are in this shortcut.

Returns:
the number of sequences MAX_SEQUENCES

Definition at line 511 of file kshortcut.cpp.

Referenced by contains(), operator QKeySequence(), and toString().

const KKeySequence & KShortcut::seq uint  i  )  const
 

Returns the i'th key sequence of this shortcut.

Parameters:
i the number of the key sequence to retrieve
Returns:
the i'th sequence or KKeySequence::null() if there are less than i key sequences MAX_SEQUENCES

Definition at line 516 of file kshortcut.cpp.

References KKeySequence::null(), and seq().

Referenced by append(), and seq().

int KShortcut::keyCodeQt  )  const
 

Returns the key code of the first key sequence, or null if there is no first key sequence.

Returns:
the key code of the first sequence's first key
See also:
Qt::Key

KKeySequence::keyCodeQt()

Definition at line 521 of file kshortcut.cpp.

References KKeySequence::keyCodeQt().

Referenced by KStdAccel::defaultKey(), and KStdAccel::key().

bool KShortcut::isNull  )  const
 

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

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

null()

Definition at line 528 of file kshortcut.cpp.

Referenced by KCompletion::makeCompletion(), and null().

int KShortcut::compare const KShortcut shortcut  )  const
 

Compares this object with the given shortcut.

Returns a negative number if the given shortcut is larger, 0 if they are equal and a positive number this shortcut is larger. Shortcuts are compared by comparing the individual key sequences, starting from the beginning until an unequal key sequences has been found. If a shortcut contains more key sequences, it is considered larger.

Parameters:
shortcut the shortcut to compare to
Returns:
a negative number if the given KShortcut is larger, 0 if they are equal and a positive number this KShortcut is larger
See also:
KKey::compare()

KKeyShortcut::compare()

Definition at line 533 of file kshortcut.cpp.

References KKeySequence::compare(), and compare().

Referenced by compare().

bool KShortcut::operator== const KShortcut cut  )  const [inline]
 

Compares the sequences of both shortcuts.

See also:
compare()

Definition at line 703 of file kshortcut.h.

bool KShortcut::operator!= const KShortcut cut  )  const [inline]
 

Compares the sequences of both shortcuts.

See also:
compare()

Definition at line 710 of file kshortcut.h.

bool KShortcut::operator< const KShortcut cut  )  const [inline]
 

Compares the sequences of both shortcuts.

See also:
compare()

Definition at line 717 of file kshortcut.h.

bool KShortcut::contains const KKey key  )  const
 

Checks whether this shortcut contains a sequence that starts with the given key.

Parameters:
key the key to check
Returns:
true if a key sequence starts with the key

Definition at line 543 of file kshortcut.cpp.

References contains().

Referenced by append(), contains(), and KShortcutList::index().

bool KShortcut::contains const KKeyNative key  )  const
 

Checks whether this shortcut contains a sequence that starts with the given key.

Parameters:
key the key to check
Returns:
true if a key sequence starts with the key

Definition at line 548 of file kshortcut.cpp.

References contains(), KKeySequence::count(), count(), KKeySequence::isNull(), KKeySequence::key(), and KKeyNative::key().

bool KShortcut::contains const KKeySequence keySeq  )  const
 

Checks whether this shortcut contains the given sequence.

Parameters:
keySeq the key sequence to check
Returns:
true if the shortcut has the given key sequence

Definition at line 562 of file kshortcut.cpp.

References contains(), count(), and KKeySequence::isNull().

bool KShortcut::setSeq uint  i,
const KKeySequence keySeq
 

Sets the i 'th key sequence of the shortcut.

You can not introduce gaps in the list of sequences, so you must use an i <= count(). Also note that the maximum number of key sequences is MAX_SEQUENCES.

Parameters:
i the position of the new key sequence(<= count(), <= MAX_SEQUENCES)
keySeq the key sequence to set
Returns:
true if successful, false otherwise

Definition at line 571 of file kshortcut.cpp.

References setSeq().

Referenced by setSeq().

bool KShortcut::append const KKeySequence keySeq  ) 
 

Appends the given key sequence.

Parameters:
keySeq the key sequence to add
Returns:
true if successful, false otherwise
See also:
setSeq()

MAX_SEQUENCES

Definition at line 583 of file kshortcut.cpp.

References append(), and KKeySequence::isNull().

Referenced by append().

bool KShortcut::append const KKey spec  ) 
 

Appends the given key.

Parameters:
spec the key to add
Returns:
true if successful, false otherwise
See also:
setSeq()

MAX_SEQUENCES

Since:
3.2

Definition at line 595 of file kshortcut.cpp.

References append(), and KKeySequence::init().

bool KShortcut::append const KShortcut cut  ) 
 

Appends the sequences from the given shortcut.

Parameters:
cut the shortcut to append
Returns:
true if successful, false otherwise
See also:
MAX_SEQUENCES
Since:
3.2

Definition at line 605 of file kshortcut.cpp.

References append(), contains(), and seq().

KShortcut::operator QKeySequence  )  const
 

Converts this shortcut to a key sequence.

The first key sequence will be taken.

Definition at line 623 of file kshortcut.cpp.

References count(), and KKeySequence::qt().

QString KShortcut::toString  )  const
 

Returns a description of the shortcut as semicolon-separated ket sequences, as returned by KKeySequence::toString().

Returns:
the string represenation of this shortcut
See also:
KKey::toString()

KKeySequence::toString()

Definition at line 631 of file kshortcut.cpp.

References count(), and KKeySequence::toString().

KShortcut & KShortcut::null  )  [static]
 

Returns a null shortcut.

Returns:
the null shortcut
See also:
isNull()

clear()

Definition at line 663 of file kshortcut.cpp.

References clear(), and isNull().

Referenced by KStdAccel::shortcut(), KGlobalAccel::shortcut(), and KAccel::shortcut().


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.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 16 17:21:47 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003