.TH "KShortcut" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KShortcut \- The KShortcut class is used to represent a keyboard shortcut to an action.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kshortcut.h>\fP
.PP
.SS "Public Types"

.in +1c
.ti -1c
.RI "enum { \fBMAX_SEQUENCES\fP =  2 }"
.br
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKShortcut\fP ()"
.br
.ti -1c
.RI "\fBKShortcut\fP (int keyQt)"
.br
.ti -1c
.RI "\fBKShortcut\fP (const \fBQKeySequence\fP &keySeq)"
.br
.ti -1c
.RI "\fBKShortcut\fP (const \fBKKey\fP &key)"
.br
.ti -1c
.RI "\fBKShortcut\fP (const \fBKKeySequence\fP &keySeq)"
.br
.ti -1c
.RI "\fBKShortcut\fP (const \fBKShortcut\fP &shortcut)"
.br
.ti -1c
.RI "\fBKShortcut\fP (const char *shortcut)"
.br
.ti -1c
.RI "\fBKShortcut\fP (const \fBQString\fP &shortcut)"
.br
.ti -1c
.RI "void \fBclear\fP ()"
.br
.ti -1c
.RI "bool \fBinit\fP (int keyQt)"
.br
.ti -1c
.RI "bool \fBinit\fP (const \fBQKeySequence\fP &keySeq)"
.br
.ti -1c
.RI "bool \fBinit\fP (const \fBKKey\fP &key)"
.br
.ti -1c
.RI "bool \fBinit\fP (const \fBKKeySequence\fP &keySeq)"
.br
.ti -1c
.RI "bool \fBinit\fP (const \fBKShortcut\fP &shortcut)"
.br
.ti -1c
.RI "bool \fBinit\fP (const \fBQString\fP &shortcut)"
.br
.ti -1c
.RI "\fBKShortcut\fP & \fBoperator=\fP (const \fBKShortcut\fP &cut)"
.br
.ti -1c
.RI "uint \fBcount\fP () const "
.br
.ti -1c
.RI "const \fBKKeySequence\fP & \fBseq\fP (uint i) const "
.br
.ti -1c
.RI "int \fBkeyCodeQt\fP () const "
.br
.ti -1c
.RI "bool \fBisNull\fP () const "
.br
.ti -1c
.RI "int \fBcompare\fP (const \fBKShortcut\fP &shortcut) const "
.br
.ti -1c
.RI "bool \fBoperator==\fP (const \fBKShortcut\fP &cut) const "
.br
.ti -1c
.RI "bool \fBoperator!=\fP (const \fBKShortcut\fP &cut) const "
.br
.ti -1c
.RI "bool \fBoperator<\fP (const \fBKShortcut\fP &cut) const "
.br
.ti -1c
.RI "bool \fBcontains\fP (const \fBKKey\fP &key) const "
.br
.ti -1c
.RI "bool \fBcontains\fP (const \fBKKeyNative\fP &key) const "
.br
.ti -1c
.RI "bool \fBcontains\fP (const \fBKKeySequence\fP &keySeq) const "
.br
.ti -1c
.RI "bool \fBsetSeq\fP (uint i, const \fBKKeySequence\fP &keySeq)"
.br
.ti -1c
.RI "bool \fBappend\fP (const \fBKKeySequence\fP &keySeq)"
.br
.ti -1c
.RI "void \fBremove\fP (const \fBKKeySequence\fP &keySeq)"
.br
.ti -1c
.RI "bool \fBappend\fP (const \fBKKey\fP &spec)"
.br
.ti -1c
.RI "bool \fBappend\fP (const \fBKShortcut\fP &cut)"
.br
.ti -1c
.RI "\fBoperator QKeySequence\fP () const "
.br
.ti -1c
.RI "\fBQString\fP \fBtoString\fP () const "
.br
.ti -1c
.RI "\fBQString\fP \fBtoStringInternal\fP (const \fBKShortcut\fP *pcutDefault=0) const "
.br
.ti -1c
.RI "\fBoperator int\fP () const "
.br
.in -1c
.SS "Static Public Member Functions"

.in +1c
.ti -1c
.RI "static \fBKShortcut\fP & \fBnull\fP ()"
.br
.in -1c
.SS "Protected Attributes"

