1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the gui module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
29
#include "qkeysequence.h"
31
#include "qshortcut.h"
36
#ifndef QT_NO_DATASTREAM
37
# include "qdatastream.h"
42
# include <private/qt_mac_p.h>
43
# define QMAC_CTRL QChar(kCommandUnicode)
44
# define QMAC_META QChar(kControlUnicode)
45
# define QMAC_ALT QChar(kOptionUnicode)
46
# define QMAC_SHIFT QChar(kShiftUnicode)
50
static bool qt_sequence_no_mnemonics = true;
52
static bool qt_sequence_no_mnemonics = false;
54
void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemonics = !b; }
58
\brief The QKeySequence class encapsulates a key sequence as used
64
A key sequence consists of up to four keyboard codes, each
65
optionally combined with modifiers, such as \c Qt::SHIFT, \c Qt::CTRL, \c
66
Qt::ALT or \c Qt::META. For example, \c{Qt::CTRL + Qt::Key_P}
67
might be a sequence used as a shortcut for printing a document.
68
Valid codes for keys and modifiers are listed in Qt::Key and
69
Qt::Modifier. As an alternative, use the unicode code point of the
70
character; for example, \c{'A'} gives the same key sequence
73
Key sequences can be constructed either from an integer key code,
74
or from a human readable translatable string such as
75
"Ctrl+X,Alt+Space". A key sequence can be cast to a QString to
76
obtain a human readable translated version of the sequence.
77
Translations are done in the "QShortcut" context.
79
In code that does not inherit the Qt namespace class, you must
80
include the namespace when writing keycodes; for example,
81
instead of Qt::ALT+Qt::Key_Q you would write Qt::ALT+Qt::Key_Q.
87
\enum QKeySequence::SequenceMatch
89
\value NoMatch The key sequences are different; not even partially
91
\value PartialMatch The key sequences match partially, but are not
93
\value ExactMatch The key sequences are the same.
101
{ Qt::Key_Space, QT_TRANSLATE_NOOP("QShortcut", "Space") },
102
{ Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Esc") },
103
{ Qt::Key_Tab, QT_TRANSLATE_NOOP("QShortcut", "Tab") },
104
{ Qt::Key_Backtab, QT_TRANSLATE_NOOP("QShortcut", "Backtab") },
105
{ Qt::Key_Backspace, QT_TRANSLATE_NOOP("QShortcut", "Backspace") },
106
{ Qt::Key_Return, QT_TRANSLATE_NOOP("QShortcut", "Return") },
107
{ Qt::Key_Enter, QT_TRANSLATE_NOOP("QShortcut", "Enter") },
108
{ Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Ins") },
109
{ Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Del") },
110
{ Qt::Key_Pause, QT_TRANSLATE_NOOP("QShortcut", "Pause") },
111
{ Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print") },
112
{ Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "SysReq") },
113
{ Qt::Key_Home, QT_TRANSLATE_NOOP("QShortcut", "Home") },
114
{ Qt::Key_End, QT_TRANSLATE_NOOP("QShortcut", "End") },
115
{ Qt::Key_Left, QT_TRANSLATE_NOOP("QShortcut", "Left") },
116
{ Qt::Key_Up, QT_TRANSLATE_NOOP("QShortcut", "Up") },
117
{ Qt::Key_Right, QT_TRANSLATE_NOOP("QShortcut", "Right") },
118
{ Qt::Key_Down, QT_TRANSLATE_NOOP("QShortcut", "Down") },
119
{ Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "PgUp") },
120
{ Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "PgDown") },
121
{ Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "CapsLock") },
122
{ Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "NumLock") },
123
{ Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "ScrollLock") },
124
{ Qt::Key_Menu, QT_TRANSLATE_NOOP("QShortcut", "Menu") },
125
{ Qt::Key_Help, QT_TRANSLATE_NOOP("QShortcut", "Help") },
128
{ Qt::Key_Back, QT_TRANSLATE_NOOP("QShortcut", "Back") },
129
{ Qt::Key_Forward, QT_TRANSLATE_NOOP("QShortcut", "Forward") },
130
{ Qt::Key_Stop, QT_TRANSLATE_NOOP("QShortcut", "Stop") },
131
{ Qt::Key_Refresh, QT_TRANSLATE_NOOP("QShortcut", "Refresh") },
132
{ Qt::Key_VolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Volume Down") },
133
{ Qt::Key_VolumeMute, QT_TRANSLATE_NOOP("QShortcut", "Volume Mute") },
134
{ Qt::Key_VolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Volume Up") },
135
{ Qt::Key_BassBoost, QT_TRANSLATE_NOOP("QShortcut", "Bass Boost") },
136
{ Qt::Key_BassUp, QT_TRANSLATE_NOOP("QShortcut", "Bass Up") },
137
{ Qt::Key_BassDown, QT_TRANSLATE_NOOP("QShortcut", "Bass Down") },
138
{ Qt::Key_TrebleUp, QT_TRANSLATE_NOOP("QShortcut", "Treble Up") },
139
{ Qt::Key_TrebleDown, QT_TRANSLATE_NOOP("QShortcut", "Treble Down") },
140
{ Qt::Key_MediaPlay, QT_TRANSLATE_NOOP("QShortcut", "Media Play") },
141
{ Qt::Key_MediaStop, QT_TRANSLATE_NOOP("QShortcut", "Media Stop") },
142
{ Qt::Key_MediaPrevious,QT_TRANSLATE_NOOP("QShortcut", "Media Previous") },
143
{ Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") },
144
{ Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") },
145
{ Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home") },
146
{ Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") },
147
{ Qt::Key_Search, QT_TRANSLATE_NOOP("QShortcut", "Search") },
148
{ Qt::Key_Standby, QT_TRANSLATE_NOOP("QShortcut", "Standby") },
149
{ Qt::Key_OpenUrl, QT_TRANSLATE_NOOP("QShortcut", "Open URL") },
150
{ Qt::Key_LaunchMail, QT_TRANSLATE_NOOP("QShortcut", "Launch Mail") },
151
{ Qt::Key_LaunchMedia, QT_TRANSLATE_NOOP("QShortcut", "Launch Media") },
152
{ Qt::Key_Launch0, QT_TRANSLATE_NOOP("QShortcut", "Launch (0)") },
153
{ Qt::Key_Launch1, QT_TRANSLATE_NOOP("QShortcut", "Launch (1)") },
154
{ Qt::Key_Launch2, QT_TRANSLATE_NOOP("QShortcut", "Launch (2)") },
155
{ Qt::Key_Launch3, QT_TRANSLATE_NOOP("QShortcut", "Launch (3)") },
156
{ Qt::Key_Launch4, QT_TRANSLATE_NOOP("QShortcut", "Launch (4)") },
157
{ Qt::Key_Launch5, QT_TRANSLATE_NOOP("QShortcut", "Launch (5)") },
158
{ Qt::Key_Launch6, QT_TRANSLATE_NOOP("QShortcut", "Launch (6)") },
159
{ Qt::Key_Launch7, QT_TRANSLATE_NOOP("QShortcut", "Launch (7)") },
160
{ Qt::Key_Launch8, QT_TRANSLATE_NOOP("QShortcut", "Launch (8)") },
161
{ Qt::Key_Launch9, QT_TRANSLATE_NOOP("QShortcut", "Launch (9)") },
162
{ Qt::Key_LaunchA, QT_TRANSLATE_NOOP("QShortcut", "Launch (A)") },
163
{ Qt::Key_LaunchB, QT_TRANSLATE_NOOP("QShortcut", "Launch (B)") },
164
{ Qt::Key_LaunchC, QT_TRANSLATE_NOOP("QShortcut", "Launch (C)") },
165
{ Qt::Key_LaunchD, QT_TRANSLATE_NOOP("QShortcut", "Launch (D)") },
166
{ Qt::Key_LaunchE, QT_TRANSLATE_NOOP("QShortcut", "Launch (E)") },
167
{ Qt::Key_LaunchF, QT_TRANSLATE_NOOP("QShortcut", "Launch (F)") },
169
// --------------------------------------------------------------
170
// More consistent namings
171
{ Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print Screen") },
172
{ Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "Page Up") },
173
{ Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "Page Down") },
174
{ Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "Caps Lock") },
175
{ Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Num Lock") },
176
{ Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Number Lock") },
177
{ Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "Scroll Lock") },
178
{ Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Insert") },
179
{ Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Delete") },
180
{ Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Escape") },
181
{ Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "System Request") },
187
class QKeySequencePrivate
190
inline QKeySequencePrivate()
193
key[0] = key[1] = key[2] = key[3] = 0;
195
inline QKeySequencePrivate(const QKeySequencePrivate ©)
198
key[0] = copy.key[0];
199
key[1] = copy.key[1];
200
key[2] = copy.key[2];
201
key[3] = copy.key[3];
209
Constructs an empty key sequence.
211
QKeySequence::QKeySequence()
213
d = new QKeySequencePrivate();
217
Creates a key sequence from the \a key string. For example
218
"Ctrl+O" gives CTRL+'O'. The strings "Ctrl",
219
"Shift", "Alt" and "Meta" are recognized, as well as their
220
translated equivalents in the "QShortcut" context (using
223
Up to four key codes may be entered by separating them with
224
commas, e.g. "Alt+X,Ctrl+S,Q".
226
This contructor is typically used with \link QObject::tr() tr
227
\endlink(), so that shortcut keys can be replaced in
231
QMenu *file = new QMenu(this);
232
file->addAction(tr("&Open..."), this, SLOT(open()),
233
QKeySequence(tr("Ctrl+O", "File|Open")));
236
Note the \c "File|Open" translator comment. It is by no means
237
necessary, but it provides some context for the human translator.
239
QKeySequence::QKeySequence(const QString &key)
241
d = new QKeySequencePrivate();
246
Constructs a key sequence with up to 4 keys \a k1, \a k2,
249
The key codes are listed in Qt::Key and can be combined with
250
modifiers (see Qt::Modifier) such as \c Qt::SHIFT, \c Qt::CTRL, \c Qt::ALT
253
QKeySequence::QKeySequence(int k1, int k2, int k3, int k4)
255
d = new QKeySequencePrivate();
263
Copy constructor. Makes a copy of \a keysequence.
265
QKeySequence::QKeySequence(const QKeySequence& keysequence)
273
Destroys the key sequence.
275
QKeySequence::~QKeySequence()
283
KeySequences should never be modified, but rather just created.
284
Internally though we do need to modify to keep pace in event
288
void QKeySequence::setKey(int key, int index)
290
Q_ASSERT_X(index >= 0 && index < 4, "QKeySequence::setKey", "index out of range");
296
Returns the number of keys in the key sequence.
299
uint QKeySequence::count() const
314
Returns true if the key sequence is empty; otherwise returns
317
bool QKeySequence::isEmpty() const
324
Returns the shortcut key sequence for the mnemonic in \a text,
325
or an empty key sequence if no mnemonics are found.
327
For example, mnemonic("E&xit") returns Qt::ALT+Qt::Key_X,
328
mnemonic("&Quit") returns ALT+Key_Q, and mnemonic("Quit")
329
returns an empty QKeySequence.
331
We provide a \link accelerators.html list of common mnemonics
332
\endlink in English. At the time of writing, Microsoft and Open
333
Group do not appear to have issued equivalent recommendations for
336
QKeySequence QKeySequence::mnemonic(const QString &text)
338
if(qt_sequence_no_mnemonics)
339
return QKeySequence();
343
p = text.indexOf('&', p) + 1;
344
if (p <= 0 || p >= (int)text.length())
346
if (text.at(p) != '&') {
347
QChar c = text.at(p);
350
return QKeySequence(c.unicode() + Qt::ALT);
355
return QKeySequence();
359
\fn int QKeySequence::assign(const QString &keys)
361
Adds the given \a keys to the key sequence. \a keys may
362
contain up to four key codes, provided they are separated by a
363
comma; for example, "Alt+X,Ctrl+S,Z". The return value is the
364
number of key codes added.
366
int QKeySequence::assign(const QString &ks)
373
// Run through the whole string, but stop
374
// if we have 4 keys before the end.
375
while (keyseq.length() && n < 4) {
376
// We MUST use something to seperate each sequence, and space
377
// does not cut it, since some of the key names have space
378
// in them.. (Let's hope no one translate with a comma in it:)
379
p = keyseq.indexOf(',');
381
if (',' == keyseq[p+1]) // e.g. 'Ctrl+,, Shift+,,'
383
if (' ' == keyseq[p+1]) { // Space after comma
390
part = keyseq.left(-1 == p ? keyseq.length() : p - diff);
391
keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1));
392
d->key[n] = decodeString(part);
398
struct ModifKeyName {
400
ModifKeyName(int q, QChar n) : qt_key(q), name(n) { }
401
ModifKeyName(int q, const QString &n) : qt_key(q), name(n) { }
406
Q_GLOBAL_STATIC(QList<ModifKeyName>, globalModifs)
409
Constructs a single key from the string \a str.
411
int QKeySequence::decodeString(const QString &str)
414
QString accel = str.toLower();
416
QList<ModifKeyName> *gmodifs = globalModifs();
417
if (!gmodifs) return ret;
419
if (gmodifs->isEmpty()) {
421
*gmodifs << ModifKeyName(Qt::CTRL, QMAC_CTRL);
424
*gmodifs << ModifKeyName(Qt::ALT, QMAC_ALT);
427
*gmodifs << ModifKeyName(Qt::META, QMAC_META);
430
*gmodifs << ModifKeyName(Qt::SHIFT, QMAC_SHIFT);
432
*gmodifs << ModifKeyName(Qt::CTRL, "ctrl+")
433
<< ModifKeyName(Qt::SHIFT, "shift+")
434
<< ModifKeyName(Qt::ALT, "alt+")
435
<< ModifKeyName(Qt::META, "meta+");
438
QList<ModifKeyName> modifs = *gmodifs;
439
modifs << ModifKeyName(Qt::CTRL, QShortcut::tr("Ctrl").toLower().append(QLatin1Char('+')))
440
<< ModifKeyName(Qt::SHIFT, QShortcut::tr("Shift").toLower().append(QLatin1Char('+')))
441
<< ModifKeyName(Qt::ALT, QShortcut::tr("Alt").toLower().append(QLatin1Char('+')))
442
<< ModifKeyName(Qt::ALT, QShortcut::tr("Meta").toLower().append(QLatin1Char('+')));
447
for (int i = 0; i < modifs.size(); ++i) {
448
const ModifKeyName &mkf = modifs.at(i);
449
if (sl.contains(mkf.name)) {
451
accel.remove(mkf.name);
456
int p = accel.lastIndexOf('+', str.length() - 2); // -2 so that Ctrl++ works
458
accel = accel.mid(p + 1);
461
if (accel.length() == 1) {
462
ret |= accel[0].toUpper().unicode();
463
} else if (accel[0] == 'f' && (fnum = accel.mid(1).toInt())) {
464
ret |= Qt::Key_F1 + fnum - 1;
466
// Check through translation table for the correct key name
467
// ...or fall back on english table.
469
for (int tran = 0; tran < 2; ++tran) {
470
for (int i = 0; keyname[i].name; ++i) {
472
? QShortcut::tr(keyname[i].name)
473
: QString::fromLatin1(keyname[i].name));
474
if (accel == keyName.toLower()) {
475
ret |= keyname[i].key;
489
Creates a shortcut string for \a key. For example,
490
Qt::CTRL+Qt::Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are
491
translated (using QObject::tr()) in the "QShortcut" context.
493
QString QKeySequence::encodeString(int key)
496
#if defined(Q_OS_MAC) && !defined(QWS)
497
// On MAC the order is Meta, Alt, Shift, Control.
498
if ((key & Qt::META) == Qt::META)
500
if ((key & Qt::ALT) == Qt::ALT)
502
if ((key & Qt::SHIFT) == Qt::SHIFT)
504
if ((key & Qt::CTRL) == Qt::CTRL)
507
// On other systems the order is Meta, Control, Alt, Shift
508
if ((key & Qt::META) == Qt::META)
509
s += QShortcut::tr("Meta");
510
if ((key & Qt::CTRL) == Qt::CTRL) {
512
s += QShortcut::tr("+");
513
s += QShortcut::tr("Ctrl");
515
if ((key & Qt::ALT) == Qt::ALT) {
517
s += QShortcut::tr("+");
518
s += QShortcut::tr("Alt");
520
if ((key & Qt::SHIFT) == Qt::SHIFT) {
522
s += QShortcut::tr("+");
523
s += QShortcut::tr("Shift");
528
key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier);
531
if (key && key < Qt::Key_Escape) {
533
p = QChar(key & 0xffff).toUpper();
535
p = QChar((key-0x10000)/0x400+0xd800);
536
p += QChar((key-0x10000)%400+0xdc00);
538
} else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) {
539
p = QShortcut::tr("F%1").arg(key - Qt::Key_F1 + 1);
540
} else if (key > Qt::Key_Space && key <= Qt::Key_AsciiTilde) {
541
p.sprintf("%c", key);
544
while (keyname[i].name) {
545
if (key == keyname[i].key) {
546
p = QShortcut::tr(keyname[i].name);
551
// If we can't find the actual translatable keyname,
552
// fall back on the unicode representation of it...
553
// Or else characters like Qt::Key_aring may not get displayed
554
// (Really depends on you locale)
555
if (!keyname[i].name) {
557
p = QChar(key & 0xffff).toUpper();
559
p = QChar((key-0x10000)/0x400+0xd800);
560
p += QChar((key-0x10000)%400+0xdc00);
567
s += QShortcut::tr("+");
575
Matches the sequence with \a seq. Returns \c ExactMatch if
576
successful, \c PartialMatch if \a seq matches incompletely,
577
and \c NoMatch if the sequences have nothing in common.
578
Returns \c NoMatch if \a seq is shorter.
580
QKeySequence::SequenceMatch QKeySequence::matches(const QKeySequence &seq) const
582
uint userN = count(),
588
// If equal in length, we have a potential ExactMatch sequence,
589
// else we already know it can only be partial.
590
SequenceMatch match = (userN == seqN ? ExactMatch : PartialMatch);
592
for (uint i = 0; i < userN; ++i) {
593
int userKey = (*this)[i],
594
sequenceKey = seq[i];
595
if (userKey != sequenceKey)
603
Creates a shortcut string for the key sequence.
605
For example, the value Qt::CTRL+Qt::Key_O results in "Ctrl+O".
606
If the key sequence has multiple key codes, each is separated
607
by commas in the string returned, such as "Alt+X, Ctrl+Y, Z".
608
The strings, "Ctrl", "Shift", etc. are translated using
609
QObject::tr() in the "QShortcut" scope.
611
If the key sequence has no keys, an empty string is returned.
613
On Mac OS X, the string returned resembles the sequence that is
614
shown in the menubar.
616
QKeySequence::operator QString() const
622
complete += encodeString(d->key[i]);
631
Returns the key sequence as a QVariant
633
QKeySequence::operator QVariant() const
635
return QVariant(QVariant::KeySequence, this);
640
For backward compatibility: returns the first keycode
641
as integer. If the key sequence is empty, 0 is returned.
643
QKeySequence::operator int () const
652
Returns a reference to the element at position \a index in the key
653
sequence. This can only be used to read an element.
655
int QKeySequence::operator[](uint index) const
657
Q_ASSERT_X(index < 4, "QKeySequence::operator[]", "index out of range");
658
return d->key[index];
663
Assignment operator. Assigns the \a other key sequence to this
666
QKeySequence &QKeySequence::operator=(const QKeySequence &other)
668
qAtomicAssign(d, other.d);
673
\fn bool QKeySequence::operator!=(const QKeySequence &other) const
675
Returns true if this key sequence is not equal to the \a other
676
key sequence; otherwise returns false.
681
Returns true if this key sequence is equal to the \a other
682
key sequence; otherwise returns false.
684
bool QKeySequence::operator==(const QKeySequence &other) const
686
return (d->key[0] == other.d->key[0] &&
687
d->key[1] == other.d->key[1] &&
688
d->key[2] == other.d->key[2] &&
689
d->key[3] == other.d->key[3]);
694
Provides an arbitrary comparison of this key sequence and
695
\a other key sequence. All that is guaranteed is that the
696
operator returns false if both key sequences are equal and
697
that (ks1 \< ks2) == !( ks2 \< ks1) if the key sequences
700
This function is useful in some circumstances, for example
701
if you want to use QKeySequence objects as keys in a QMap.
703
\sa operator==() operator!=() operator>() operator<=() operator>=()
705
bool QKeySequence::operator< (const QKeySequence &other) const
707
for (int i = 0; i < 4; ++i)
708
if (d->key[i] != other.d->key[i])
709
return d->key[i] < other.d->key[i];
714
\fn bool QKeySequence::operator> (const QKeySequence &other) const
716
Returns true if this key sequence is larger than the \a other key
717
sequence; otherwise returns false.
719
\sa operator==() operator!=() operator<() operator<=() operator>=()
723
\fn bool QKeySequence::operator<= (const QKeySequence &other) const
725
Returns true if this key sequence is smaller or equal to the
726
\a other key sequence; otherwise returns false.
728
\sa operator==() operator!=() operator<() operator>() operator>=()
732
\fn bool QKeySequence::operator>= (const QKeySequence &other) const
734
Returns true if this key sequence is larger or equal to the
735
\a other key sequence; otherwise returns false.
737
\sa operator==() operator!=() operator<() operator>() operator<=()
743
bool QKeySequence::isDetached() const
748
/*****************************************************************************
749
QKeySequence stream functions
750
*****************************************************************************/
751
#if !defined(QT_NO_DATASTREAM) && !defined(QT_NO_IMAGEIO)
753
\fn QDataStream &operator<<(QDataStream &stream, const QKeySequence &sequence)
754
\relates QKeySequence
756
Writes the key \a sequence to the \a stream.
758
\sa \link datastreamformat.html Format of the QDataStream operators \endlink
760
QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence)
763
list << keysequence.d->key[0];
765
if (s.version() >= 5 && keysequence.count() > 1) {
766
list << keysequence.d->key[1];
767
list << keysequence.d->key[2];
768
list << keysequence.d->key[3];
776
\fn QDataStream &operator>>(QDataStream &stream, QKeySequence &sequence)
777
\relates QKeySequence
779
Reads a key sequence from the \a stream into the key \a sequence.
781
\sa \link datastreamformat.html Format of the QDataStream operators \endlink
783
QDataStream &operator>>(QDataStream &s, QKeySequence &keysequence)
787
for (int i = 0; i < 4; ++i)
788
keysequence.d->key[i] = list.value(i);
792
#endif //QT_NO_DATASTREAM
794
#ifndef QT_NO_DEBUG_STREAM
795
QDebug operator<<(QDebug dbg, const QKeySequence &p)
797
#ifndef Q_BROKEN_DEBUG_STREAM
798
dbg.nospace() << "QKeySequence(" << QString(p) << ')';
801
qWarning("This compiler doesn't support streaming QKeySequence to QDebug");