Qt 4.8
qkeysequence.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QKEYSEQUENCE_H
43 #define QKEYSEQUENCE_H
44 
45 #include <QtCore/qnamespace.h>
46 #include <QtCore/qstring.h>
47 
49 
51 
52 QT_MODULE(Gui)
53 
54 #ifndef QT_NO_SHORTCUT
55 
56 /*****************************************************************************
57  QKeySequence stream functions
58  *****************************************************************************/
59 #ifndef QT_NO_DATASTREAM
60 class QKeySequence;
63 #endif
64 
65 #ifdef qdoc
67 #endif
68 
69 class QVariant;
71 
73 {
74 public:
75  enum StandardKey {
82  New,
84  Cut,
141  Quit
142  };
143 
146  PortableText
147  };
148 
149  QKeySequence();
150  QKeySequence(const QString &key);
152  QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0);
153  QKeySequence(const QKeySequence &ks);
155  ~QKeySequence();
156 
157  uint count() const; // ### Qt 5: return 'int'
158  bool isEmpty() const;
159 
163  ExactMatch
164 #ifdef QT3_SUPPORT
165  , Identical = ExactMatch
166 #endif
167  };
168 
169  QString toString(SequenceFormat format = PortableText) const;
170  static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText);
171 
172  SequenceMatch matches(const QKeySequence &seq) const;
173  static QKeySequence mnemonic(const QString &text);
174  static QList<QKeySequence> keyBindings(StandardKey key);
175 
176  // ### Qt 5: kill 'operator QString' - it's evil
177  operator QString() const;
178  operator QVariant() const;
179  operator int() const;
180  int operator[](uint i) const;
181  QKeySequence &operator=(const QKeySequence &other);
182 #ifdef Q_COMPILER_RVALUE_REFS
183  inline QKeySequence &operator=(QKeySequence &&other)
184  { qSwap(d, other.d); return *this; }
185 #endif
186  inline void swap(QKeySequence &other) { qSwap(d, other.d); }
187  bool operator==(const QKeySequence &other) const;
188  inline bool operator!= (const QKeySequence &other) const
189  { return !(*this == other); }
190  bool operator< (const QKeySequence &ks) const;
191  inline bool operator> (const QKeySequence &other) const
192  { return other < *this; }
193  inline bool operator<= (const QKeySequence &other) const
194  { return !(other < *this); }
195  inline bool operator>= (const QKeySequence &other) const
196  { return !(*this < other); }
197 
198  bool isDetached() const;
199 private:
200  static int decodeString(const QString &ks);
201  static QString encodeString(int key);
202  int assign(const QString &str);
203  int assign(const QString &str, SequenceFormat format);
204  void setKey(int key, int index);
205 
207 
210  friend class Q3AccelManager;
211  friend class QShortcutMap;
212  friend class QShortcut;
213 
214 public:
216  inline DataPtr &data_ptr() { return d; }
217 };
220 
221 #ifndef QT_NO_DEBUG_STREAM
223 #endif
224 
225 #else
226 
227 class Q_GUI_EXPORT QKeySequence
228 {
229 public:
230  QKeySequence() {}
231  QKeySequence(int) {}
232 };
233 
234 #endif // QT_NO_SHORTCUT
235 
237 
239 
240 #endif // QKEYSEQUENCE_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
double d
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
bool operator>(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:551
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
DataPtr & data_ptr()
Definition: qkeysequence.h:216
StandardKey
This enum represent standard key bindings.
Definition: qkeysequence.h:75
bool operator!=(QBool b1, bool b2)
Definition: qglobal.h:2026
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool operator<(int priority, const QPair< QRunnable *, int > &p)
Definition: qthreadpool.cpp:50
bool operator<=(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:545
The QShortcut class is used to create keyboard shortcuts.
Definition: qshortcut.h:57
void qt_set_sequence_auto_mnemonic(bool b)
#define Q_DECLARE_SHARED(TYPE)
Definition: qglobal.h:2214
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &out, QKeySequence &ks)
static QString toString(Register *reg, int type, bool *ok=0)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool isEmpty(const char *str)
QKeySequencePrivate * DataPtr
Definition: qkeysequence.h:215
static QByteArray encodeString(QTextCodec *tc, const QString &str)
Definition: qsql_ibase.cpp:289
QKeySequencePrivate * d
Definition: qkeysequence.h:206
unsigned int uint
Definition: qglobal.h:996
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
void swap(QKeySequence &other)
Swaps key sequence other with this key sequence.
Definition: qkeysequence.h:186
bool operator>=(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:557
int key
Q_DECLARE_TYPEINFO(QKeySequence, Q_MOVABLE_TYPE)
quint16 index
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
SequenceFormat
This means that it will be shown translated and on the Mac it will resemble a key sequence from the m...
Definition: qkeysequence.h:144
#define QT_END_HEADER
Definition: qglobal.h:137
QDataStream & operator<<(QDataStream &out, const QUrl &url)
Writes url url to the stream out and returns a reference to the stream.
Definition: qurl.cpp:6757
bool operator==(QBool b1, bool b2)
Definition: qglobal.h:2023
#define text
Definition: qobjectdefs.h:80
QDataStream & operator>>(QDataStream &in, QUrl &url)
Reads a url into url from the stream in and returns a reference to the stream.
Definition: qurl.cpp:6774
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &in, const QKeySequence &ks)