author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /microkde/kdecore/kshortcut.h | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | microkde/kdecore/kshortcut.h | 846 |
1 files changed, 846 insertions, 0 deletions
diff --git a/microkde/kdecore/kshortcut.h b/microkde/kdecore/kshortcut.h new file mode 100644 index 0000000..4813734 --- a/dev/null +++ b/microkde/kdecore/kshortcut.h | |||
@@ -0,0 +1,846 @@ | |||
1 | /* This file is part of the KDE libraries | ||
2 | Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | #ifndef __KSHORTCUT_H | ||
21 | #define __KSHORTCUT_H | ||
22 | /*US | ||
23 | #include <qkeysequence.h> | ||
24 | #include <qstring.h> | ||
25 | |||
26 | class QKeyEvent; | ||
27 | class KKeyNative; | ||
28 | */ | ||
29 | /** | ||
30 | * A KKey object represents a single key with possible modifiers | ||
31 | * (Shift, Ctrl, Alt, Win). It can represent both keys which are | ||
32 | * understood by Qt as well as those which are additionally supported | ||
33 | * by the underlying system (e.g. X11). | ||
34 | * @see KKeyNative | ||
35 | * @see KKeySequence | ||
36 | * @see KShortcut | ||
37 | */ | ||
38 | /*US | ||
39 | class KKey | ||
40 | { | ||
41 | public: | ||
42 | */ | ||
43 | /** | ||
44 | * The number of flags. | ||
45 | * @see ModFlag | ||
46 | */ | ||
47 | /*US | ||
48 | enum { MOD_FLAG_COUNT = 4 }; | ||
49 | enum { QtWIN = (Qt::ALT << 1) }; | ||
50 | */ | ||
51 | /** | ||
52 | * Flags to represent the modifiers. You can combine modifiers | ||
53 | * by ORing them. | ||
54 | */ | ||
55 | /*US | ||
56 | enum ModFlag { | ||
57 | SHIFT = 0x01, | ||
58 | CTRL = 0x02, | ||
59 | ALT = 0x04, | ||
60 | WIN = 0x08 | ||
61 | }; | ||
62 | */ | ||
63 | /** | ||
64 | * Creates a new null KKey. | ||
65 | * @see clear() | ||
66 | * @see isNull() | ||
67 | * @see null() | ||
68 | */ | ||
69 | //USKKey(); | ||
70 | |||
71 | /** | ||
72 | * Creates a new key for the given Qt key code. | ||
73 | * @param keyQt the qt keycode | ||
74 | * @see Qt::Key | ||
75 | */ | ||
76 | //USKKey( int keyQt ); | ||
77 | |||
78 | /** | ||
79 | * Creates a new key from the first key code of the given key sequence. | ||
80 | * @param keySeq the key sequence that contains the key | ||
81 | */ | ||
82 | //USKKey( const QKeySequence& keySeq ); | ||
83 | |||
84 | /** | ||
85 | * Extracts the key from the given key event. | ||
86 | * @param keyEvent the key event to get the key from | ||
87 | */ | ||
88 | //USKKey( const QKeyEvent* keyEvent ); | ||
89 | |||
90 | /** | ||
91 | * Copy constructor. | ||
92 | */ | ||
93 | //USKKey( const KKey& key ); | ||
94 | |||
95 | /** | ||
96 | * Creates a new key from the given description. The form of the description | ||
97 | * is "[modifier+[modifier+]]+key", for example "e", "CTRL+q" or | ||
98 | * "CTRL+ALT+DEL". Allowed modifiers are "SHIFT", "CTRL", "ALT", "WIN" and | ||
99 | * "META". "WIN" and "META" are equivalent. Modifiers are not case-sensitive. | ||
100 | * @param key the description of the key | ||
101 | * @see KKeyServer::Sym::init() | ||
102 | */ | ||
103 | //USKKey( const QString& key ); | ||
104 | /** | ||
105 | * @internal | ||
106 | */ | ||
107 | //USKKey( uint key, uint mod ); | ||
108 | //US~KKey(); | ||
109 | |||
110 | // Initialization methods | ||
111 | /** | ||
112 | * Clears the key. The key is null after calling this function. | ||
113 | * @see isNull() | ||
114 | */ | ||
115 | //USvoid clear(); | ||
116 | |||
117 | /** | ||
118 | * Initializes the key with the given Qt key code. | ||
119 | * @param keyQt the qt keycode | ||
120 | * @return true if successful, false otherwise | ||
121 | * @see Qt::Key | ||
122 | */ | ||
123 | //USbool init( int keyQt ); | ||
124 | |||
125 | /** | ||
126 | * Initializes the key with the first key code of the given key sequence. | ||
127 | * @param keySeq the key sequence that contains the key | ||
128 | * @return true if successful, false otherwise | ||
129 | */ | ||
130 | //USbool init( const QKeySequence& keySeq ); | ||
131 | |||
132 | /** | ||
133 | * Initializes the key by extracting the code from the given key event. | ||
134 | * @param keyEvent the key event to get the key from | ||
135 | * @return true if successful, false otherwise | ||
136 | */ | ||
137 | //USbool init( const QKeyEvent* keyEvent ); | ||
138 | |||
139 | /** | ||
140 | * Copies the given key. | ||
141 | * @param key the key to copy | ||
142 | * @return true if successful, false otherwise | ||
143 | */ | ||
144 | //USbool init( const KKey& key ); | ||
145 | |||
146 | /** | ||
147 | * Initializes the key with the given description. The form of the description | ||
148 | * is "[modifier+[modifier+]]+key", for example "e", "CTRL+q" or | ||
149 | * "CTRL+ALT+DEL". Allowed modifiers are "SHIFT", "CTRL", "ALT", "WIN" and | ||
150 | * "META". "WIN" and "META" are equivalent. Modifiers are not case-sensitive. | ||
151 | * @param key the description of the key | ||
152 | * @return true if successful, false otherwise | ||
153 | * @see KKeyServer::Sym::init() | ||
154 | */ | ||
155 | //USbool init( const QString& ); | ||
156 | |||
157 | /** | ||
158 | * @internal | ||
159 | */ | ||
160 | //USbool init( uint key, uint mod ); | ||
161 | |||
162 | /** | ||
163 | * Copies the key. | ||
164 | */ | ||
165 | //USKKey& operator =( const KKey& key ) | ||
166 | //US { init( key ); return *this; } | ||
167 | |||
168 | // Query methods. | ||
169 | /** | ||
170 | * Returns true if the key is null (after @ref clear() or empty | ||
171 | * constructor). | ||
172 | * @return true if the key is null | ||
173 | * @see clear() | ||
174 | * @see null() | ||
175 | */ | ||
176 | //USbool isNull() const; | ||
177 | |||
178 | /** | ||
179 | * @internal | ||
180 | */ | ||
181 | //USbool isValidQt() const; | ||
182 | |||
183 | /** | ||
184 | * @internal | ||
185 | */ | ||
186 | //USbool isValidNative() const; | ||
187 | |||
188 | /** | ||
189 | * @internal | ||
190 | */ | ||
191 | //USuint sym() const; | ||
192 | /** | ||
193 | * @internal | ||
194 | */ | ||
195 | //USuint modFlags() const; | ||
196 | |||
197 | // Comparison Methods | ||
198 | /** | ||
199 | * Compares this key with the given KKey object. Returns a negative | ||
200 | * number if the given KKey is larger, 0 if they are equal and | ||
201 | * a positive number this KKey is larger. The returned value | ||
202 | * is the difference between the symbol or, if the symbols | ||
203 | * are equal, the difference between the encoded modifiers. | ||
204 | * @param key the key to compare with this key | ||
205 | * @return a negative number if the given KKey is larger, 0 if | ||
206 | * they are equal and a positive number this KKey is larger | ||
207 | */ | ||
208 | //USint compare( const KKey& key ) const; | ||
209 | |||
210 | /** | ||
211 | * Compares the symbol and modifiers of both keys. | ||
212 | * @see compare() | ||
213 | */ | ||
214 | //USbool operator == ( const KKey& key ) const | ||
215 | //US { return compare( key ) == 0; } | ||
216 | /** | ||
217 | * Compares the symbol and modifiers of both keys. | ||
218 | * @see compare() | ||
219 | */ | ||
220 | //USbool operator != ( const KKey& key ) const | ||
221 | //US { return compare( key ) != 0; } | ||
222 | /** | ||
223 | * Compares the symbol and modifiers of both keys. | ||
224 | * @see compare() | ||
225 | */ | ||
226 | //USbool operator < ( const KKey& key ) const | ||
227 | //US { return compare( key ) < 0; } | ||
228 | |||
229 | // Conversion methods. | ||
230 | /** | ||
231 | * Returns the qt key code. | ||
232 | * @return the qt key code or 0 if there is no key set. | ||
233 | * @see Qt::Key | ||
234 | */ | ||
235 | //USint keyCodeQt() const; | ||
236 | |||
237 | /** | ||
238 | * Returns a human-readable representation of the key in the form | ||
239 | * "modifier+key". | ||
240 | * @return the string representation of the key | ||
241 | */ | ||
242 | //USQString toString() const; | ||
243 | |||
244 | /** | ||
245 | * @internal | ||
246 | */ | ||
247 | //US QString toStringInternal() const; | ||
248 | |||
249 | // Operation methods | ||
250 | /** | ||
251 | * @internal | ||
252 | */ | ||
253 | //USvoid simplify(); | ||
254 | |||
255 | /** | ||
256 | * Returns a null key. | ||
257 | * @return the null key | ||
258 | * @see isNull() | ||
259 | * @see clear() | ||
260 | */ | ||
261 | //USstatic KKey& null(); | ||
262 | |||
263 | /** | ||
264 | * Returns a user-readable representation of the given modifiers. | ||
265 | * @param f the modifiers to convert | ||
266 | * @return the string representation of the modifiers | ||
267 | */ | ||
268 | //USstatic QString modFlagLabel( ModFlag f ); | ||
269 | |||
270 | //US private: | ||
271 | /* | ||
272 | * Under X11, m_key will hold an X11 key symbol. | ||
273 | * For Qt/Embedded, it will hold the Qt key code. | ||
274 | */ | ||
275 | /** | ||
276 | * Returns the native key symbol value key. Under X11, this is the X | ||
277 | * keycode. Under Qt/Embedded, this is the Qt keycode. | ||
278 | * @see /usr/include/X11/keysymdef.h | ||
279 | * @see qnamespace.h | ||
280 | */ | ||
281 | //USuint m_sym; | ||
282 | /** | ||
283 | * m_mod holds the | ||
284 | */ | ||
285 | //USuint m_mod; | ||
286 | |||
287 | //US private: | ||
288 | //USfriend class KKeyNative; | ||
289 | //US}; | ||
290 | |||
291 | /** | ||
292 | * A KKeySequence object holds a sequence of up to 4 keys. | ||
293 | * Ex: Ctrl+X,I | ||
294 | * @see KKey | ||
295 | * @see KShortcut | ||
296 | */ | ||
297 | |||
298 | //USclass KKeySequence | ||
299 | //US{ | ||
300 | //US public: | ||
301 | /// Defines the maximum length of the key sequence | ||
302 | //US enum { MAX_KEYS = 4 }; | ||
303 | |||
304 | /** | ||
305 | * Create a new null key sequence. | ||
306 | * @see isNull() | ||
307 | * @see null() | ||
308 | * @see clear() | ||
309 | */ | ||
310 | //USKKeySequence(); | ||
311 | |||
312 | /** | ||
313 | * Copies the given qt key sequence. | ||
314 | * @param keySeq the qt key sequence to copy | ||
315 | */ | ||
316 | //USKKeySequence( const QKeySequence& keySeq ); | ||
317 | |||
318 | /** | ||
319 | * Create a new key sequence that only contains the given key. | ||
320 | * @param key the key to add | ||
321 | */ | ||
322 | //USKKeySequence( const KKey& key ); | ||
323 | |||
324 | /** | ||
325 | * Create a new key sequence that only contains the given key. | ||
326 | * @param key the key to add | ||
327 | */ | ||
328 | //USKKeySequence( const KKeyNative& key ); | ||
329 | |||
330 | /** | ||
331 | * Copies the given key sequence. | ||
332 | * @param keySeq the key sequence to copy | ||
333 | */ | ||
334 | //USKKeySequence( const KKeySequence& keySeq ); | ||
335 | |||
336 | /** | ||
337 | * Creates a new key sequence that contains the given key sequence. | ||
338 | * The description consists of comma-separated keys as | ||
339 | * required by @ref KKey::KKey(const QString&). | ||
340 | * @param keySeq the description of the key | ||
341 | * @see KKeyServer::Sym::init() | ||
342 | * @see KKey::KKey(const QString&) | ||
343 | */ | ||
344 | //USKKeySequence( const QString& keySeq ); | ||
345 | |||
346 | //US~KKeySequence(); | ||
347 | |||
348 | /** | ||
349 | * Clears the key sequence. The key sequence is null after calling this | ||
350 | * function. | ||
351 | * @see isNull() | ||
352 | */ | ||
353 | //USvoid clear(); | ||
354 | |||
355 | /** | ||
356 | * Copies the given qt key sequence over this key sequence. | ||
357 | * @param keySeq the qt key sequence to copy | ||
358 | * @return true if successful, false otherwise | ||
359 | */ | ||
360 | //USbool init( const QKeySequence& keySeq ); | ||
361 | |||
362 | /** | ||
363 | * Initializes the key sequence to only contain the given key. | ||
364 | * @param key the key to set | ||
365 | * @return true if successful, false otherwise | ||
366 | */ | ||
367 | //USbool init( const KKey& key ); | ||
368 | |||
369 | /** | ||
370 | * Initializes the key sequence to only contain the given key. | ||
371 | * @param key the key to set | ||
372 | * @return true if successful, false otherwise | ||
373 | */ | ||
374 | //USbool init( const KKeyNative& key ); | ||
375 | |||
376 | /** | ||
377 | * Copies the given key sequence over this key sequence. | ||
378 | * @param keySeq the key sequence to copy | ||
379 | * @return true if successful, false otherwise | ||
380 | */ | ||
381 | //USbool init( const KKeySequence& keySeq ); | ||
382 | |||
383 | /** | ||
384 | * Initializes this key sequence to contain the given key sequence. | ||
385 | * The description consists of comma-separated keys as | ||
386 | * required by @ref KKey::KKey(const QString&). | ||
387 | * @param key the description of the key | ||
388 | * @return true if successful, false otherwise | ||
389 | * @see KKeyServer::Sym::init() | ||
390 | * @see KKey::KKey(const QString&) | ||
391 | */ | ||
392 | //USbool init( const QString& key ); | ||
393 | |||
394 | /** | ||
395 | * Copy the given key sequence into this sequence. | ||
396 | */ | ||
397 | //USKKeySequence& operator =( const KKeySequence& seq ) | ||
398 | //US { init( seq ); return *this; } | ||
399 | |||
400 | /** | ||
401 | * Returns the number of key strokes of this sequence. | ||
402 | * @return the number of key strokes | ||
403 | * @see MAX_KEYS | ||
404 | */ | ||
405 | //USuint count() const; | ||
406 | |||
407 | /** | ||
408 | * Return the @p i'th key of this sequence, or a null key if there | ||
409 | * are less then i keys. | ||
410 | * @param i the key to retrieve | ||
411 | * @return the @p i'th key, or @ref KKey::null() if there are less | ||
412 | * than i keys | ||
413 | * @see MAX_KEYS | ||
414 | */ | ||
415 | //USconst KKey& key( uint i ) const; | ||
416 | |||
417 | /** | ||
418 | * @internal | ||
419 | */ | ||
420 | //USbool isTriggerOnRelease() const; | ||
421 | |||
422 | /** | ||
423 | * Sets the @p i'th key of the sequence. You can not introduce gaps | ||
424 | * in a sequence, so you must use an @p i <= @ref count(). Also note that | ||
425 | * the maximum length of a key sequence is @ref MAX_KEYS. | ||
426 | * @param i the position of the new key (<= @ref count(), <= @ref MAX_KEYS) | ||
427 | * @param key the key to set | ||
428 | * @return true if successful, false otherwise | ||
429 | */ | ||
430 | //USbool setKey( uint i, const KKey& key ); | ||
431 | |||
432 | /** | ||
433 | * @internal | ||
434 | */ | ||
435 | //USvoid setTriggerOnRelease( bool ); | ||
436 | |||
437 | /** | ||
438 | * Returns true if the key sequence is null (after @ref clear() or empty | ||
439 | * constructor). | ||
440 | * @return true if the key sequence is null | ||
441 | * @see clear() | ||
442 | * @see null() | ||
443 | */ | ||
444 | //US bool isNull() const; | ||
445 | |||
446 | /** | ||
447 | * Returns true if this key sequence begins with the given sequence. | ||
448 | * @param keySeq the key sequence to search | ||
449 | * @return true if this key sequence begins with the given sequence | ||
450 | */ | ||
451 | //USbool startsWith( const KKeySequence& keySeq ) const; | ||
452 | |||
453 | /** | ||
454 | * Compares this object with the given key sequence. Returns a negative | ||
455 | * number if the given KKeySequence is larger, 0 if they are equal and | ||
456 | * a positive number this KKeySequence is larger. Key sequences are | ||
457 | * compared by comparing the individual keys, starting from the beginning | ||
458 | * until an unequal key has been found. If a sequence contains more | ||
459 | * keys, it is considered larger. | ||
460 | * @param keySeq the key sequence to compare to | ||
461 | * @return a negative number if the given KKeySequence is larger, 0 if | ||
462 | * they are equal and a positive number this KKeySequence is larger | ||
463 | * @see KKey::sequence | ||
464 | */ | ||
465 | //USint compare( const KKeySequence& keySeq ) const; | ||
466 | |||
467 | /** | ||
468 | * Compares the keys of both sequences. | ||
469 | * @see compare() | ||
470 | */ | ||
471 | //USbool operator == ( const KKeySequence& seq ) const | ||
472 | //US { return compare( seq ) == 0; } | ||
473 | |||
474 | /** | ||
475 | * Compares the keys of both sequences. | ||
476 | * @see compare() | ||
477 | */ | ||
478 | //USbool operator != ( const KKeySequence& seq ) const | ||
479 | //US { return compare( seq ) != 0; } | ||
480 | |||
481 | /** | ||
482 | * Compares the keys of both sequences. | ||
483 | * @see compare() | ||
484 | */ | ||
485 | //USbool operator < ( const KKeySequence& seq ) const | ||
486 | //US { return compare( seq ) < 0; } | ||
487 | // TODO: consider adding Qt::SequenceMatch matches(...) methods for QKeySequence equivalence | ||
488 | |||
489 | /** | ||
490 | * Converts this key sequence to a QKeySequence. | ||
491 | * @return the QKeySequence | ||
492 | */ | ||
493 | //USQKeySequence qt() const; | ||
494 | |||
495 | /** | ||
496 | * Returns the qt key code of the first key. | ||
497 | * @return the qt key code of the first key | ||
498 | * @see Qt::Key | ||
499 | * @see KKey::keyCodeQt() | ||
500 | */ | ||
501 | //USint keyCodeQt() const; | ||
502 | |||
503 | /** | ||
504 | * Returns the key sequence as a number of key presses as | ||
505 | * returned by @ref KKey::toString(), seperated by commas. | ||
506 | * @return the string represenation of this key sequence | ||
507 | * @see KKey::toString() | ||
508 | */ | ||
509 | //USQString toString() const; | ||
510 | |||
511 | /** | ||
512 | * @internal | ||
513 | */ | ||
514 | //US QString toStringInternal() const; | ||
515 | |||
516 | /** | ||
517 | * Returns a null key sequence. | ||
518 | * @return the null key sequence | ||
519 | * @see isNull() | ||
520 | * @see clear() | ||
521 | */ | ||
522 | //USstatic KKeySequence& null(); | ||
523 | |||
524 | //US protected: | ||
525 | //USuchar m_nKeys; | ||
526 | //USuchar m_bTriggerOnRelease; | ||
527 | // BCI: m_rgvar should be renamed to m_rgkey for KDE 4.0 | ||
528 | //USKKey m_rgvar[MAX_KEYS]; | ||
529 | |||
530 | //US private: | ||
531 | //USclass KKeySequencePrivate* d; | ||
532 | //USfriend class KKeyNative; | ||
533 | //US}; | ||
534 | |||
535 | /** | ||
536 | * The KShortcut class is used to represent a keyboard shortcut to an action. | ||
537 | * A shortcut is normally a single key with modifiers, such as Ctrl+V. | ||
538 | * A KShortcut object may also contain an alternate key which will also | ||
539 | * activate the action it's associated to, as long as no other actions have | ||
540 | * defined that key as their primary key. Ex: Ctrl+V;Shift+Insert. | ||
541 | */ | ||
542 | |||
543 | class KShortcut | ||
544 | { | ||
545 | public: | ||
546 | /** | ||
547 | * The maximum number of key sequences that can be contained in | ||
548 | * a KShortcut. | ||
549 | */ | ||
550 | enum { MAX_SEQUENCES = 2 }; | ||
551 | |||
552 | /** | ||
553 | * Creates a new null shortcut. | ||
554 | * @see null() | ||
555 | * @see isNull() | ||
556 | * @see clear() | ||
557 | */ | ||
558 | KShortcut() {} | ||
559 | |||
560 | /** | ||
561 | * Creates a new shortcut with the given Qt key code | ||
562 | * as the only key sequence. | ||
563 | * @param keyQt the qt keycode | ||
564 | * @see Qt::Key | ||
565 | */ | ||
566 | KShortcut( int keyQt ) {} | ||
567 | |||
568 | /** | ||
569 | * Creates a new shortcut that contains only the given qt key | ||
570 | * sequence. | ||
571 | * @param keySeq the qt key sequence to add | ||
572 | */ | ||
573 | //USKShortcut( const QKeySequence& keySeq ) {} | ||
574 | |||
575 | /** | ||
576 | * Creates a new shortcut that contains only the given key | ||
577 | * in its only sequence. | ||
578 | * @param key the key to add | ||
579 | */ | ||
580 | //USKShortcut( const KKey& key ); | ||
581 | |||
582 | /** | ||
583 | * Creates a new shortcut that contains only the given key | ||
584 | * sequence. | ||
585 | * @param keySeq the key sequence to add | ||
586 | */ | ||
587 | //USKShortcut( const KKeySequence& keySeq ); | ||
588 | |||
589 | /** | ||
590 | * Copies the given shortcut. | ||
591 | * @param shortcut the shortcut to add | ||
592 | */ | ||
593 | //USKShortcut( const KShortcut& shortcut ); | ||
594 | |||
595 | /** | ||
596 | * Creates a new key sequence that contains the given key sequence. | ||
597 | * The description consists of semicolon-separated keys as | ||
598 | * used in @ref KKeySequence::KKeySequence(const QString&). | ||
599 | * @param shortcut the description of the key | ||
600 | * @see KKeySequence::KKeySequence(const QString&) | ||
601 | */ | ||
602 | KShortcut( const char* shortcut ) {} | ||
603 | |||
604 | /** | ||
605 | * Creates a new key sequence that contains the given key sequence. | ||
606 | * The description consists of semicolon-separated keys as | ||
607 | * used in @ref KKeySequence::KKeySequence(const QString&). | ||
608 | * @param shortcut the description of the key | ||
609 | * @see KKeySequence::KKeySequence(const QString&) | ||
610 | */ | ||
611 | KShortcut( const QString& shortcut ) {} | ||
612 | ~KShortcut() {} | ||
613 | |||
614 | /** | ||
615 | * Clears the shortcut. The shortcut is null after calling this | ||
616 | * function. | ||
617 | * @see isNull() | ||
618 | */ | ||
619 | //USvoid clear(); | ||
620 | |||
621 | /** | ||
622 | * Initializes the shortcut with the given Qt key code | ||
623 | * as the only key sequence. | ||
624 | * @param keyQt the qt keycode | ||
625 | * @see Qt::Key | ||
626 | */ | ||
627 | //USbool init( int keyQt ); | ||
628 | |||
629 | /** | ||
630 | * Initializes the shortcut with the given qt key sequence. | ||
631 | * @param keySeq the qt key sequence to add | ||
632 | */ | ||
633 | //USbool init( const QKeySequence& keySeq ); | ||
634 | |||
635 | /** | ||
636 | * Initializes the shortcut with the given key as its only sequence. | ||
637 | * @param key the key to add | ||
638 | */ | ||
639 | //USbool init( const KKey& key ); | ||
640 | |||
641 | /** | ||
642 | * Initializes the shortcut with the given qt key sequence. | ||
643 | * @param keySeq the qt key sequence to add | ||
644 | */ | ||
645 | //USbool init( const KKeySequence& keySeq ); | ||
646 | |||
647 | /** | ||
648 | * Copies the given shortcut. | ||
649 | * @param shortcut the shortcut to add | ||
650 | */ | ||
651 | //USbool init( const KShortcut& shortcut ); | ||
652 | |||
653 | /** | ||
654 | * Initializes the key sequence with the given key sequence. | ||
655 | * The description consists of semicolon-separated keys as | ||
656 | * used in @ref KKeySequence::KKeySequence(const QString&). | ||
657 | * @param shortcut the description of the key | ||
658 | * @see KKeySequence::KKeySequence(const QString&) | ||
659 | */ | ||
660 | //USbool init( const QString& shortcut ); | ||
661 | |||
662 | /** | ||
663 | * Copies the given shortcut over this shortcut. | ||
664 | */ | ||
665 | //USKShortcut& operator =( const KShortcut& cut ) | ||
666 | //US { init( cut ); return *this; } | ||
667 | |||
668 | /** | ||
669 | * Returns the number of sequences that are in this | ||
670 | * shortcut. | ||
671 | * @return the number of sequences | ||
672 | * @ref MAX_SEQUENCES | ||
673 | */ | ||
674 | //USuint count() const; | ||
675 | |||
676 | /** | ||
677 | * Returns the @p i'th key sequence of this shortcut. | ||
678 | * @param i the number of the key sequence to retrieve | ||
679 | * @return the @p i'th sequence or @ref KKeySequence::null() if | ||
680 | * there are less than @p i key sequences | ||
681 | * @ref MAX_SEQUENCES | ||
682 | */ | ||
683 | //USconst KKeySequence& seq( uint i ) const; | ||
684 | |||
685 | /** | ||
686 | * Returns the key code of the first key sequence, or | ||
687 | * null if there is no first key sequence. | ||
688 | * @return the key code of the first sequence's first key | ||
689 | * @see Qt::Key | ||
690 | * @see KKeySequence::keyCodeQt() | ||
691 | */ | ||
692 | //USint keyCodeQt() const; | ||
693 | |||
694 | /** | ||
695 | * Returns true if the shortcut is null (after @ref clear() or empty | ||
696 | * constructor). | ||
697 | * @return true if the shortcut is null | ||
698 | * @see clear() | ||
699 | * @see null() | ||
700 | */ | ||
701 | bool isNull() const { return true; } | ||
702 | |||
703 | /** | ||
704 | * Compares this object with the given shortcut. Returns a negative | ||
705 | * number if the given shortcut is larger, 0 if they are equal and | ||
706 | * a positive number this shortcut is larger. Shortcuts are | ||
707 | * compared by comparing the individual key sequences, starting from the | ||
708 | * beginning until an unequal key sequences has been found. If a shortcut | ||
709 | * contains more key sequences, it is considered larger. | ||
710 | * @param shortcut the shortcut to compare to | ||
711 | * @return a negative number if the given KShortcut is larger, 0 if | ||
712 | * they are equal and a positive number this KShortcut is larger | ||
713 | * @see KKey::compare() | ||
714 | * @see KKeyShortcut::compare() | ||
715 | */ | ||
716 | //USint compare( const KShortcut& shortcut ) const; | ||
717 | |||
718 | /** | ||
719 | * Compares the sequences of both shortcuts. | ||
720 | * @see compare() | ||
721 | */ | ||
722 | //USbool operator == ( const KShortcut& cut ) const | ||
723 | //US { return compare( cut ) == 0; } | ||
724 | |||
725 | /** | ||
726 | * Compares the sequences of both shortcuts. | ||
727 | * @see compare() | ||
728 | */ | ||
729 | //USbool operator != ( const KShortcut& cut ) const | ||
730 | //US { return compare( cut ) != 0; } | ||
731 | |||
732 | /** | ||
733 | * Compares the sequences of both shortcuts. | ||
734 | * @see compare() | ||
735 | */ | ||
736 | //USbool operator < ( const KShortcut& cut ) const | ||
737 | //US { return compare( cut ) < 0; } | ||
738 | |||
739 | /** | ||
740 | * Checks whether this shortcut contains a sequence that starts | ||
741 | * with the given key. | ||
742 | * @param key the key to check | ||
743 | * @return true if a key sequence starts with the key | ||
744 | */ | ||
745 | //USbool contains( const KKey& key ) const; | ||
746 | |||
747 | /** | ||
748 | * Checks whether this shortcut contains a sequence that starts | ||
749 | * with the given key. | ||
750 | * @param key the key to check | ||
751 | * @return true if a key sequence starts with the key | ||
752 | */ | ||
753 | //USbool contains( const KKeyNative& key ) const; | ||
754 | |||
755 | /** | ||
756 | * Checks whether this shortcut contains the given sequence. | ||
757 | * @param keySeq the key sequence to check | ||
758 | * @return true if the shortcut has the given key sequence | ||
759 | */ | ||
760 | //USbool contains( const KKeySequence& keySeq ) const; | ||
761 | |||
762 | /** | ||
763 | * Sets the @p i'th key sequence of the shortcut. You can not introduce | ||
764 | * gaps in the list of sequences, so you must use an @i <= @ref count(). | ||
765 | * Also note that the maximum number of key sequences is @ref MAX_SEQUENCES. | ||
766 | * @param i the position of the new key sequence(<= @ref count(), | ||
767 | * <= @ref MAX_SEQUENCES) | ||
768 | * @param keySeq the key sequence to set | ||
769 | * @return true if successful, false otherwise | ||
770 | */ | ||
771 | //USbool setSeq( uint i, const KKeySequence& keySeq ); | ||
772 | |||
773 | /** | ||
774 | * Appends the given key sequence. | ||
775 | * @param keySeq the key sequence to add | ||
776 | * @return true if successful, false otherwise | ||
777 | * @see setSeq() | ||
778 | * @see MAX_SEQUENCES | ||
779 | */ | ||
780 | //USbool append( const KKeySequence& keySeq ); | ||
781 | |||
782 | /** | ||
783 | * Appends the given key | ||
784 | * @param spec the key to add | ||
785 | * @return true if successful, false otherwise | ||
786 | * @see setSeq() | ||
787 | * @see MAX_SEQUENCES | ||
788 | * @since 3.2 | ||
789 | */ | ||
790 | //USbool append( const KKey& spec ); | ||
791 | |||
792 | /** | ||
793 | * Appends the sequences from the given shortcut. | ||
794 | * @param cut the shortcut to append | ||
795 | * @return true if successful, false otherwise | ||
796 | * @see MAX_SEQUENCES | ||
797 | * @since 3.2 | ||
798 | */ | ||
799 | //USbool append( const KShortcut& cut ); | ||
800 | |||
801 | /** | ||
802 | * Converts this shortcut to a key sequence. The first key sequence | ||
803 | * will be taken. | ||
804 | */ | ||
805 | //USoperator QKeySequence () const; | ||
806 | |||
807 | /** | ||
808 | * Returns a description of the shortcut as semicolon-separated | ||
809 | * ket sequences, as returned by @ref KKeySequence::toString(). | ||
810 | * @return the string represenation of this shortcut | ||
811 | * @see KKey::toString() | ||
812 | * @see KKeySequence::toString() | ||
813 | */ | ||
814 | //USQString toString() const; | ||
815 | |||
816 | /** | ||
817 | * @internal | ||
818 | */ | ||
819 | QString toStringInternal( const KShortcut* pcutDefault = 0 ) const | ||
820 | { | ||
821 | return "EMPTY IMPL."; | ||
822 | } | ||
823 | |||
824 | /** | ||
825 | * Returns a null shortcut. | ||
826 | * @return the null shortcut | ||
827 | * @see isNull() | ||
828 | * @see clear() | ||
829 | */ | ||
830 | //USstatic KShortcut& null(); | ||
831 | |||
832 | //US protected: | ||
833 | //USuint m_nSeqs; | ||
834 | //USKKeySequence m_rgseq[MAX_SEQUENCES]; | ||
835 | |||
836 | //US private: | ||
837 | //USclass KShortcutPrivate* d; | ||
838 | //USfriend class KKeyNative; | ||
839 | |||
840 | //US#ifndef KDE_NO_COMPAT | ||
841 | //US public: | ||
842 | //USoperator int () const { return keyCodeQt(); } | ||
843 | //US#endif | ||
844 | }; | ||
845 | |||
846 | #endif // __KSHORTCUT_H | ||