kernel/qshortcutmap.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
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: }
0
12 -
13 QShortcutEntry(const QKeySequence &k) -
14 : keyseq(k), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0), contextMatcher(0) -
15 {}
executed: }
Execution Count:250
250
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 {}
executed: }
Execution Count:2624
2624
20 -
21 bool correctContext() const { return contextMatcher(owner, context); }
executed: return contextMatcher(owner, context);
Execution Count:219
219
22 -
23 bool operator<(const QShortcutEntry &f) const -
24 { return keyseq < f.keyseq; }
executed: return keyseq < f.keyseq;
Execution Count:5530
5530
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 }
executed: }
Execution Count:289
289
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}
executed: }
Execution Count:289
289
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 qt_noop(); -
82 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 d->currentId;
executed: return d->currentId;
Execution Count:2624
2624
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 && allKeys && id == 0) {
partially evaluated: allOwners
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2876
never evaluated: allKeys
never evaluated: id == 0
0-2876
105 itemsRemoved = d->sequences.size(); -
106 d->sequences.clear(); -
107 return itemsRemoved;
never executed: return itemsRemoved;
0
108 } -
109 -
110 int i = d->sequences.size()-1; -
111 while (i>=0)
evaluated: i>=0
TRUEFALSE
yes
Evaluation Count:14059
yes
Evaluation Count:1480
1480-14059
112 { -
113 const QShortcutEntry &entry = d->sequences.at(i); -
114 int entryId = entry.id; -
115 if ((allOwners || entry.owner == owner)
partially evaluated: allOwners
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14059
evaluated: entry.owner == owner
TRUEFALSE
yes
Evaluation Count:2665
yes
Evaluation Count:11394
0-14059
116 && (allIds || entry.id == id)
evaluated: allIds
TRUEFALSE
yes
Evaluation Count:1223
yes
Evaluation Count:1442
evaluated: entry.id == id
TRUEFALSE
yes
Evaluation Count:1396
yes
Evaluation Count:46
46-1442
117 && (allKeys || entry.keyseq == key)) {
partially evaluated: allKeys
TRUEFALSE
yes
Evaluation Count:2619
no
Evaluation Count:0
never evaluated: entry.keyseq == key
0-2619
118 d->sequences.removeAt(i); -
119 ++itemsRemoved; -
120 }
executed: }
Execution Count:2619
2619
121 if (id == entryId)
evaluated: id == entryId
TRUEFALSE
yes
Evaluation Count:1396
yes
Evaluation Count:12663
1396-12663
122 return itemsRemoved;
executed: return itemsRemoved;
Execution Count:1396
1396
123 --i; -
124 }
executed: }
Execution Count:12663
12663
125 -
126 -
127 -
128 -
129 -
130 return itemsRemoved;
executed: return itemsRemoved;
Execution Count:1480
1480
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)
partially evaluated: i>=0
TRUEFALSE
yes
Evaluation Count:724
no
Evaluation Count:0
0-724
142 { -
143 QShortcutEntry entry = d->sequences.at(i); -
144 if ((allOwners || entry.owner == owner)
partially evaluated: allOwners
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:724
evaluated: entry.owner == owner
TRUEFALSE
yes
Evaluation Count:598
yes
Evaluation Count:126
0-724
145 && (allIds || entry.id == id)
partially evaluated: allIds
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:598
partially evaluated: entry.id == id
TRUEFALSE
yes
Evaluation Count:598
no
Evaluation Count:0
0-598
146 && (allKeys || entry.keyseq == key)) {
partially evaluated: allKeys
TRUEFALSE
yes
Evaluation Count:598
no
Evaluation Count:0
never evaluated: entry.keyseq == key
0-598
147 d->sequences[i].enabled = enable; -
148 ++itemsChanged; -
149 }
executed: }
Execution Count:598
598
150 if (id == entry.id)
evaluated: id == entry.id
TRUEFALSE
yes
Evaluation Count:598
yes
Evaluation Count:126
126-598
151 return itemsChanged;
executed: return itemsChanged;
Execution Count:598
598
152 --i; -
153 }
executed: }
Execution Count:126
126
154 -
155 -
156 -
157 -
158 -
159 return 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)
partially evaluated: i>=0
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
171 { -
172 QShortcutEntry entry = d->sequences.at(i); -
173 if ((allOwners || entry.owner == owner)
partially evaluated: allOwners
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
partially evaluated: entry.owner == owner
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
174 && (allIds || entry.id == id)
partially evaluated: allIds
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
evaluated: entry.id == id
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
0-3
175 && (allKeys || entry.keyseq == key)) {
partially evaluated: allKeys
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
never evaluated: entry.keyseq == key
0-2
176 d->sequences[i].autorepeat = on; -
177 ++itemsChanged; -
178 }
executed: }
Execution Count:2
2
179 if (id == entry.id)
evaluated: id == entry.id
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
180 return itemsChanged;
executed: return itemsChanged;
Execution Count:2
2
181 --i; -
182 }
executed: }
Execution Count:1
1
183 -
184 -
185 -
186 -
187 -
188 return 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}
executed: }
Execution Count:404
404
200 -
201 -
202 -
203 -
204QKeySequence::SequenceMatch QShortcutMap::state() -
205{ -
206 QShortcutMapPrivate * const d = d_func(); -
207 return d->currentState;
never executed: return d->currentState;
0
208} -
209 -
210 -
211 -
212 -
213 -
214 -
215 -
216bool QShortcutMap::tryShortcutEvent(QObject *o, QKeyEvent *e) -
217{ -
218 QShortcutMapPrivate * const d = d_func(); -
219 -
220 bool wasAccepted = e->isAccepted(); -
221 bool wasSpontaneous = e->spont; -
222 if (d->currentState == QKeySequence::NoMatch) {
evaluated: d->currentState == QKeySequence::NoMatch
TRUEFALSE
yes
Evaluation Count:5525
yes
Evaluation Count:5
5-5525
223 ushort orgType = e->t; -
224 e->t = QEvent::ShortcutOverride; -
225 e->ignore(); -
226 QCoreApplication::sendEvent(o, e); -
227 e->t = orgType; -
228 e->spont = wasSpontaneous; -
229 if (e->isAccepted()) {
evaluated: e->isAccepted()
TRUEFALSE
yes
Evaluation Count:2373
yes
Evaluation Count:3152
2373-3152
230 if (!wasAccepted)
partially evaluated: !wasAccepted
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2373
0-2373
231 e->ignore();
never executed: e->ignore();
0
232 return false;
executed: return false;
Execution Count:2373
2373
233 } -
234 }
executed: }
Execution Count:3152
3152
235 -
236 QKeySequence::SequenceMatch result = nextState(e); -
237 bool stateWasAccepted = e->isAccepted(); -
238 if (wasAccepted)
partially evaluated: wasAccepted
TRUEFALSE
yes
Evaluation Count:3157
no
Evaluation Count:0
0-3157
239 e->accept();
executed: e->accept();
Execution Count:3157
3157
240 else -
241 e->ignore();
never executed: e->ignore();
0
242 -
243 int identicalMatches = d->identicals.count(); -
244 -
245 switch(result) { -
246 case QKeySequence::NoMatch: -
247 return stateWasAccepted;
executed: return stateWasAccepted;
Execution Count:3037
3037
248 case QKeySequence::ExactMatch: -
249 resetState(); -
250 dispatchEvent(e); -
251 default: -
252 break;
executed: break;
Execution Count:120
120
253 } -
254 -
255 -
256 return identicalMatches > 0 || result == QKeySequence::PartialMatch;
executed: return identicalMatches > 0 || result == QKeySequence::PartialMatch;
Execution Count:120
120
257} -
258 -
259 -
260 -
261 -
262 -
263 -
264 -
265QKeySequence::SequenceMatch QShortcutMap::nextState(QKeyEvent *e) -
266{ -
267 QShortcutMapPrivate * const d = d_func(); -
268 -
269 if (e->key() >= Qt::Key_Shift &&
evaluated: e->key() >= Qt::Key_Shift
TRUEFALSE
yes
Evaluation Count:248
yes
Evaluation Count:2909
248-2909
270 e->key() <= Qt::Key_Alt)
evaluated: e->key() <= Qt::Key_Alt
TRUEFALSE
yes
Evaluation Count:229
yes
Evaluation Count:19
19-229
271 return d->currentState;
executed: return d->currentState;
Execution Count:229
229
272 -
273 QKeySequence::SequenceMatch result = QKeySequence::NoMatch; -
274 -
275 -
276 d->identicals.resize(0); -
277 -
278 result = find(e); -
279 if (result == QKeySequence::NoMatch && (e->modifiers() & Qt::KeypadModifier)) {
evaluated: result == QKeySequence::NoMatch
TRUEFALSE
yes
Evaluation Count:2810
yes
Evaluation Count:118
evaluated: (e->modifiers() & Qt::KeypadModifier)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2807
3-2810
280 -
281 QKeyEvent event = *e; -
282 event.setModifiers(e->modifiers() & ~Qt::KeypadModifier); -
283 result = find(&event); -
284 }
executed: }
Execution Count:3
3
285 if (result == QKeySequence::NoMatch && e->modifiers() & Qt::ShiftModifier) {
evaluated: result == QKeySequence::NoMatch
TRUEFALSE
yes
Evaluation Count:2809
yes
Evaluation Count:119
evaluated: e->modifiers() & Qt::ShiftModifier
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:2784
25-2809
286 -
287 if (e->key() == Qt::Key_Backtab) {
evaluated: e->key() == Qt::Key_Backtab
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:22
3-22
288 QKeyEvent pe = QKeyEvent(e->type(), Qt::Key_Tab, e->modifiers(), e->text()); -
289 result = find(&pe); -
290 }
executed: }
Execution Count:3
3
291 }
executed: }
Execution Count:25
25
292 -
293 -
294 if (d->currentState == QKeySequence::PartialMatch
evaluated: d->currentState == QKeySequence::PartialMatch
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2923
5-2923
295 || (d->currentState == QKeySequence::ExactMatch && d->identicals.count()))
partially evaluated: d->currentState == QKeySequence::ExactMatch
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2923
never evaluated: d->identicals.count()
0-2923
296 e->accept();
executed: e->accept();
Execution Count:5
5
297 -
298 if (result == QKeySequence::NoMatch)
evaluated: result == QKeySequence::NoMatch
TRUEFALSE
yes
Evaluation Count:2808
yes
Evaluation Count:120
120-2808
299 clearSequence(d->currentSequences);
executed: clearSequence(d->currentSequences);
Execution Count:2808
2808
300 d->currentState = result; -
301 -
302 -
303 -
304 -
305 return result;
executed: return result;
Execution Count:2928
2928
306} -
307 -
308 -
309 -
310 -
311 -
312bool QShortcutMap::hasShortcutForKeySequence(const QKeySequence &seq) const -
313{ -
314 const QShortcutMapPrivate * const d = d_func(); -
315 QShortcutEntry entry(seq); -
316 QList<QShortcutEntry>::ConstIterator itEnd = d->sequences.constEnd(); -
317 QList<QShortcutEntry>::ConstIterator it = std::lower_bound(d->sequences.constBegin(), itEnd, entry); -
318 -
319 for (;it != itEnd; ++it) {
partially evaluated: it != itEnd
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
320 if (matches(entry.keyseq, (*it).keyseq) == QKeySequence::ExactMatch && (*it).correctContext() && (*it).enabled) {
never evaluated: matches(entry.keyseq, (*it).keyseq) == QKeySequence::ExactMatch
never evaluated: (*it).correctContext()
never evaluated: (*it).enabled
0
321 return true;
never executed: return true;
0
322 } -
323 }
never executed: }
0
324 -
325 -
326 return false;
executed: return false;
Execution Count:14
14
327} -
328QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e) -
329{ -
330 QShortcutMapPrivate * const d = d_func(); -
331 if (!d->sequences.count())
evaluated: !d->sequences.count()
TRUEFALSE
yes
Evaluation Count:2698
yes
Evaluation Count:236
236-2698
332 return QKeySequence::NoMatch;
executed: return QKeySequence::NoMatch;
Execution Count:2698
2698
333 -
334 createNewSequences(e, d->newEntries); -
335 -
336 -
337 -
338 -
339 -
340 if (d->newEntries == d->currentSequences) {
partially evaluated: d->newEntries == d->currentSequences
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:236
0-236
341 qt_noop(); -
342 -
343 return QKeySequence::NoMatch;
never executed: return QKeySequence::NoMatch;
0
344 } -
345 -
346 -
347 d->identicals.resize(0); -
348 -
349 bool partialFound = false; -
350 bool identicalDisabledFound = false; -
351 QVector<QKeySequence> okEntries; -
352 int result = QKeySequence::NoMatch; -
353 for (int i = d->newEntries.count()-1; i >= 0 ; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:236
yes
Evaluation Count:236
236
354 QShortcutEntry entry(d->newEntries.at(i)); -
355 QList<QShortcutEntry>::ConstIterator itEnd = d->sequences.constEnd(); -
356 QList<QShortcutEntry>::ConstIterator it = -
357 std::lower_bound(d->sequences.constBegin(), itEnd, entry); -
358 -
359 int oneKSResult = QKeySequence::NoMatch; -
360 int tempRes = QKeySequence::NoMatch; -
361 do { -
362 if (it == itEnd)
evaluated: it == itEnd
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:377
78-377
363 break;
executed: break;
Execution Count:78
78
364 tempRes = matches(entry.keyseq, (*it).keyseq); -
365 oneKSResult = qMax(oneKSResult, tempRes); -
366 if (tempRes != QKeySequence::NoMatch && (*it).correctContext()) {
evaluated: tempRes != QKeySequence::NoMatch
TRUEFALSE
yes
Evaluation Count:219
yes
Evaluation Count:158
evaluated: (*it).correctContext()
TRUEFALSE
yes
Evaluation Count:217
yes
Evaluation Count:2
2-219
367 if (tempRes == QKeySequence::ExactMatch) {
evaluated: tempRes == QKeySequence::ExactMatch
TRUEFALSE
yes
Evaluation Count:209
yes
Evaluation Count:8
8-209
368 if ((*it).enabled)
evaluated: (*it).enabled
TRUEFALSE
yes
Evaluation Count:154
yes
Evaluation Count:55
55-154
369 d->identicals.append(&*it);
executed: d->identicals.append(&*it);
Execution Count:154
154
370 else -
371 identicalDisabledFound = true;
executed: identicalDisabledFound = true;
Execution Count:55
55
372 } else if (tempRes == QKeySequence::PartialMatch) {
partially evaluated: tempRes == QKeySequence::PartialMatch
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
373 -
374 if (d->identicals.size())
partially evaluated: d->identicals.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
375 break;
never executed: break;
0
376 -
377 -
378 partialFound |= (*it).enabled; -
379 }
executed: }
Execution Count:8
8
380 } -
381 ++it; -
382 -
383 -
384 -
385 } while (tempRes != QKeySequence::NoMatch);
evaluated: tempRes != QKeySequence::NoMatch
TRUEFALSE
yes
Evaluation Count:219
yes
Evaluation Count:158
executed: }
Execution Count:377
158-377
386 -
387 -
388 -
389 if (oneKSResult > result) {
evaluated: oneKSResult > result
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:114
114-122
390 okEntries.clear(); -
391 -
392 -
393 -
394 }
executed: }
Execution Count:122
122
395 if (oneKSResult && oneKSResult >= result) {
evaluated: oneKSResult
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:114
partially evaluated: oneKSResult >= result
TRUEFALSE
yes
Evaluation Count:122
no
Evaluation Count:0
0-122
396 okEntries << d->newEntries.at(i); -
397 -
398 -
399 -
400 }
executed: }
Execution Count:122
122
401 }
executed: }
Execution Count:236
236
402 -
403 if (d->identicals.size()) {
evaluated: d->identicals.size()
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:124
112-124
404 result = QKeySequence::ExactMatch; -
405 } else if (partialFound) {
evaluated: partialFound
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:119
executed: }
Execution Count:112
5-119
406 result = QKeySequence::PartialMatch; -
407 } else if (identicalDisabledFound) {
evaluated: identicalDisabledFound
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:116
executed: }
Execution Count:5
3-116
408 result = QKeySequence::ExactMatch; -
409 } else {
executed: }
Execution Count:3
3
410 clearSequence(d->currentSequences); -
411 result = QKeySequence::NoMatch; -
412 }
executed: }
Execution Count:116
116
413 if (result != QKeySequence::NoMatch)
evaluated: result != QKeySequence::NoMatch
TRUEFALSE
yes
Evaluation Count:120
yes
Evaluation Count:116
116-120
414 d->currentSequences = okEntries;
executed: d->currentSequences = okEntries;
Execution Count:120
120
415 -
416 -
417 -
418 return QKeySequence::SequenceMatch(result);
executed: return QKeySequence::SequenceMatch(result);
Execution Count:236
236
419} -
420 -
421 -
422 -
423 -
424 -
425 -
426void QShortcutMap::clearSequence(QVector<QKeySequence> &ksl) -
427{ -
428 ksl.clear(); -
429 d_func()->newEntries.clear(); -
430}
executed: }
Execution Count:3328
3328
431 -
432 -
433 -
434 -
435 -
436void QShortcutMap::createNewSequences(QKeyEvent *e, QVector<QKeySequence> &ksl) -
437{ -
438 QShortcutMapPrivate * const d = d_func(); -
439 QList<int> possibleKeys = QKeyMapper::possibleKeys(e); -
440 int pkTotal = possibleKeys.count(); -
441 if (!pkTotal)
partially evaluated: !pkTotal
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:236
0-236
442 return;
never executed: return;
0
443 -
444 int ssActual = d->currentSequences.count(); -
445 int ssTotal = qMax(1, ssActual); -
446 -
447 ksl.resize(pkTotal * ssTotal); -
448 -
449 int index = ssActual ? d->currentSequences.at(0).count() : 0;
evaluated: ssActual
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:231
5-231
450 for (int pkNum = 0; pkNum < pkTotal; ++pkNum) {
evaluated: pkNum < pkTotal
TRUEFALSE
yes
Evaluation Count:236
yes
Evaluation Count:236
236
451 for (int ssNum = 0; ssNum < ssTotal; ++ssNum) {
evaluated: ssNum < ssTotal
TRUEFALSE
yes
Evaluation Count:236
yes
Evaluation Count:236
236
452 int i = (pkNum * ssTotal) + ssNum; -
453 QKeySequence &curKsl = ksl[i]; -
454 if (ssActual) {
evaluated: ssActual
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:231
5-231
455 const QKeySequence &curSeq = d->currentSequences.at(ssNum); -
456 curKsl.setKey(curSeq[0], 0); -
457 curKsl.setKey(curSeq[1], 1); -
458 curKsl.setKey(curSeq[2], 2); -
459 curKsl.setKey(curSeq[3], 3); -
460 } else {
executed: }
Execution Count:5
5
461 curKsl.setKey(0, 0); -
462 curKsl.setKey(0, 1); -
463 curKsl.setKey(0, 2); -
464 curKsl.setKey(0, 3); -
465 }
executed: }
Execution Count:231
231
466 curKsl.setKey(possibleKeys.at(pkNum), index); -
467 }
executed: }
Execution Count:236
236
468 }
executed: }
Execution Count:236
236
469}
executed: }
Execution Count:236
236
470 -
471 -
472 -
473 -
474 -
475 -
476QKeySequence::SequenceMatch QShortcutMap::matches(const QKeySequence &seq1, -
477 const QKeySequence &seq2) const -
478{ -
479 uint userN = seq1.count(), -
480 seqN = seq2.count(); -
481 -
482 if (userN > seqN)
evaluated: userN > seqN
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:375
2-375
483 return QKeySequence::NoMatch;
executed: return QKeySequence::NoMatch;
Execution Count:2
2
484 -
485 -
486 -
487 QKeySequence::SequenceMatch match = (userN == seqN
evaluated: userN == seqN
TRUEFALSE
yes
Evaluation Count:365
yes
Evaluation Count:10
10-365
488 ? QKeySequence::ExactMatch -
489 : QKeySequence::PartialMatch); -
490 -
491 for (uint i = 0; i < userN; ++i) {
evaluated: i < userN
TRUEFALSE
yes
Evaluation Count:379
yes
Evaluation Count:219
219-379
492 int userKey = seq1[i], -
493 sequenceKey = seq2[i]; -
494 if ((userKey & Qt::Key_unknown) == Qt::Key_hyphen)
partially evaluated: (userKey & Qt::Key_unknown) == Qt::Key_hyphen
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:379
0-379
495 userKey = (userKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
never executed: userKey = (userKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
0
496 if ((sequenceKey & Qt::Key_unknown) == Qt::Key_hyphen)
partially evaluated: (sequenceKey & Qt::Key_unknown) == Qt::Key_hyphen
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:379
0-379
497 sequenceKey = (sequenceKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
never executed: sequenceKey = (sequenceKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
0
498 if (userKey != sequenceKey)
evaluated: userKey != sequenceKey
TRUEFALSE
yes
Evaluation Count:156
yes
Evaluation Count:223
156-223
499 return QKeySequence::NoMatch;
executed: return QKeySequence::NoMatch;
Execution Count:156
156
500 }
executed: }
Execution Count:223
223
501 return match;
executed: return match;
Execution Count:219
219
502} -
503 -
504 -
505 -
506 -
507 -
508int QShortcutMap::translateModifiers(Qt::KeyboardModifiers modifiers) -
509{ -
510 int result = 0; -
511 if (modifiers & Qt::ShiftModifier)
never evaluated: modifiers & Qt::ShiftModifier
0
512 result |= Qt::SHIFT;
never executed: result |= Qt::SHIFT;
0
513 if (modifiers & Qt::ControlModifier)
never evaluated: modifiers & Qt::ControlModifier
0
514 result |= Qt::CTRL;
never executed: result |= Qt::CTRL;
0
515 if (modifiers & Qt::MetaModifier)
never evaluated: modifiers & Qt::MetaModifier
0
516 result |= Qt::META;
never executed: result |= Qt::META;
0
517 if (modifiers & Qt::AltModifier)
never evaluated: modifiers & Qt::AltModifier
0
518 result |= Qt::ALT;
never executed: result |= Qt::ALT;
0
519 return result;
never executed: return result;
0
520} -
521 -
522 -
523 -
524 -
525QVector<const QShortcutEntry*> QShortcutMap::matches() const -
526{ -
527 const QShortcutMapPrivate * const d = d_func(); -
528 return d->identicals;
never executed: return d->identicals;
0
529} -
530 -
531 -
532 -
533 -
534void QShortcutMap::dispatchEvent(QKeyEvent *e) -
535{ -
536 QShortcutMapPrivate * const d = d_func(); -
537 if (!d->identicals.size())
evaluated: !d->identicals.size()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:112
3-112
538 return;
executed: return;
Execution Count:3
3
539 -
540 const QKeySequence &curKey = d->identicals.at(0)->keyseq; -
541 if (d->prevSequence != curKey) {
evaluated: d->prevSequence != curKey
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:26
26-86
542 d->ambigCount = 0; -
543 d->prevSequence = curKey; -
544 }
executed: }
Execution Count:86
86
545 -
546 const QShortcutEntry *current = 0, *next = 0; -
547 int i = 0, enabledShortcuts = 0; -
548 while(i < d->identicals.size()) {
evaluated: i < d->identicals.size()
TRUEFALSE
yes
Evaluation Count:146
yes
Evaluation Count:97
97-146
549 current = d->identicals.at(i); -
550 if (current->enabled || !next){
partially evaluated: current->enabled
TRUEFALSE
yes
Evaluation Count:146
no
Evaluation Count:0
never evaluated: !next
0-146
551 ++enabledShortcuts; -
552 if (enabledShortcuts > d->ambigCount + 1)
evaluated: enabledShortcuts > d->ambigCount + 1
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:131
15-131
553 break;
executed: break;
Execution Count:15
15
554 next = current; -
555 }
executed: }
Execution Count:131
131
556 ++i; -
557 }
executed: }
Execution Count:131
131
558 d->ambigCount = (d->identicals.size() == i ? 0 : d->ambigCount + 1);
evaluated: d->identicals.size() == i
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:15
15-97
559 -
560 -
561 if (!next || (e->isAutoRepeat() && !next->autorepeat))
partially evaluated: !next
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:112
partially evaluated: e->isAutoRepeat()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:112
never evaluated: !next->autorepeat
0-112
562 return;
never executed: return;
0
563 -
564 -
565 -
566 -
567 -
568 -
569 -
570 QShortcutEvent se(next->keyseq, next->id, enabledShortcuts>1); -
571 QCoreApplication::sendEvent(const_cast<QObject *>(next->owner), &se); -
572}
executed: }
Execution Count:112
112
573 -
574 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial