OpenCoverage

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};-
34template<> class QTypeInfo<QShortcutEntry > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QShortcutEntry)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QShortcutEntry >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QShortcutEntry) }; static inline const char *name() { return "QShortcutEntry"; } };-
35class QShortcutMapPrivate-
36{-
37 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;-
38-
39public:-
40 QShortcutMapPrivate(QShortcutMap* parent)-
41 : q_ptr(parent), currentId(0), ambigCount(0), currentState(QKeySequence::NoMatch)-
42 {-
43 identicals.reserve(10);-
44 currentSequences.reserve(10);-
45 }
never executed: end of block
0
46 QShortcutMap *q_ptr;-
47-
48 QVector<QShortcutEntry> sequences;-
49-
50 int currentId;-
51 int ambigCount;-
52 QKeySequence::SequenceMatch currentState;-
53 QVector<QKeySequence> currentSequences;-
54 QVector<QKeySequence> newEntries;-
55 QKeySequence prevSequence;-
56 QVector<const QShortcutEntry*> identicals;-
57};-
58-
59-
60-
61-
62-
63QShortcutMap::QShortcutMap()-
64 : d_ptr(new QShortcutMapPrivate(this))-
65{-
66 resetState();-
67}
never executed: end of block
0
68-
69-
70-
71-
72QShortcutMap::~QShortcutMap()-
73{-
74}-
75-
76-
77-
78-
79-
80int QShortcutMap::addShortcut(QObject *owner, const QKeySequence &key, Qt::ShortcutContext context, ContextMatcher matcher)-
81{-
82 ((!(owner)) ? qt_assert_x("QShortcutMap::addShortcut", "All shortcuts need an owner",__FILE__,161) : qt_noop());-
83 ((!(!key.isEmpty())) ? qt_assert_x("QShortcutMap::addShortcut", "Cannot add keyless shortcuts to map",__FILE__,162) : qt_noop());-
84 QShortcutMapPrivate * const d = d_func();-
85-
86 QShortcutEntry newEntry(owner, key, context, --(d->currentId), true, matcher);-
87 const auto it = std::upper_bound(d->sequences.begin(), d->sequences.end(), newEntry);-
88 d->sequences.insert(it, newEntry);-
89-
90-
91-
92-
93-
94 return
never executed: return d->currentId;
d->currentId;
never executed: return d->currentId;
0
95}-
96int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key)-
97{-
98 QShortcutMapPrivate * const d = d_func();-
99 int itemsRemoved = 0;-
100 bool allOwners = (owner == 0);-
101 bool allKeys = key.isEmpty();-
102 bool allIds = id == 0;-
103-
104-
105 if (allOwners
allOwnersDescription
TRUEnever evaluated
FALSEnever evaluated
&& allKeys
allKeysDescription
TRUEnever evaluated
FALSEnever evaluated
&& allIds
allIdsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
106 itemsRemoved = d->sequences.size();-
107 d->sequences.clear();-
108 return
never executed: return itemsRemoved;
itemsRemoved;
never executed: return itemsRemoved;
0
109 }-
110-
111 int i = d->sequences.size()-1;-
112 while (i>=0
i>=0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
113 {-
114 const QShortcutEntry &entry = d->sequences.at(i);-
115 int entryId = entry.id;-
116 if ((allOwners
allOwnersDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.owner == owner
entry.owner == ownerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
117 && (allIds
allIdsDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.id == id
entry.id == idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
118 && (allKeys
allKeysDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.keyseq == key
entry.keyseq == keyDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
119 d->sequences.removeAt(i);-
120 ++itemsRemoved;-
121 }
never executed: end of block
0
122 if (id == entryId
id == entryIdDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
123 return
never executed: return itemsRemoved;
itemsRemoved;
never executed: return itemsRemoved;
0
124 --i;-
125 }
never executed: end of block
0
126-
127-
128-
129-
130-
131 return
never executed: return itemsRemoved;
itemsRemoved;
never executed: return itemsRemoved;
0
132}-
133int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &key)-
134{-
135 QShortcutMapPrivate * const d = d_func();-
136 int itemsChanged = 0;-
137 bool allOwners = (owner == 0);-
138 bool allKeys = key.isEmpty();-
139 bool allIds = id == 0;-
140-
141 int i = d->sequences.size()-1;-
142 while (i>=0
i>=0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
143 {-
144 QShortcutEntry entry = d->sequences.at(i);-
145 if ((allOwners
allOwnersDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.owner == owner
entry.owner == ownerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
146 && (allIds
allIdsDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.id == id
entry.id == idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
147 && (allKeys
allKeysDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.keyseq == key
entry.keyseq == keyDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
148 d->sequences[i].enabled = enable;-
149 ++itemsChanged;-
150 }
never executed: end of block
0
151 if (id == entry.id
id == entry.idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
152 return
never executed: return itemsChanged;
itemsChanged;
never executed: return itemsChanged;
0
153 --i;-
154 }
never executed: end of block
0
155-
156-
157-
158-
159-
160 return
never executed: return itemsChanged;
itemsChanged;
never executed: return itemsChanged;
0
161}-
162int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &key)-
163{-
164 QShortcutMapPrivate * const d = d_func();-
165 int itemsChanged = 0;-
166 bool allOwners = (owner == 0);-
167 bool allKeys = key.isEmpty();-
168 bool allIds = id == 0;-
169-
170 int i = d->sequences.size()-1;-
171 while (i>=0
i>=0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
172 {-
173 QShortcutEntry entry = d->sequences.at(i);-
174 if ((allOwners
allOwnersDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.owner == owner
entry.owner == ownerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
175 && (allIds
allIdsDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.id == id
entry.id == idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
176 && (allKeys
allKeysDescription
TRUEnever evaluated
FALSEnever evaluated
|| entry.keyseq == key
entry.keyseq == keyDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
177 d->sequences[i].autorepeat = on;-
178 ++itemsChanged;-
179 }
never executed: end of block
0
180 if (id == entry.id
id == entry.idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
181 return
never executed: return itemsChanged;
itemsChanged;
never executed: return itemsChanged;
0
182 --i;-
183 }
never executed: end of block
0
184-
185-
186-
187-
188-
189 return
never executed: return itemsChanged;
itemsChanged;
never executed: return itemsChanged;
0
190}-
191-
192-
193-
194-
195void QShortcutMap::resetState()-
196{-
197 QShortcutMapPrivate * const d = d_func();-
198 d->currentState = QKeySequence::NoMatch;-
199 clearSequence(d->currentSequences);-
200}
never executed: end of block
0
201-
202-
203-
204-
205QKeySequence::SequenceMatch QShortcutMap::state()-
206{-
207 QShortcutMapPrivate * const d = d_func();-
208 return
never executed: return d->currentState;
d->currentState;
never executed: return d->currentState;
0
209}-
210bool QShortcutMap::tryShortcut(QKeyEvent *e)-
211{-
212 QShortcutMapPrivate * const d = d_func();-
213-
214 if (e->key() == Qt::Key_unknown
e->key() == Qt::Key_unknownDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
215 return
never executed: return false;
false;
never executed: return false;
0
216-
217 QKeySequence::SequenceMatch previousState = state();-
218-
219 switch (nextState(e)) {-
220 case
never executed: case QKeySequence::NoMatch:
QKeySequence::NoMatch:
never executed: case QKeySequence::NoMatch:
0
221-
222-
223-
224 return
never executed: return previousState == QKeySequence::PartialMatch;
previousState == QKeySequence::PartialMatch;
never executed: return previousState == QKeySequence::PartialMatch;
0
225 case
never executed: case QKeySequence::PartialMatch:
QKeySequence::PartialMatch:
never executed: case QKeySequence::PartialMatch:
0
226-
227-
228 return
never executed: return true;
true;
never executed: return true;
0
229 case
never executed: case QKeySequence::ExactMatch:
QKeySequence::ExactMatch:
never executed: case QKeySequence::ExactMatch:
{
0
230-
231-
232 const int identicalMatches = d->identicals.count();-
233 resetState();-
234 dispatchEvent(e);-
235-
236-
237 return
never executed: return identicalMatches > 0;
identicalMatches > 0;
never executed: return identicalMatches > 0;
0
238 }-
239 }-
240 do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,357) : qt_noop()); __builtin_unreachable(); } while (0);-
241 return
never executed: return false;
false;
never executed: return false;
0
242}-
243-
244-
245-
246-
247-
248-
249-
250QKeySequence::SequenceMatch QShortcutMap::nextState(QKeyEvent *e)-
251{-
252 QShortcutMapPrivate * const d = d_func();-
253-
254 if (e->key() >= Qt::Key_Shift
e->key() >= Qt::Key_ShiftDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
255 e->key() <= Qt::Key_Alt
e->key() <= Qt::Key_AltDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
256 return
never executed: return d->currentState;
d->currentState;
never executed: return d->currentState;
0
257-
258 QKeySequence::SequenceMatch result = QKeySequence::NoMatch;-
259-
260-
261 d->identicals.clear();-
262-
263 result = find(e);-
264 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
265-
266 result = find(e, Qt::KeypadModifier);-
267 }
never executed: end of block
0
268 if (result == QKeySequence::NoMatch
result == QKey...uence::NoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
&& e->modifiers() & Qt::ShiftModifier
e->modifiers()...:ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
269-
270 if (e->key() == Qt::Key_Backtab
e->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
271 QKeyEvent pe = QKeyEvent(e->type(), Qt::Key_Tab, e->modifiers(), e->text());-
272 result = find(&pe);-
273 }
never executed: end of block
0
274 }
never executed: end of block
0
275-
276-
277 if (result == QKeySequence::NoMatch
result == QKey...uence::NoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
278 clearSequence(d->currentSequences);
never executed: clearSequence(d->currentSequences);
0
279 d->currentState = result;-
280-
281-
282-
283-
284 return
never executed: return result;
result;
never executed: return result;
0
285}-
286-
287-
288-
289-
290-
291bool QShortcutMap::hasShortcutForKeySequence(const QKeySequence &seq) const-
292{-
293 const QShortcutMapPrivate * const d = d_func();-
294 QShortcutEntry entry(seq);-
295 const auto itEnd = d->sequences.cend();-
296 auto it = std::lower_bound(d->sequences.cbegin(), itEnd, entry);-
297-
298 for (;it != itEnd
it != itEndDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
299 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
300 return
never executed: return true;
true;
never executed: return true;
0
301 }-
302 }
never executed: end of block
0
303-
304-
305 return
never executed: return false;
false;
never executed: return false;
0
306}-
307QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifiers)-
308{-
309 QShortcutMapPrivate * const d = d_func();-
310 if (!d->sequences.count()
!d->sequences.count()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
311 return
never executed: return QKeySequence::NoMatch;
QKeySequence::NoMatch;
never executed: return QKeySequence::NoMatch;
0
312-
313 createNewSequences(e, d->newEntries, ignoredModifiers);-
314-
315-
316-
317-
318-
319 if (d->newEntries == d->currentSequences
d->newEntries ...rrentSequencesDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
320 ((!(e->key() != Qt::Key_unknown || e->text().length())) ? qt_assert_x("QShortcutMap::find", "New sequence to find identical to previous",-
321 __FILE__-
322 ,-
323 446-
324 ) : qt_noop())-
325 ;-
326 return
never executed: return QKeySequence::NoMatch;
QKeySequence::NoMatch;
never executed: return QKeySequence::NoMatch;
0
327 }-
328-
329-
330 d->identicals.clear();-
331-
332 bool partialFound = false;-
333 bool identicalDisabledFound = false;-
334 QVector<QKeySequence> okEntries;-
335 int result = QKeySequence::NoMatch;-
336 for (int i = d->newEntries.count()-1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
337 QShortcutEntry entry(d->newEntries.at(i));-
338 const auto itEnd = d->sequences.constEnd();-
339 auto it = 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