.in +1c
.ti -1c
.RI "uint \fBm_nSeqs\fP"
.br
.ti -1c
.RI "\fBKKeySequence\fP \fBm_rgseq\fP [MAX_SEQUENCES]"
.br
.in -1c
.SS "Friends"

.in +1c
.ti -1c
.RI "class \fBKKeyNative\fP"
.br
.in -1c
.SH "Detailed Description"
.PP 
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.
.PP
This can be used to add additional accelerators to a \fBKAction\fP. For example, the below code binds the escape key to the close action.
.PP
.PP
.nf
  KAction *closeAction = KStdAction::close( this, SLOT( close() ), actionCollection() );
  KShortcut closeShortcut = closeAction->shortcut();
  closeShortcut.append( KKey(Key_Escape));
  closeAction->setShortcut(closeShortcut);
.fi
.PP
.PP
Note that a shortcut cannot have more than 2 key combinations associated with it, so the above code would not do anything (and .append would return false) if the closeAction already had an key and alternate key. 
.PP
Definition at line 543 of file kshortcut.h.
.SH "Member Enumeration Documentation"
.PP 
.SS "anonymous enum"
.PP
The maximum number of key sequences that can be contained in a KShortcut. 
.PP
Definition at line 550 of file kshortcut.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KShortcut::KShortcut ()"
.PP
Creates a new null shortcut. 
.PP
\fBSee also:\fP
.RS 4
\fBnull()\fP 
.PP
\fBisNull()\fP 
.PP
\fBclear()\fP
.RE
.PP

.PP
Definition at line 414 of file kshortcut.cpp.
.PP
References clear().
.SS "KShortcut::KShortcut (int keyQt)"
.PP
Creates a new shortcut with the given \fBQt\fP key code as the only key sequence. 
.PP
\fBParameters:\fP
.RS 4
\fIkeyQt\fP the qt keycode 
.RE
.PP
\fBSee also:\fP
.RS 4
Qt::Key
.RE
.PP

.PP
Definition at line 415 of file kshortcut.cpp.
.PP
References init().
.SS "KShortcut::KShortcut (const \fBQKeySequence\fP & keySeq)"
.PP
Creates a new shortcut that contains only the given qt key sequence. 
.PP
\fBParameters:\fP
.RS 4
\fIkeySeq\fP the qt key sequence to add
.RE
.PP

.PP
Definition at line 416 of file kshortcut.cpp.
.PP
References init().
.SS "KShortcut::KShortcut (const \fBKKey\fP & key)"
.PP
Creates a new shortcut that contains only the given key in its only sequence. 
.PP
\fBParameters:\fP
.RS 4
\fIkey\fP the key to add
.RE
.PP

.PP
Definition at line 417 of file kshortcut.cpp.
.PP
References init().
.SS "KShortcut::KShortcut (const \fBKKeySequence\fP & keySeq)"
.PP
Creates a new shortcut that contains only the given key sequence. 
.PP
\fBParameters:\fP
.RS 4
\fIkeySeq\fP the key sequence to add
.RE
.PP

.PP
Definition at line 418 of file kshortcut.cpp.
.PP
References init(), and seq().
.SS "KShortcut::KShortcut (const \fBKShortcut\fP & shortcut)"
.PP
Copies the given shortcut. 
.PP
\fBParameters:\fP
.RS 4
\fIshortcut\fP the shortcut to add
.RE
.PP

.PP
Definition at line 419 of file kshortcut.cpp.
.PP
References init().
.SS "KShortcut::KShortcut (const char * shortcut)"
.PP
Creates a new key sequence that contains the given key sequence. 
.PP
The description consists of semicolon-separated keys as used in \fBKKeySequence::KKeySequence(const QString&)\fP. 
.PP
\fBParameters:\fP
.RS 4
\fIshortcut\fP the description of the key 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBKKeySequence::KKeySequence(const QString&)\fP
.RE
.PP

.PP
Definition at line 420 of file kshortcut.cpp.
.PP
References init().
.SS "KShortcut::KShortcut (const \fBQString\fP & shortcut)"
.PP
Creates a new key sequence that contains the given key sequence. 
.PP
The description consists of semicolon-separated keys as used in \fBKKeySequence::KKeySequence(const QString&)\fP. 
.PP
\fBParameters:\fP
.RS 4
\fIshortcut\fP the description of the key 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBKKeySequence::KKeySequence(const QString&)\fP
.RE
.PP

