# kdecore Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# KKeySequence Class Reference

A KKeySequence object holds a sequence of up to 4 keys. More...

`#include <kshortcut.h>`

Collaboration diagram for KKeySequence:

[legend]
List of all members.

## Public Types

enum | { MAX_KEYS = 4 }

## Public Member Functions

| KKeySequence ()
| KKeySequence (const QKeySequence &keySeq)
| KKeySequence (const KKey &key)
| KKeySequence (const KKeyNative &key)
| KKeySequence (const KKeySequence &keySeq)
| KKeySequence (const QString &keySeq)
void | clear ()
bool | init (const QKeySequence &keySeq)
bool | init (const KKey &key)
bool | init (const KKeyNative &key)
bool | init (const KKeySequence &keySeq)
bool | init (const QString &key)
KKeySequence & | operator= (const KKeySequence &seq)
uint | count () const
const KKey & | key (uint i) const
bool | isTriggerOnRelease () const
bool | setKey (uint i, const KKey &key)
bool | isNull () const
bool | startsWith (const KKeySequence &keySeq) const
int | compare (const KKeySequence &keySeq) const
bool | operator== (const KKeySequence &seq) const
bool | operator!= (const KKeySequence &seq) const
bool | operator< (const KKeySequence &seq) const
QKeySequence | qt () const
int | keyCodeQt () const
QString | toString () const
QString | toStringInternal () const

## Static Public Member Functions

static KKeySequence & | null ()

## Protected Attributes

uchar | m_nKeys
uchar | m_bTriggerOnRelease
KKey | m_rgvar [MAX_KEYS]

## Friends

class | KKeyNative

## Detailed Description

A KKeySequence object holds a sequence of up to 4 keys.

Ex: Ctrl+X,I

See also:
  KKey

  KShortcut

Definition at line 288 of file kshortcut.h.

## Member Enumeration Documentation

anonymous enum

| Defines the maximum length of the key sequence. Definition at line 292 of file kshortcut.h.

## Constructor & Destructor Documentation

KKeySequence::KKeySequence | ( |  | ) |

Create a new null key sequence.

See also:
  isNull()

  null()

  clear()

Definition at line 206 of file kshortcut.cpp.

References clear().

KKeySequence::KKeySequence | ( | const QKeySequence & | keySeq | ) |

Copies the given qt key sequence.

Parameters:

  | keySeq | the qt key sequence to copy

Definition at line 207 of file kshortcut.cpp.

References init().

KKeySequence::KKeySequence | ( | const KKey & | key | ) |

Create a new key sequence that only contains the given key.

Parameters:

  | key | the key to add

Definition at line 208 of file kshortcut.cpp.

References init(), and key().

KKeySequence::KKeySequence | ( | const KKeyNative & | key | ) |

Create a new key sequence that only contains the given key.

Parameters:

  | key | the key to add

KKeySequence::KKeySequence | ( | const KKeySequence & | keySeq | ) |

Copies the given key sequence.

Parameters:

  | keySeq | the key sequence to copy

Definition at line 209 of file kshortcut.cpp.

References init().

KKeySequence::KKeySequence | ( | const QString & | keySeq | ) |

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

The description consists of comma-separated keys as required by KKey::KKey(const QString&).

Parameters:

  | keySeq | the description of the key

See also:
  KKeyServer::Sym::init()

  KKey::KKey(const QString&)

Definition at line 210 of file kshortcut.cpp.

References init().

## Member Function Documentation

void KKeySequence::clear | ( |  | ) |

Clears the key sequence.

The key sequence is null after calling this function.

See also:
  isNull()

Definition at line 216 of file kshortcut.cpp.

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

bool KKeySequence::init | ( | const QKeySequence & | keySeq | ) |

Copies the given qt key sequence over this key sequence.

Parameters:

  | keySeq | the qt key sequence to copy

Returns:
  true if successful, false otherwise

Definition at line 222 of file kshortcut.cpp.

References clear(), KKey::init(), and KKey::isNull().

Referenced by KShortcut::append(), KShortcut::init(), KKeySequence(), and KStdAccel::shortcutDefault4().

bool KKeySequence::init | ( | const KKey & | key | ) |

Initializes the key sequence to only contain the given key.

Parameters:

  | key | the key to set

Returns:
  true if successful, false otherwise

Definition at line 247 of file kshortcut.cpp.

References clear(), KKey::init(), KKey::isNull(), and key().

bool KKeySequence::init | ( | const KKeyNative & | key | ) |

Initializes the key sequence to only contain the given key.

Parameters:

  | key | the key to set

Returns:
  true if successful, false otherwise

bool KKeySequence::init | ( | const KKeySequence & | keySeq | ) |

Copies the given key sequence over this key sequence.

Parameters:

  | keySeq | the key sequence to copy

Returns:
  true if successful, false otherwise

Definition at line 258 of file kshortcut.cpp.

References endl().

