QtGui/qkeysequence.h Source File

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;
61 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
62 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks);
63 #endif
64 
65 #ifdef qdoc
66 void qt_set_sequence_auto_mnemonic(bool b);
67 #endif
68 
69 class QVariant;
70 class QKeySequencePrivate;
71 
72 class Q_GUI_EXPORT QKeySequence
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);
151  QKeySequence(const QString &key, SequenceFormat format);
152  QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0);
153  QKeySequence(const QKeySequence &ks);
154  QKeySequence(StandardKey key);
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 
206  QKeySequencePrivate *d;
207 
208  friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
209  friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
210  friend class Q3AccelManager;
211  friend class QShortcutMap;
212  friend class QShortcut;
213 
214 public:
215  typedef QKeySequencePrivate * DataPtr;
216  inline DataPtr &data_ptr() { return d; }
217 };
218 Q_DECLARE_TYPEINFO(QKeySequence, Q_MOVABLE_TYPE);
219 Q_DECLARE_SHARED(QKeySequence)
220 
221 #ifndef QT_NO_DEBUG_STREAM
222 Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &);
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
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
bool operator>(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:551
bool operator<=(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:545
Definition: qdebug.h:62
void swap(QKeySequence &other)
Definition: qkeysequence.h:186
bool operator==(const Attribute &cA, const AttributeInstance< type > &cB)
This operator compares the two attributes and NOT their values.
Definition: node.h:577
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &out, QKeySequence &ks)
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLenum GLsizei GLenum format
Definition: GLee.h:873
Q_INLINE_TEMPLATE void qSwap(QScopedPointer< T, Cleanup > &p1, QScopedPointer< T, Cleanup > &p2)
GLuint GLuint GLsizei count
Definition: GLee.h:872
DataPtr & data_ptr()
Definition: qkeysequence.h:216
bool operator!=(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:533
GLubyte GLubyte b
Definition: GLee.h:5404
bool operator>=(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:557
GLuint in
Definition: GLee.h:7188
QKeySequencePrivate * DataPtr
Definition: qkeysequence.h:215
Q_DECLARE_TYPEINFO(QKeySequence, Q_MOVABLE_TYPE)
bool operator<(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:539
#define QT_END_HEADER
Definition: qglobal.h:142
GLuint index
Definition: GLee.h:1704
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &in, const QKeySequence &ks)