.PP
Definition at line 421 of file kshortcut.cpp.
.PP
References init().
.SH "Member Function Documentation"
.PP 
.SS "void KShortcut::clear ()"
.PP
Clears the shortcut. 
.PP
The shortcut is null after calling this function. 
.PP
\fBSee also:\fP
.RS 4
\fBisNull()\fP
.RE
.PP

.PP
Definition at line 427 of file kshortcut.cpp.
.PP
Referenced by init(), KShortcut(), and null().
.SS "bool KShortcut::init (int keyQt)"
.PP
Initializes the shortcut with the given \fBQt\fP key code as the only key sequence. 
.PP
\fBParameters:\fP
.RS 4
\fIkeyQt\fP the qt keycode 
.RE
.PP
\fBSee also:\fP
.RS 4
Qt::Key
.RE
.PP

.PP
Definition at line 432 of file kshortcut.cpp.
.PP
References clear(), and KKeySequence::init().
.PP
Referenced by KShortcut().
.SS "bool KShortcut::init (const \fBQKeySequence\fP & keySeq)"
.PP
Initializes the shortcut with the given qt key sequence. 
.PP
\fBParameters:\fP
.RS 4
\fIkeySeq\fP the qt key sequence to add
.RE
.PP

.PP
Definition at line 442 of file kshortcut.cpp.
.PP
References KKeySequence::init().
.SS "bool KShortcut::init (const \fBKKey\fP & key)"
.PP
Initializes the shortcut with the given key as its only sequence. 
.PP
\fBParameters:\fP
.RS 4
\fIkey\fP the key to add
.RE
.PP

.PP
Definition at line 449 of file kshortcut.cpp.
.PP
References KKeySequence::init().
.SS "bool KShortcut::init (const \fBKKeySequence\fP & keySeq)"
.PP
Initializes the shortcut with the given qt key sequence. 
.PP
\fBParameters:\fP
.RS 4
\fIkeySeq\fP the qt key sequence to add
.RE
.PP

.PP
Definition at line 456 of file kshortcut.cpp.
.PP
References seq().
.SS "bool KShortcut::init (const \fBKShortcut\fP & shortcut)"
.PP
Copies the given shortcut. 
.PP
\fBParameters:\fP
.RS 4
\fIshortcut\fP the shortcut to add
.RE
.PP

.PP
Definition at line 463 of file kshortcut.cpp.
.SS "bool KShortcut::init (const \fBQString\fP & shortcut)"
.PP
Initializes the key sequence with the given key sequence. 
.PP
The description consists of semicolon-separated keys as used in \fBKKeySequence::KKeySequence(const QString&)\fP. 
.PP
\fBParameters:\fP
.RS 4
\fIshortcut\fP the description of the key 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBKKeySequence::KKeySequence(const QString&)\fP
.RE
.PP

.PP
Definition at line 471 of file kshortcut.cpp.
.PP
References clear(), KKeyServer::Variations::count(), endl(), KKeyServer::Variations::init(), KKeySequence::init(), QString::length(), KKeyServer::Variations::m_rgkey, QString::mid(), QString::number(), QStringList::split(), and QString::startsWith().
.SS "\fBKShortcut\fP& KShortcut::operator= (const \fBKShortcut\fP & cut)\fC [inline]\fP"
.PP
Copies the given shortcut over this shortcut. 
.PP

.PP
Definition at line 665 of file kshortcut.h.
.SS "uint KShortcut::count () const"
.PP
Returns the number of sequences that are in this shortcut. 
.PP
\fBReturns:\fP
.RS 4
the number of sequences MAX_SEQUENCES
.RE
.PP

.PP
Definition at line 509 of file kshortcut.cpp.
.PP
Referenced by contains(), operator QKeySequence(), and toString().
.SS "const \fBKKeySequence\fP & KShortcut::seq (uint i) const"
.PP
Returns the \fCi'th\fP key sequence of this shortcut. 
.PP
\fBParameters:\fP
.RS 4
\fIi\fP the number of the key sequence to retrieve 
.RE
.PP
\fBReturns:\fP
.RS 4
the \fCi'th\fP sequence or \fBKKeySequence::null()\fP if there are less than \fCi\fP key sequences MAX_SEQUENCES
.RE
.PP

