author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 10:37:55 +0300 | |
changeset 33 | 3e2da88830cd |
parent 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
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 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
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 |
||
48 |
QT_BEGIN_HEADER |
|
49 |
||
50 |
QT_BEGIN_NAMESPACE |
|
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 { |
|
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 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
144 |
enum SequenceFormat { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
145 |
NativeText, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
146 |
PortableText |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
147 |
}; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
148 |
|
0 | 149 |
QKeySequence(); |
150 |
QKeySequence(const QString &key); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
151 |
QKeySequence(const QString &key, SequenceFormat format); |
0 | 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; |
|
194 |
private: |
|
195 |
static int decodeString(const QString &ks); |
|
196 |
static QString encodeString(int key); |
|
197 |
int assign(const QString &str); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
198 |
int assign(const QString &str, SequenceFormat format); |
0 | 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 |
||
209 |
public: |
|
210 |
typedef QKeySequencePrivate * DataPtr; |
|
211 |
inline DataPtr &data_ptr() { return d; } |
|
212 |
}; |
|
213 |
Q_DECLARE_TYPEINFO(QKeySequence, Q_MOVABLE_TYPE); |
|
214 |
Q_DECLARE_SHARED(QKeySequence) |
|
215 |
||
216 |
#ifndef QT_NO_DEBUG_STREAM |
|
217 |
Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &); |
|
218 |
#endif |
|
219 |
||
220 |
#else |
|
221 |
||
222 |
class Q_GUI_EXPORT QKeySequence |
|
223 |
{ |
|
224 |
public: |
|
225 |
QKeySequence() {} |
|
226 |
QKeySequence(int) {} |
|
227 |
}; |
|
228 |
||
229 |
#endif // QT_NO_SHORTCUT |
|
230 |
||
231 |
QT_END_NAMESPACE |
|
232 |
||
233 |
QT_END_HEADER |
|
234 |
||
235 |
#endif // QKEYSEQUENCE_H |