bool KKeySequence::init | ( | const QString & | key | ) |

Initializes this key sequence to contain the given key sequence.

The description consists of comma-separated keys as required by KKey::KKey(const QString&).

Parameters:

  | key | the description of the key

Returns:
  true if successful, false otherwise

See also:
  KKeyServer::Sym::init()

  KKey::KKey(const QString&)

Definition at line 273 of file kshortcut.cpp.

References clear(), KKey::init(), and QStringList::split().

KKeySequence& KKeySequence::operator= | ( | const KKeySequence & | seq | ) | `[inline]`

| Copy the given key sequence into this sequence. Definition at line 387 of file kshortcut.h.

uint KKeySequence::count | ( |  | ) | const

Returns the number of key strokes of this sequence.

Returns:
  the number of key strokes

See also:
  MAX_KEYS

Definition at line 294 of file kshortcut.cpp.

Referenced by KShortcut::contains(), keyCodeQt(), qt(), and KStdAccel::shortcutDefault4().

const KKey & KKeySequence::key | ( | uint | i | ) | const

Return the `i'th` key of this sequence, or a null key if there are less then i keys.

Parameters:

  | i | the key to retrieve

Returns:
  the `i'th` key, or KKey::null() if there are less than i keys

See also:
  MAX_KEYS

Definition at line 299 of file kshortcut.cpp.

References KKey::null().

Referenced by KShortcut::contains(), init(), keyCodeQt(), KKeySequence(), qt(), and setKey().

bool KKeySequence::setKey | ( | uint | i,
|  | const KKey & | key
| ) |

Sets the `i'th` key of the sequence.

You can not introduce gaps in a sequence, so you must use an `i` <= count(). Also note that the maximum length of a key sequence is MAX_KEYS.

Parameters:

  | i | the position of the new key (<= count(), <= MAX_KEYS)
  | key | the key to set

Returns:
  true if successful, false otherwise

Definition at line 310 of file kshortcut.cpp.

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

bool KKeySequence::isNull | ( |  | ) | const

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

Returns:
  true if the key sequence is null

See also:
  clear()

  null()

Definition at line 321 of file kshortcut.cpp.

Referenced by KShortcut::append(), KShortcut::contains(), null(), and KShortcut::remove().

bool KKeySequence::startsWith | ( | const KKeySequence & | keySeq | ) | const

Returns true if this key sequence begins with the given sequence.

Parameters:

  | keySeq | the key sequence to search

Returns:
  true if this key sequence begins with the given sequence

Definition at line 326 of file kshortcut.cpp.

int KKeySequence::compare | ( | const KKeySequence & | keySeq | ) | const

Compares this object with the given key sequence.

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

Parameters:

  | keySeq | the key sequence to compare to

Returns:
  a negative number if the given KKeySequence is larger, 0 if they are equal and a positive number this KKeySequence is larger

See also:
  KKey::sequence

Definition at line 339 of file kshortcut.cpp.

References KKey::compare().

Referenced by KShortcut::compare().

bool KKeySequence::operator== | ( | const KKeySequence & | seq | ) | const`[inline]`

Compares the keys of both sequences.

See also:
  compare()

Definition at line 456 of file kshortcut.h.

bool KKeySequence::operator!= | ( | const KKeySequence & | seq | ) | const`[inline]`

Compares the keys of both sequences.

See also:
  compare()

Definition at line 463 of file kshortcut.h.

bool KKeySequence::operator< | ( | const KKeySequence & | seq | ) | const`[inline]`

Compares the keys of both sequences.

See also:
  compare()

Definition at line 470 of file kshortcut.h.

QKeySequence KKeySequence::qt | ( |  | ) | const

Converts this key sequence to a QKeySequence.

Returns:
  the QKeySequence

Definition at line 352 of file kshortcut.cpp.

References count(), and key().

Referenced by KShortcut::operator QKeySequence().

int KKeySequence::keyCodeQt | ( |  | ) | const

Returns the qt key code of the first key.

Returns:
  the qt key code of the first key

See also:
  Qt::Key

  KKey::keyCodeQt()

Definition at line 368 of file kshortcut.cpp.

References count(), and key().

Referenced by KShortcut::keyCodeQt().

QString KKeySequence::toString | ( |  | ) | const

Returns the key sequence as a number of key presses as returned by KKey::toString(), separated by commas.

Returns:
  the string represenation of this key sequence

See also:
  KKey::toString()

Definition at line 373 of file kshortcut.cpp.

References KKey::toString().

Referenced by KShortcut::toString().

KKeySequence & KKeySequence::null | ( |  | ) | `[static]`

Returns a null key sequence.

Returns:
  the null key sequence

See also:
  isNull()

  clear()

Definition at line 401 of file kshortcut.cpp.

References clear(), and isNull().

Referenced by KShortcut::seq().

The documentation for this class was generated from the following files:

- kshortcut.h
- kshortcut.cpp

This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:18:43 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003