.PP
Definition at line 514 of file kshortcut.cpp.
.PP
References KKeySequence::null().
.PP
Referenced by append(), contains(), init(), KShortcut(), remove(), and setSeq().
.SS "int KShortcut::keyCodeQt () const"
.PP
Returns the key code of the first key sequence, or null if there is no first key sequence. 
.PP
\fBReturns:\fP
.RS 4
the key code of the first sequence's first key 
.RE
.PP
\fBSee also:\fP
.RS 4
Qt::Key 
.PP
\fBKKeySequence::keyCodeQt()\fP
.RE
.PP

.PP
Definition at line 519 of file kshortcut.cpp.
.PP
References KKeySequence::keyCodeQt().
.PP
Referenced by KStdAccel::defaultKey(), and KStdAccel::key().
.SS "bool KShortcut::isNull () const"
.PP
Returns true if the shortcut is null (after \fBclear()\fP or empty constructor). 
.PP
\fBReturns:\fP
.RS 4
true if the shortcut is null 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBclear()\fP 
.PP
\fBnull()\fP
.RE
.PP

.PP
Definition at line 526 of file kshortcut.cpp.
.PP
Referenced by KCompletion::makeCompletion(), and null().
.SS "int KShortcut::compare (const \fBKShortcut\fP & shortcut) const"
.PP
Compares this object with the given shortcut. 
.PP
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. 
.PP
\fBParameters:\fP
.RS 4
\fIshortcut\fP the shortcut to compare to 
.RE
.PP
\fBReturns:\fP
.RS 4
a negative number if the given KShortcut is larger, 0 if they are equal and a positive number this KShortcut is larger 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBKKey::compare()\fP 
.PP
KKeyShortcut::compare()
.RE
.PP

.PP
Definition at line 531 of file kshortcut.cpp.
.PP
References KKeySequence::compare().
.SS "bool KShortcut::operator== (const \fBKShortcut\fP & cut) const\fC [inline]\fP"
.PP
Compares the sequences of both shortcuts. 
.PP
\fBSee also:\fP
.RS 4
\fBcompare()\fP
.RE
.PP

.PP
Definition at line 722 of file kshortcut.h.
.SS "bool KShortcut::operator!= (const \fBKShortcut\fP & cut) const\fC [inline]\fP"
.PP
Compares the sequences of both shortcuts. 
.PP
\fBSee also:\fP
.RS 4
\fBcompare()\fP
.RE
.PP

.PP
Definition at line 729 of file kshortcut.h.
.SS "bool KShortcut::operator< (const \fBKShortcut\fP & cut) const\fC [inline]\fP"
.PP
Compares the sequences of both shortcuts. 
.PP
\fBSee also:\fP
.RS 4
\fBcompare()\fP
.RE
.PP

.PP
Definition at line 736 of file kshortcut.h.
.SS "bool KShortcut::contains (const \fBKKey\fP & key) const"
.PP
Checks whether this shortcut contains a sequence that starts with the given key. 
.PP
\fBParameters:\fP
.RS 4
\fIkey\fP the key to check 
.RE
.PP
\fBReturns:\fP
.RS 4
true if a key sequence starts with the key
.RE
.PP

.PP
Definition at line 541 of file kshortcut.cpp.
.PP
Referenced by append(), and KShortcutList::index().
.SS "bool KShortcut::contains (const \fBKKeyNative\fP & key) const"
.PP
Checks whether this shortcut contains a sequence that starts with the given key. 
.PP
\fBParameters:\fP
.RS 4
\fIkey\fP the key to check 
.RE
.PP
\fBReturns:\fP
.RS 4
true if a key sequence starts with the key
.RE
.PP

.PP
Definition at line 546 of file kshortcut.cpp.
.PP
References KKeySequence::count(), count(), KKeySequence::isNull(), KKeySequence::key(), and KKey::simplify().
.SS "bool KShortcut::contains (const \fBKKeySequence\fP & keySeq) const"
.PP
Checks whether this shortcut contains the given sequence. 
.PP
\fBParameters:\fP
.RS 4
\fIkeySeq\fP the key sequence to check 
.RE
.PP
\fBReturns:\fP
.RS 4
true if the shortcut has the given key sequence
.RE
.PP

