qshortcutmap.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qshortcutmap.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7struct QShortcutEntry-
8{-
9 QShortcutEntry()-
10 : keyseq(0), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0), contextMatcher(0)-
11 {}
never executed: end of block
0
12-
13 QShortcutEntry(const QKeySequence &k)-
14 : keyseq(k), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0), contextMatcher(0)-
15 {}
never executed: end of block
0
16-
17 QShortcutEntry(QObject *o, const QKeySequence &k, Qt::ShortcutContext c, int i, bool a, QShortcutMap::ContextMatcher m)-
18 : keyseq(k), context(c), enabled(true), autorepeat(a), id(i), owner(o), contextMatcher(m)-
19 {}
never executed: end of block
0
20-
21 bool correctContext() const { return
never executed: return contextMatcher(owner, context);
contextMatcher(owner, context);
never executed: return contextMatcher(owner, context);
}
0
22-
23 bool operator<(const QShortcutEntry &f) const-
24 { return
never executed: return keyseq < f.keyseq;
keyseq < f.keyseq;
never executed: return keyseq < f.keyseq;
}
0
25-
26 QKeySequence keyseq;-
27 Qt::ShortcutContext context;-
28 bool enabled : 1;-
29 bool autorepeat : 1;-
30 signed int id;-
31 QObject *owner;-
32 QShortcutMap::ContextMatcher contextMatcher;-
33};-
34class QShortcutMapPrivate-
35{-
36 inline QShortcutMap* q_func() { return static_cast<QShortcutMap *>(q_ptr); } inline const QShortcutMap* q_func() const { return static_cast<const QShortcutMap *>(q_ptr); } friend class QShortcutMap;-
37-
38public:-
39 QShortcutMapPrivate(QShortcutMap* parent)-
40 : q_ptr(parent), currentId(0), ambigCount(0), currentState(QKeySequence::NoMatch)-
41 {-
42 identicals.reserve(10);-
43 currentSequences.reserve(10);-
44 }
never executed: end of block
0
45 QShortcutMap *q_ptr;-
46-
47 QList<QShortcutEntry> sequences;-
48-
49 int currentId;-
50 int ambigCount;-
51 QKeySequence::SequenceMatch currentState;-
52 QVector<QKeySequence> currentSequences;-
53 QVector<QKeySequence> newEntries;-
54 QKeySequence prevSequence;-
55 QVector<const QShortcutEntry*> identicals;-
56};-
57-
58-
59-
60-
61-
62QShortcutMap::QShortcutMap()-
63 : d_ptr(new QShortcutMapPrivate(this))-
64{-
65 resetState();-
66}
never executed: end of block
0
67-
68-
69-
70-
71QShortcutMap::~QShortcutMap()-
72{-
73}-
74-
75-
76-
77-
78-
79int QShortcutMap::addShortcut(QObject *owner, const QKeySequence &key, Qt::ShortcutContext context, ContextMatcher matcher)-
80{-
81 ((!(owner)) ? qt_assert_x("QShortcutMap::addShortcut", "All shortcuts need an owner",__FILE__,154) : qt_noop());-
82 ((!(!key.isEmpty())) ? qt_assert_x("QShortcutMap::addShortcut", "Cannot add keyless shortcuts to map",__FILE__,155) : qt_noop());-
83 QShortcutMapPrivate * const d = d_func();-
84-
85 QShortcutEntry newEntry(owner, key, context, --(d->currentId), true, matcher);-
86 QList<QShortcutEntry>::iterator it = std::upper_bound(d->sequences.begin(), d->sequences.end(), newEntry);-
87 d->sequences.insert(it, newEntry);-
88-
89-
90-
91-
92-
93 return
never executed: return d->currentId;
d->currentId;
never executed: return d->currentId;
0
94}-
95int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key)-
96{-
97 QShortcutMapPrivate * const d = d_func();-
98 int itemsRemoved = 0;-
99 bool allOwners = (owner == 0);-
100 bool allKeys = key.isEmpty();-
101 bool allIds = id == 0;-
102-
103-
104 if (allOwners
allOwnersDescription
TRUEnever evaluated
FALSEnever evaluated
&& allKeys
allKeysDescription
TRUEnever evaluated
FALSEnever evaluated
&& id == 0
id == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
105 itemsRemoved = d->sequences.size();-
106 d->sequences.clear();-
107 return
never executed: return itemsRemoved;
itemsRemoved;
never executed: return itemsRemoved;
0
108 }-
109-
110 int i = d->sequences.size()-1;-
111 while (i>=0
i>=0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
112 {-
113 const QShortcutEntry &entry = d->sequences.at(i);-
114 int entryId = entry.id;-
115 if ((allOwners
allOwnersDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.owner == owner
entry.owner == ownerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
116 && (allIds
allIdsDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.id == id
entry.id == idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
117 && (allKeys
allKeysDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.keyseq == key
entry.keyseq == keyDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
118 d->sequences.removeAt(i);-
119 ++itemsRemoved;-
120 }
never executed: end of block
0
121 if (id == entryId
id == entryIdDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
122 return
never executed: return itemsRemoved;
itemsRemoved;
never executed: return itemsRemoved;
0
123 --i;-
124 }
never executed: end of block
0
125-
126-
127-
128-
129-
130 return
never executed: return itemsRemoved;
itemsRemoved;
never executed: return itemsRemoved;
0
131}-
132int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &key)-
133{-
134 QShortcutMapPrivate * const d = d_func();-
135 int itemsChanged = 0;-
136 bool allOwners = (owner == 0);-
137 bool allKeys = key.isEmpty();-
138 bool allIds = id == 0;-
139-
140 int i = d->sequences.size()-1;-
141 while (i>=0
i>=0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
142 {-
143 QShortcutEntry entry = d->sequences.at(i);-
144 if ((allOwners
allOwnersDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.owner == owner
entry.owner == ownerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
145 && (allIds
allIdsDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.id == id
entry.id == idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
146 && (allKeys
allKeysDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.keyseq == key
entry.keyseq == keyDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
147 d->sequences[i].enabled = enable;-
148 ++itemsChanged;-
149 }
never executed: end of block
0
150 if (id == entry.id
id == entry.idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
151 return
never executed: return itemsChanged;
itemsChanged;
never executed: return itemsChanged;
0
152 --i;-
153 }
never executed: end of block
0
154-
155-
156-
157-
158-
159 return
never executed: return itemsChanged;
itemsChanged;
never executed: return itemsChanged;
0
160}-
161int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &key)-
162{-
163 QShortcutMapPrivate * const d = d_func();-
164 int itemsChanged = 0;-
165 bool allOwners = (owner == 0);-
166 bool allKeys = key.isEmpty();-
167 bool allIds = id == 0;-
168-
169 int i = d->sequences.size()-1;-
170 while (i>=0
i>=0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
171 {-
172 QShortcutEntry entry = d->sequences.at(i);-
173 if ((allOwners
allOwnersDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.owner == owner
entry.owner == ownerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
174 && (allIds
allIdsDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.id == id
entry.id == idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
175 && (allKeys
allKeysDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.keyseq == key
entry.keyseq == keyDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
176 d->sequences[i].autorepeat = on;-
177 ++itemsChanged;-
178 }
never executed: end of block
0
179 if (id == entry.id
id == entry.idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
180 return
never executed: return itemsChanged;
itemsChanged;
never executed: return itemsChanged;
0
181 --i;-
182 }
never executed: end of block
0
183-
184-
185-
186-
187-
188 return
never executed: return itemsChanged;
itemsChanged;
never executed: return itemsChanged;
0
189}-
190-
191-
192-
193-
194void QShortcutMap::resetState()-
195{-
196 QShortcutMapPrivate * const d = d_func();-
197 d->currentState = QKeySequence::NoMatch;-
198 clearSequence(d->currentSequences);-
199}
never executed: end of block
0
200-
201-
202-
203-
204QKeySequence::SequenceMatch QShortcutMap::state()-
205{-
206 QShortcutMapPrivate * const d = d_func();-
207 return
never executed: return d->currentState;
d->currentState;
never executed: return d->currentState;
0
208}-
209bool QShortcutMap::tryShortcut(QKeyEvent *e)-
210{-
211 QShortcutMapPrivate * const d = d_func();-
212-
213 if (e->key() == Qt::Key_unknown
e->key() == Qt::Key_unknownDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
214 return
never executed: return false;
false;
never executed: return false;
0
215-
216 QKeySequence::SequenceMatch previousState = state();-
217-
218 switch (nextState(e)) {-
219 case
never executed: case QKeySequence::NoMatch:
QKeySequence::NoMatch:
never executed: case QKeySequence::NoMatch:
0
220-
221-
222-
223 return
never executed: return previousState == QKeySequence::PartialMatch;
previousState == QKeySequence::PartialMatch;
never executed: return previousState == QKeySequence::PartialMatch;
0
224 case
never executed: case QKeySequence::PartialMatch:
QKeySequence::PartialMatch:
never executed: case QKeySequence::PartialMatch:
0
225-
226-
227 return
never executed: return true;
true;
never executed: return true;
0
228 case
never executed: case QKeySequence::ExactMatch:
QKeySequence::ExactMatch:
never executed: case QKeySequence::ExactMatch:
{
0
229-
230-
231 const int identicalMatches = d->identicals.count();-
232 resetState();-
233 dispatchEvent(e);-
234-
235-
236 return
never executed: return identicalMatches > 0;
identicalMatches > 0;
never executed: return identicalMatches > 0;
0
237 }-
238 default
never executed: default:
:
never executed: default:
0
239 do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,350) : qt_noop()); __builtin_unreachable(); } while (0);-
240 }
never executed: end of block
0
241}-
242-
243-
244-
245-
246-
247-
248-
249QKeySequence::SequenceMatch QShortcutMap::nextState(QKeyEvent *e)-
250{-
251 QShortcutMapPrivate * const d = d_func();-
252-
253 if (e->key() >= Qt::Key_Shift
e->key() >= Qt::Key_ShiftDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
254 e->key() <= Qt::Key_Alt
e->key() <= Qt::Key_AltDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
255 return
never executed: return d->currentState;
d->currentState;
never executed: return d->currentState;
0
256-
257 QKeySequence::SequenceMatch result = QKeySequence::NoMatch;-
258-
259-
260 d->identicals.resize(0);-
261-
262 result = find(e);-
263 if (result == QKeySequence::NoMatch
result == QKey...uence::NoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(e->modifiers(...eypadModifier)Description
TRUEnever evaluated
FALSEnever evaluated
e->modifiers() & Qt::KeypadModifier)
(e->modifiers(...eypadModifier)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
264-
265 result = find(e, Qt::KeypadModifier);-
266 }
never executed: end of block
0
267 if (result == QKeySequence::NoMatch
result == QKey...uence::NoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
&& e->modifiers() & Qt::ShiftModifier
e->modifiers()...:ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
268-
269 if (e->key() == Qt::Key_Backtab
e->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
270 QKeyEvent pe = QKeyEvent(e->type(), Qt::Key_Tab, e->modifiers(), e->text());-
271 result = find(&pe);-
272 }
never executed: end of block
0
273 }
never executed: end of block
0
274-
275-
276 if (result == QKeySequence::NoMatch
result == QKey...uence::NoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
277 clearSequence(d->currentSequences);
never executed: clearSequence(d->currentSequences);
0
278 d->currentState = result;-
279-
280-
281-
282-
283 return
never executed: return result;
result;
never executed: return result;
0
284}-
285-
286-
287-
288-
289-
290bool QShortcutMap::hasShortcutForKeySequence(const QKeySequence &seq) const-
291{-
292 const QShortcutMapPrivate * const d = d_func();-
293 QShortcutEntry entry(seq);-
294 QList<QShortcutEntry>::ConstIterator itEnd = d->sequences.constEnd();-
295 QList<QShortcutEntry>::ConstIterator it = std::lower_bound(d->sequences.constBegin(), itEnd, entry);-
296-
297 for (;it != itEnd
it != itEndDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
298 if (matches(entry.keyseq, (*it).keyseq) == QKeySequence::ExactMatch
matches(entry....ce::ExactMatchDescription
TRUEnever evaluated
FALSEnever evaluated
&& (*
(*it).correctContext()Description
TRUEnever evaluated
FALSEnever evaluated
it).correctContext()
(*it).correctContext()Description
TRUEnever evaluated
FALSEnever evaluated
&& (*
(*it).enabledDescription
TRUEnever evaluated
FALSEnever evaluated
it).enabled
(*it).enabledDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
299 return
never executed: return true;
true;
never executed: return true;
0
300 }-
301 }
never executed: end of block
0
302-
303-
304 return
never executed: return false;
false;
never executed: return false;
0
305}-
306QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifiers)-
307{-
308 QShortcutMapPrivate * const d = d_func();-
309 if (!d->sequences.count()
!d->sequences.count()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
310 return
never executed: return QKeySequence::NoMatch;
QKeySequence::NoMatch;
never executed: return QKeySequence::NoMatch;
0
311-
312 createNewSequences(e, d->newEntries, ignoredModifiers);-
313-
314-
315-
316-
317-
318 if (d->newEntries == d->currentSequences
d->newEntries ...rrentSequencesDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
319 ((!(e->key() != Qt::Key_unknown || e->text().length())) ? qt_assert_x("QShortcutMap::find", "New sequence to find identical to previous",-
320 __FILE__-
321 ,-
322 439-
323 ) : qt_noop())-
324 ;-
325 return
never executed: return QKeySequence::NoMatch;
QKeySequence::NoMatch;
never executed: return QKeySequence::NoMatch;
0
326 }-
327-
328-
329 d->identicals.resize(0);-
330-
331 bool partialFound = false;-
332 bool identicalDisabledFound = false;-
333 QVector<QKeySequence> okEntries;-
334 int result = QKeySequence::NoMatch;-
335 for (int i = d->newEntries.count()-1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
336 QShortcutEntry entry(d->newEntries.at(i));-
337 QList<QShortcutEntry>::ConstIterator itEnd = d->sequences.constEnd();-
338 QList<QShortcutEntry>::ConstIterator it =-
339 std::lower_bound(d->sequences.constBegin(), itEnd, entry);-
340-
341 int oneKSResult = QKeySequence::NoMatch;-
342 int tempRes = QKeySequence::NoMatch;-
343 do {-
344 if (it == itEnd
it == itEndDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
345 break;
never executed: break;
0
346 tempRes = matches(entry.keyseq, (*it).keyseq);-
347 oneKSResult = qMax(oneKSResult, tempRes);-
348 if (tempRes != QKeySequence::NoMatch
tempRes != QKe...uence::NoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
&& (*
(*it).correctContext()Description
TRUEnever evaluated
FALSEnever evaluated
it).correctContext()
(*it).correctContext()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
349 if (tempRes == QKeySequence::ExactMatch
tempRes == QKe...ce::ExactMatchDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
350 if ((*
(*it).enabledDescription
TRUEnever evaluated
FALSEnever evaluated
it).enabled
(*it).enabledDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
351 d->identicals.append(&*it);
never executed: d->identicals.append(&*it);
0
352 else-
353 identicalDisabledFound = true;
never executed: identicalDisabledFound = true;
0
354 } else if (tempRes == QKeySequence::PartialMatch
tempRes == QKe...::PartialMatchDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
355-
356 if (d->identicals.size()
d->identicals.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
357 break;
never executed: break;
0
358-
359-
360 partialFound |= (*it).enabled;-
361 }
never executed: end of block
0
362 }
never executed: end of block
0
363 ++it;-
364-
365-
366-
367 }
never executed: end of block
while (tempRes != QKeySequence::NoMatch
tempRes != QKe...uence::NoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
368-
369-
370-
371 if (oneKSResult > result
oneKSResult > resultDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
372 okEntries.clear();-
373-
374-
375-
376 }
never executed: end of block
0
377 if (oneKSResult
oneKSResultDescription
TRUEnever evaluated
FALSEnever evaluated
&& oneKSResult >= result
oneKSResult >= resultDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
378 okEntries << d->newEntries.at(i);-
379-
380-
381-
382 }
never executed: end of block
0
383 }
never executed: end of block
0
384-
385 if (d->identicals.size()
d->identicals.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
386 result = QKeySequence::ExactMatch;-
387 }
never executed: end of block
else if (partialFound
partialFoundDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
388 result = QKeySequence::PartialMatch;-
389 }
never executed: end of block
else if (identicalDisabledFound
identicalDisabledFoundDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
390 result = QKeySequence::ExactMatch;-
391 }
never executed: end of block
else {
0
392 clearSequence(d->currentSequences);-
393 result = QKeySequence::NoMatch;-
394 }
never executed: end of block
0
395 if (result != QKeySequence::NoMatch
result != QKey...uence::NoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
396 d->currentSequences = okEntries;
never executed: d->currentSequences = okEntries;
0
397-
398-
399-
400 return
never executed: return QKeySequence::SequenceMatch(result);
QKeySequence::SequenceMatch(result);
never executed: return QKeySequence::SequenceMatch(result);
0
401}-
402-
403-
404-
405-
406-
407-
408void QShortcutMap::clearSequence(QVector<QKeySequence> &ksl)-
409{-
410 ksl.clear();-
411 d_func()->newEntries.clear();-
412}
never executed: end of block
0
413-
414-
415-
416-
417-
418void QShortcutMap::createNewSequences(QKeyEvent *e, QVector<QKeySequence> &ksl, int ignoredModifiers)-
419{-
420 QShortcutMapPrivate * const d = d_func();-
421 QList<int> possibleKeys = QKeyMapper::possibleKeys(e);-
422 int pkTotal = possibleKeys.count();-
423 if (!pkTotal
!pkTotalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
424 return;
never executed: return;
0
425-
426 int ssActual = d->currentSequences.count();-
427 int ssTotal = qMax(1, ssActual);-
428-
429 ksl.resize(pkTotal * ssTotal);-
430-
431 int index = ssActual
ssActualDescription
TRUEnever evaluated
FALSEnever evaluated
? d->currentSequences.at(0).count() : 0;
0
432 for (int pkNum = 0; pkNum < pkTotal
pkNum < pkTotalDescription
TRUEnever evaluated
FALSEnever evaluated
; ++pkNum) {
0
433 for (int ssNum = 0; ssNum < ssTotal
ssNum < ssTotalDescription
TRUEnever evaluated
FALSEnever evaluated
; ++ssNum) {
0
434 int i = (pkNum * ssTotal) + ssNum;-
435 QKeySequence &curKsl = ksl[i];-
436 if (ssActual
ssActualDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
437 const QKeySequence &curSeq = d->currentSequences.at(ssNum);-
438 curKsl.setKey(curSeq[0], 0);-
439 curKsl.setKey(curSeq[1], 1);-
440 curKsl.setKey(curSeq[2], 2);-
441 curKsl.setKey(curSeq[3], 3);-
442 }
never executed: end of block
else {
0
443 curKsl.setKey(0, 0);-
444 curKsl.setKey(0, 1);-
445 curKsl.setKey(0, 2);-
446 curKsl.setKey(0, 3);-
447 }
never executed: end of block
0
448 curKsl.setKey(possibleKeys.at(pkNum) & ~ignoredModifiers, index);-
449 }
never executed: end of block
0
450 }
never executed: end of block
0
451}
never executed: end of block
0
452-
453-
454-
455-
456-
457-
458QKeySequence::SequenceMatch QShortcutMap::matches(const QKeySequence &seq1,-
459 const QKeySequence &seq2) const-
460{-
461 uint userN = seq1.count(),-
462 seqN = seq2.count();-
463-
464 if (userN > seqN
userN > seqNDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
465 return
never executed: return QKeySequence::NoMatch;
QKeySequence::NoMatch;
never executed: return QKeySequence::NoMatch;
0
466-
467-
468-
469 QKeySequence::SequenceMatch match = (userN == seqN
userN == seqNDescription
TRUEnever evaluated
FALSEnever evaluated
0
470 ? QKeySequence::ExactMatch-
471 : QKeySequence::PartialMatch);-
472-
473 for (uint i = 0; i < userN
i < userNDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
474 int userKey = seq1[i],-
475 sequenceKey = seq2[i];-
476 if ((
(userKey & Qt:...Qt::Key_hyphenDescription
TRUEnever evaluated
FALSEnever evaluated
userKey & Qt::Key_unknown) == Qt::Key_hyphen
(userKey & Qt:...Qt::Key_hyphenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
477 userKey = (userKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
never executed: userKey = (userKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
0
478 if ((
(sequenceKey &...Qt::Key_hyphenDescription
TRUEnever evaluated
FALSEnever evaluated
sequenceKey & Qt::Key_unknown) == Qt::Key_hyphen
(sequenceKey &...Qt::Key_hyphenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
479 sequenceKey = (sequenceKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
never executed: sequenceKey = (sequenceKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
0
480 if (userKey != sequenceKey
userKey != sequenceKeyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
481 return
never executed: return QKeySequence::NoMatch;
QKeySequence::NoMatch;
never executed: return QKeySequence::NoMatch;
0
482 }
never executed: end of block
0
483 return
never executed: return match;
match;
never executed: return match;
0
484}-
485-
486-
487-
488-
489-
490int QShortcutMap::translateModifiers(Qt::KeyboardModifiers modifiers)-
491{-
492 int result = 0;-
493 if (modifiers & Qt::ShiftModifier
modifiers & Qt::ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
494 result |= Qt::SHIFT;
never executed: result |= Qt::SHIFT;
0
495 if (modifiers & Qt::ControlModifier
modifiers & Qt...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
496 result |= Qt::CTRL;
never executed: result |= Qt::CTRL;
0
497 if (modifiers & Qt::MetaModifier
modifiers & Qt::MetaModifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
498 result |= Qt::META;
never executed: result |= Qt::META;
0
499 if (modifiers & Qt::AltModifier
modifiers & Qt::AltModifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
500 result |= Qt::ALT;
never executed: result |= Qt::ALT;
0
501 return
never executed: return result;
result;
never executed: return result;
0
502}-
503-
504-
505-
506-
507QVector<const QShortcutEntry*> QShortcutMap::matches() const-
508{-
509 const QShortcutMapPrivate * const d = d_func();-
510 return
never executed: return d->identicals;
d->identicals;
never executed: return d->identicals;
0
511}-
512-
513-
514-
515-
516void QShortcutMap::dispatchEvent(QKeyEvent *e)-
517{-
518 QShortcutMapPrivate * const d = d_func();-
519 if (!d->identicals.size()
!d->identicals.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
520 return;
never executed: return;
0
521-
522 const QKeySequence &curKey = d->identicals.at(0)->keyseq;-
523 if (d->prevSequence != curKey
d->prevSequence != curKeyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
524 d->ambigCount = 0;-
525 d->prevSequence = curKey;-
526 }
never executed: end of block
0
527-
528 const QShortcutEntry *current = 0, *next = 0;-
529 int i = 0, enabledShortcuts = 0;-
530 while(i < d->identicals.size()
i < d->identicals.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
531 current = d->identicals.at(i);-
532 if (current->enabled
current->enabledDescription
TRUEnever evaluated
FALSEnever evaluated
|| !next
!nextDescription
TRUEnever evaluated
FALSEnever evaluated
){
0
533 ++enabledShortcuts;-
534 if (enabledShortcuts > d->ambigCount + 1
enabledShortcu...ambigCount + 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
535 break;
never executed: break;
0
536 next = current;-
537 }
never executed: end of block
0
538 ++i;-
539 }
never executed: end of block
0
540 d->ambigCount = (d->identicals.size() == i
d->identicals.size() == iDescription
TRUEnever evaluated
FALSEnever evaluated
? 0 : d->ambigCount + 1);
0
541-
542-
543 if (!next
!nextDescription
TRUEnever evaluated
FALSEnever evaluated
|| (e->isAutoRepeat()
e->isAutoRepeat()Description
TRUEnever evaluated
FALSEnever evaluated
&& !next->autorepeat
!next->autorepeatDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
544 return;
never executed: return;
0
545-
546-
547-
548-
549-
550-
551-
552 QShortcutEvent se(next->keyseq, next->id, enabledShortcuts>1);-
553 QCoreApplication::sendEvent(const_cast<QObject *>(next->owner), &se);-
554}
never executed: end of block
0
555-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9