source: trunk/src/gui/kernel/qkeysequence.h@ 858

Last change on this file since 858 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 6.6 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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
48QT_BEGIN_HEADER
49
50QT_BEGIN_NAMESPACE
51
52QT_MODULE(Gui)
53
54#ifndef QT_NO_SHORTCUT
55
56/*****************************************************************************
57 QKeySequence stream functions
58 *****************************************************************************/
59#ifndef QT_NO_DATASTREAM
60class QKeySequence;
61Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
62Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks);
63#endif
64
65#ifdef qdoc
66void qt_set_sequence_auto_mnemonic(bool b);
67#endif
68
69class QVariant;
70class QKeySequencePrivate;
71
72class Q_GUI_EXPORT QKeySequence
73{
74public:
75 enum StandardKey {
76 UnknownKey,
77 HelpContents,
78 WhatsThis,
79 Open,
80 Close,
81 Save,
82 New,
83 Delete,
84 Cut,
85 Copy,
86 Paste,
87 Undo,
88 Redo,
89 Back,
90 Forward,
91 Refresh,
92 ZoomIn,
93 ZoomOut,
94 Print,
95 AddTab,
96 NextChild,
97 PreviousChild,
98 Find,
99 FindNext,
100 FindPrevious,
101 Replace,
102 SelectAll,
103 Bold,
104 Italic,
105 Underline,
106 MoveToNextChar,
107 MoveToPreviousChar,
108 MoveToNextWord,
109 MoveToPreviousWord,
110 MoveToNextLine,
111 MoveToPreviousLine,
112 MoveToNextPage,
113 MoveToPreviousPage,
114 MoveToStartOfLine,
115 MoveToEndOfLine,
116 MoveToStartOfBlock,
117 MoveToEndOfBlock,
118 MoveToStartOfDocument,
119 MoveToEndOfDocument,
120 SelectNextChar,
121 SelectPreviousChar,
122 SelectNextWord,
123 SelectPreviousWord,
124 SelectNextLine,
125 SelectPreviousLine,
126 SelectNextPage,
127 SelectPreviousPage,
128 SelectStartOfLine,
129 SelectEndOfLine,
130 SelectStartOfBlock,
131 SelectEndOfBlock,
132 SelectStartOfDocument,
133 SelectEndOfDocument,
134 DeleteStartOfWord,
135 DeleteEndOfWord,
136 DeleteEndOfLine,
137 InsertParagraphSeparator,
138 InsertLineSeparator,
139 SaveAs,
140 Preferences,
141 Quit
142 };
143
144 enum SequenceFormat {
145 NativeText,
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
160 enum SequenceMatch {
161 NoMatch,
162 PartialMatch,
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 bool operator==(const QKeySequence &other) const;
183 inline bool operator!= (const QKeySequence &other) const
184 { return !(*this == other); }
185 bool operator< (const QKeySequence &ks) const;
186 inline bool operator> (const QKeySequence &other) const
187 { return other < *this; }
188 inline bool operator<= (const QKeySequence &other) const
189 { return !(other < *this); }
190 inline bool operator>= (const QKeySequence &other) const
191 { return !(*this < other); }
192
193 bool isDetached() const;
194private:
195 static int decodeString(const QString &ks);
196 static QString encodeString(int key);
197 int assign(const QString &str);
198 int assign(const QString &str, SequenceFormat format);
199 void setKey(int key, int index);
200
201 QKeySequencePrivate *d;
202
203 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
204 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
205 friend class Q3AccelManager;
206 friend class QShortcutMap;
207 friend class QShortcut;
208
209public:
210 typedef QKeySequencePrivate * DataPtr;
211 inline DataPtr &data_ptr() { return d; }
212};
213Q_DECLARE_TYPEINFO(QKeySequence, Q_MOVABLE_TYPE);
214Q_DECLARE_SHARED(QKeySequence)
215
216#ifndef QT_NO_DEBUG_STREAM
217Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &);
218#endif
219
220#else
221
222class Q_GUI_EXPORT QKeySequence
223{
224public:
225 QKeySequence() {}
226 QKeySequence(int) {}
227};
228
229#endif // QT_NO_SHORTCUT
230
231QT_END_NAMESPACE
232
233QT_END_HEADER
234
235#endif // QKEYSEQUENCE_H
Note: See TracBrowser for help on using the repository browser.