.PP
Definition at line 560 of file kshortcut.cpp.
.PP
References count(), KKeySequence::isNull(), and seq().
.SS "bool KShortcut::setSeq (uint i, const \fBKKeySequence\fP & keySeq)"
.PP
Sets the \fCi\fP 'th key sequence of the shortcut. 
.PP
You can not introduce gaps in the list of sequences, so you must use an \fCi\fP <= \fBcount()\fP. Also note that the maximum number of key sequences is MAX_SEQUENCES. 
.PP
\fBParameters:\fP
.RS 4
\fIi\fP the position of the new key sequence(0 <= i <= \fBcount()\fP, 0 <= i < MAX_SEQUENCES) 
.br
\fIkeySeq\fP the key sequence to set 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise
.RE
.PP

.PP
Definition at line 569 of file kshortcut.cpp.
.PP
References seq().
.SS "bool KShortcut::append (const \fBKKeySequence\fP & keySeq)"
.PP
Appends the given key sequence. 
.PP
This sets it as either the keysequence or the alternate keysequence. If the shortcut already has MAX_SEQUENCES sequences then this call does nothing, and returns false.
.PP
\fBParameters:\fP
.RS 4
\fIkeySeq\fP the key sequence to add 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBsetSeq()\fP
.RE
.PP

.PP
Definition at line 596 of file kshortcut.cpp.
.PP
References KKeySequence::isNull(), and seq().
.SS "void KShortcut::remove (const \fBKKeySequence\fP & keySeq)"
.PP
Removes the given key sequence from this shortcut. 
.PP
\fBParameters:\fP
.RS 4
\fIkeySeq\fP the key sequence to remove 
.RE
.PP
\fBSince:\fP
.RS 4
3.3
.RE
.PP

.PP
Definition at line 581 of file kshortcut.cpp.
.PP
References KKeySequence::isNull(), and seq().
.SS "bool KShortcut::append (const \fBKKey\fP & spec)"
.PP
Appends the given key. 
.PP
\fBParameters:\fP
.RS 4
\fIspec\fP the key to add 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBsetSeq()\fP 
.PP
MAX_SEQUENCES 
.RE
.PP
\fBSince:\fP
.RS 4
3.2
.RE
.PP

.PP
Definition at line 608 of file kshortcut.cpp.
.PP
References KKeySequence::init().
.SS "bool KShortcut::append (const \fBKShortcut\fP & cut)"
.PP
Appends the sequences from the given shortcut. 
.PP
\fBParameters:\fP
.RS 4
\fIcut\fP the shortcut to append 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP
\fBSee also:\fP
.RS 4
MAX_SEQUENCES 
.RE
.PP
\fBSince:\fP
.RS 4
3.2
.RE
.PP

.PP
Definition at line 618 of file kshortcut.cpp.
.PP
References contains(), and seq().
.SS "KShortcut::operator \fBQKeySequence\fP () const"
.PP
Converts this shortcut to a key sequence. 
.PP
The first key sequence will be taken.
.PP
Definition at line 636 of file kshortcut.cpp.
.PP
References count(), and KKeySequence::qt().
.SS "\fBQString\fP KShortcut::toString () const"
.PP
Returns a description of the shortcut as semicolon-separated ket sequences, as returned by \fBKKeySequence::toString()\fP. 
.PP
\fBReturns:\fP
.RS 4
the string represenation of this shortcut 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBKKey::toString()\fP 
.PP
\fBKKeySequence::toString()\fP
.RE
.PP

.PP
Definition at line 644 of file kshortcut.cpp.
.PP
References count(), and KKeySequence::toString().
.SS "\fBKShortcut\fP & KShortcut::null ()\fC [static]\fP"
.PP
Returns a null shortcut. 
.PP
\fBReturns:\fP
.RS 4
the null shortcut 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBisNull()\fP 
.PP
\fBclear()\fP
.RE
.PP

.PP
Definition at line 676 of file kshortcut.cpp.
.PP
References clear(), and isNull().
.PP
Referenced by KStdAccel::shortcut(), KGlobalAccel::shortcut(), and KAccel::shortcut().

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
