util/qcompleter.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7QCompletionModel::QCompletionModel(QCompleterPrivate *c, QObject *parent) -
8 : QAbstractProxyModel(*new QCompletionModelPrivate, parent), -
9 c(c), showAll(false) -
10{ -
11 createEngine(); -
12}
executed: }
Execution Count:375
375
13 -
14int QCompletionModel::columnCount(const QModelIndex &) const -
15{ -
16 const QCompletionModelPrivate * const d = d_func(); -
17 return d->model->columnCount();
executed: return d->model->columnCount();
Execution Count:9320
9320
18} -
19 -
20void QCompletionModel::setSourceModel(QAbstractItemModel *source) -
21{ -
22 bool hadModel = (sourceModel() != 0); -
23 -
24 if (hadModel)
evaluated: hadModel
TRUEFALSE
yes
Evaluation Count:147
yes
Evaluation Count:393
147-393
25 QObject::disconnect(sourceModel(), 0, this, 0);
executed: QObject::disconnect(sourceModel(), 0, this, 0);
Execution Count:147
147
26 -
27 QAbstractProxyModel::setSourceModel(source); -
28 -
29 if (source) {
evaluated: source
TRUEFALSE
yes
Evaluation Count:520
yes
Evaluation Count:20
20-520
30 -
31 connect(source, "2""modelReset()", this, "1""invalidate()"); -
32 connect(source, "2""destroyed()", this, "1""modelDestroyed()"); -
33 connect(source, "2""layoutChanged()", this, "1""invalidate()"); -
34 connect(source, "2""rowsInserted(QModelIndex,int,int)", this, "1""rowsInserted()"); -
35 connect(source, "2""rowsRemoved(QModelIndex,int,int)", this, "1""invalidate()"); -
36 connect(source, "2""columnsInserted(QModelIndex,int,int)", this, "1""invalidate()"); -
37 connect(source, "2""columnsRemoved(QModelIndex,int,int)", this, "1""invalidate()"); -
38 connect(source, "2""dataChanged(QModelIndex,QModelIndex)", this, "1""invalidate()"); -
39 }
executed: }
Execution Count:520
520
40 -
41 invalidate(); -
42}
executed: }
Execution Count:540
540
43 -
44void QCompletionModel::createEngine() -
45{ -
46 bool sortedEngine = false; -
47 switch (c->sorting) { -
48 case QCompleter::UnsortedModel: -
49 sortedEngine = false; -
50 break;
executed: break;
Execution Count:531
531
51 case QCompleter::CaseSensitivelySortedModel: -
52 sortedEngine = c->cs == Qt::CaseSensitive; -
53 break;
executed: break;
Execution Count:11
11
54 case QCompleter::CaseInsensitivelySortedModel: -
55 sortedEngine = c->cs == Qt::CaseInsensitive; -
56 break;
executed: break;
Execution Count:12
12
57 } -
58 -
59 if (sortedEngine)
evaluated: sortedEngine
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:542
12-542
60 engine.reset(new QSortedModelEngine(c));
executed: engine.reset(new QSortedModelEngine(c));
Execution Count:12
12
61 else -
62 engine.reset(new QUnsortedModelEngine(c));
executed: engine.reset(new QUnsortedModelEngine(c));
Execution Count:542
542
63} -
64 -
65QModelIndex QCompletionModel::mapToSource(const QModelIndex& index) const -
66{ -
67 const QCompletionModelPrivate * const d = d_func(); -
68 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:22856
45-22856
69 return engine->curParent;
executed: return engine->curParent;
Execution Count:45
45
70 -
71 int row; -
72 QModelIndex parent = engine->curParent; -
73 if (!showAll) {
evaluated: !showAll
TRUEFALSE
yes
Evaluation Count:22403
yes
Evaluation Count:453
453-22403
74 if (!engine->matchCount())
partially evaluated: !engine->matchCount()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22403
0-22403
75 return QModelIndex();
never executed: return QModelIndex();
0
76 qt_noop(); -
77 QIndexMapper& rootIndices = engine->historyMatch.indices; -
78 if (index.row() < rootIndices.count()) {
evaluated: index.row() < rootIndices.count()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:22402
1-22402
79 row = rootIndices[index.row()]; -
80 parent = QModelIndex(); -
81 } else {
executed: }
Execution Count:1
1
82 row = engine->curMatch.indices[index.row() - rootIndices.count()]; -
83 }
executed: }
Execution Count:22402
22402
84 } else { -
85 row = index.row(); -
86 }
executed: }
Execution Count:453
453
87 -
88 return d->model->index(row, index.column(), parent);
executed: return d->model->index(row, index.column(), parent);
Execution Count:22856
22856
89} -
90 -
91QModelIndex QCompletionModel::mapFromSource(const QModelIndex& idx) const -
92{ -
93 if (!idx.isValid())
partially evaluated: !idx.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:118
0-118
94 return QModelIndex();
never executed: return QModelIndex();
0
95 -
96 int row = -1; -
97 if (!showAll) {
evaluated: !showAll
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:13
13-105
98 if (!engine->matchCount())
evaluated: !engine->matchCount()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:102
3-102
99 return QModelIndex();
executed: return QModelIndex();
Execution Count:3
3
100 -
101 QIndexMapper& rootIndices = engine->historyMatch.indices; -
102 if (idx.parent().isValid()) {
evaluated: idx.parent().isValid()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:87
15-87
103 if (idx.parent() != engine->curParent)
evaluated: idx.parent() != engine->curParent
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:9
6-9
104 return QModelIndex();
executed: return QModelIndex();
Execution Count:6
6
105 } else {
executed: }
Execution Count:9
9
106 row = rootIndices.indexOf(idx.row()); -
107 if (row == -1 && engine->curParent.isValid())
evaluated: row == -1
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:1
evaluated: engine->curParent.isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:84
1-86
108 return QModelIndex();
executed: return QModelIndex();
Execution Count:2
2
109 }
executed: }
Execution Count:85
85
110 -
111 if (row == -1) {
evaluated: row == -1
TRUEFALSE
yes
Evaluation Count:93
yes
Evaluation Count:1
1-93
112 QIndexMapper& indices = engine->curMatch.indices; -
113 engine->filterOnDemand(idx.row() - indices.last()); -
114 row = indices.indexOf(idx.row()) + rootIndices.count(); -
115 }
executed: }
Execution Count:93
93
116 -
117 if (row == -1)
evaluated: row == -1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:88
6-88
118 return QModelIndex();
executed: return QModelIndex();
Execution Count:6
6
119 } else {
executed: }
Execution Count:88
88
120 if (idx.parent() != engine->curParent)
evaluated: idx.parent() != engine->curParent
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:10
3-10
121 return QModelIndex();
executed: return QModelIndex();
Execution Count:3
3
122 row = idx.row(); -
123 }
executed: }
Execution Count:10
10
124 -
125 return createIndex(row, idx.column());
executed: return createIndex(row, idx.column());
Execution Count:98
98
126} -
127 -
128bool QCompletionModel::setCurrentRow(int row) -
129{ -
130 if (row < 0 || !engine->matchCount())
evaluated: row < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:170
partially evaluated: !engine->matchCount()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:170
0-170
131 return false;
executed: return false;
Execution Count:2
2
132 -
133 if (row >= engine->matchCount())
evaluated: row >= engine->matchCount()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:156
14-156
134 engine->filterOnDemand(row + 1 - engine->matchCount());
executed: engine->filterOnDemand(row + 1 - engine->matchCount());
Execution Count:14
14
135 -
136 if (row >= engine->matchCount())
evaluated: row >= engine->matchCount()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:166
4-166
137 return false;
executed: return false;
Execution Count:4
4
138 -
139 engine->curRow = row; -
140 return true;
executed: return true;
Execution Count:166
166
141} -
142 -
143QModelIndex QCompletionModel::currentIndex(bool sourceIndex) const -
144{ -
145 if (!engine->matchCount())
evaluated: !engine->matchCount()
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:299
92-299
146 return QModelIndex();
executed: return QModelIndex();
Execution Count:92
92
147 -
148 int row = engine->curRow; -
149 if (showAll)
evaluated: showAll
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:202
97-202
150 row = engine->curMatch.indices[engine->curRow];
executed: row = engine->curMatch.indices[engine->curRow];
Execution Count:97
97
151 -
152 QModelIndex idx = createIndex(row, c->column); -
153 if (!sourceIndex)
evaluated: !sourceIndex
TRUEFALSE
yes
Evaluation Count:90
yes
Evaluation Count:209
90-209
154 return idx;
executed: return idx;
Execution Count:90
90
155 return mapToSource(idx);
executed: return mapToSource(idx);
Execution Count:209
209
156} -
157 -
158QModelIndex QCompletionModel::index(int row, int column, const QModelIndex& parent) const -
159{ -
160 const QCompletionModelPrivate * const d = d_func(); -
161 if (row < 0 || column < 0 || column >= columnCount(parent) || parent.isValid())
partially evaluated: row < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8898
partially evaluated: column < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8898
partially evaluated: column >= columnCount(parent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8898
partially evaluated: parent.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8898
0-8898
162 return QModelIndex();
never executed: return QModelIndex();
0
163 -
164 if (!showAll) {
evaluated: !showAll
TRUEFALSE
yes
Evaluation Count:8609
yes
Evaluation Count:289
289-8609
165 if (!engine->matchCount())
partially evaluated: !engine->matchCount()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8609
0-8609
166 return QModelIndex();
never executed: return QModelIndex();
0
167 if (row >= engine->historyMatch.indices.count()) {
partially evaluated: row >= engine->historyMatch.indices.count()
TRUEFALSE
yes
Evaluation Count:8609
no
Evaluation Count:0
0-8609
168 int want = row + 1 - engine->matchCount(); -
169 if (want > 0)
partially evaluated: want > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8609
0-8609
170 engine->filterOnDemand(want);
never executed: engine->filterOnDemand(want);
0
171 if (row >= engine->matchCount())
partially evaluated: row >= engine->matchCount()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8609
0-8609
172 return QModelIndex();
never executed: return QModelIndex();
0
173 }
executed: }
Execution Count:8609
8609
174 } else {
executed: }
Execution Count:8609
8609
175 if (row >= d->model->rowCount(engine->curParent))
partially evaluated: row >= d->model->rowCount(engine->curParent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:289
0-289
176 return QModelIndex();
never executed: return QModelIndex();
0
177 }
executed: }
Execution Count:289
289
178 -
179 return createIndex(row, column);
executed: return createIndex(row, column);
Execution Count:8898
8898
180} -
181 -
182int QCompletionModel::completionCount() const -
183{ -
184 if (!engine->matchCount())
evaluated: !engine->matchCount()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:359
11-359
185 return 0;
executed: return 0;
Execution Count:11
11
186 -
187 engine->filterOnDemand(2147483647); -
188 return engine->matchCount();
executed: return engine->matchCount();
Execution Count:359
359
189} -
190 -
191int QCompletionModel::rowCount(const QModelIndex &parent) const -
192{ -
193 const QCompletionModelPrivate * const d = d_func(); -
194 if (parent.isValid())
partially evaluated: parent.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:365
0-365
195 return 0;
never executed: return 0;
0
196 -
197 if (showAll) {
evaluated: showAll
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:337
28-337
198 -
199 if (engine->curParts.count() != 1 && !engine->matchCount()
evaluated: engine->curParts.count() != 1
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:21
evaluated: !engine->matchCount()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-21
200 && !engine->curParent.isValid())
partially evaluated: !engine->curParent.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
201 return 0;
never executed: return 0;
0
202 return d->model->rowCount(engine->curParent);
executed: return d->model->rowCount(engine->curParent);
Execution Count:28
28
203 } -
204 -
205 return completionCount();
executed: return completionCount();
Execution Count:337
337
206} -
207 -
208void QCompletionModel::setFiltered(bool filtered) -
209{ -
210 if (showAll == !filtered)
evaluated: showAll == !filtered
TRUEFALSE
yes
Evaluation Count:533
yes
Evaluation Count:15
15-533
211 return;
executed: return;
Execution Count:533
533
212 beginResetModel(); -
213 showAll = !filtered; -
214 endResetModel(); -
215}
executed: }
Execution Count:15
15
216 -
217bool QCompletionModel::hasChildren(const QModelIndex &parent) const -
218{ -
219 const QCompletionModelPrivate * const d = d_func(); -
220 if (parent.isValid())
partially evaluated: parent.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22
0-22
221 return false;
never executed: return false;
0
222 -
223 if (showAll)
evaluated: showAll
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:12
10-12
224 return d->model->hasChildren(mapToSource(parent));
executed: return d->model->hasChildren(mapToSource(parent));
Execution Count:10
10
225 -
226 if (!engine->matchCount())
evaluated: !engine->matchCount()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:8
4-8
227 return false;
executed: return false;
Execution Count:4
4
228 -
229 return true;
executed: return true;
Execution Count:8
8
230} -
231 -
232QVariant QCompletionModel::data(const QModelIndex& index, int role) const -
233{ -
234 const QCompletionModelPrivate * const d = d_func(); -
235 return d->model->data(mapToSource(index), role);
executed: return d->model->data(mapToSource(index), role);
Execution Count:22280
22280
236} -
237 -
238void QCompletionModel::modelDestroyed() -
239{ -
240 QAbstractProxyModel::setSourceModel(0); -
241 invalidate(); -
242}
executed: }
Execution Count:207
207
243 -
244void QCompletionModel::rowsInserted() -
245{ -
246 invalidate(); -
247 rowsAdded(); -
248}
executed: }
Execution Count:1742
1742
249 -
250void QCompletionModel::invalidate() -
251{ -
252 engine->cache.clear(); -
253 filter(engine->curParts); -
254}
executed: }
Execution Count:3272
3272
255 -
256void QCompletionModel::filter(const QStringList& parts) -
257{ -
258 QCompletionModelPrivate * const d = d_func(); -
259 beginResetModel(); -
260 engine->filter(parts); -
261 endResetModel(); -
262 -
263 if (d->model->canFetchMore(engine->curParent))
evaluated: d->model->canFetchMore(engine->curParent)
TRUEFALSE
yes
Evaluation Count:2186
yes
Evaluation Count:1711
1711-2186
264 d->model->fetchMore(engine->curParent);
executed: d->model->fetchMore(engine->curParent);
Execution Count:2186
2186
265}
executed: }
Execution Count:3897
3897
266 -
267 -
268void QCompletionEngine::filter(const QStringList& parts) -
269{ -
270 const QAbstractItemModel *model = c->proxy->sourceModel(); -
271 curParts = parts; -
272 if (curParts.isEmpty())
evaluated: curParts.isEmpty()
TRUEFALSE
yes
Evaluation Count:554
yes
Evaluation Count:3343
554-3343
273 curParts.append(QString());
executed: curParts.append(QString());
Execution Count:554
554
274 -
275 curRow = -1; -
276 curParent = QModelIndex(); -
277 curMatch = QMatchData(); -
278 historyMatch = filterHistory(); -
279 -
280 if (!model)
evaluated: !model
TRUEFALSE
yes
Evaluation Count:246
yes
Evaluation Count:3651
246-3651
281 return;
executed: return;
Execution Count:246
246
282 -
283 QModelIndex parent; -
284 for (int i = 0; i < curParts.count() - 1; i++) {
evaluated: i < curParts.count() - 1
TRUEFALSE
yes
Evaluation Count:3312
yes
Evaluation Count:3600
3312-3600
285 QString part = curParts[i]; -
286 int emi = filter(part, parent, -1).exactMatchIndex; -
287 if (emi == -1)
evaluated: emi == -1
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:3261
51-3261
288 return;
executed: return;
Execution Count:51
51
289 parent = model->index(emi, c->column, parent); -
290 }
executed: }
Execution Count:3261
3261
291 -
292 -
293 -
294 curParent = parent; -
295 if (curParts.last().isEmpty())
evaluated: curParts.last().isEmpty()
TRUEFALSE
yes
Evaluation Count:3307
yes
Evaluation Count:293
293-3307
296 curMatch = QMatchData(QIndexMapper(0, model->rowCount(curParent) - 1), -1, false);
executed: curMatch = QMatchData(QIndexMapper(0, model->rowCount(curParent) - 1), -1, false);
Execution Count:3307
3307
297 else -
298 curMatch = filter(curParts.last(), curParent, 1);
executed: curMatch = filter(curParts.last(), curParent, 1);
Execution Count:293
293
299 curRow = curMatch.isValid() ? 0 : -1;
evaluated: curMatch.isValid()
TRUEFALSE
yes
Evaluation Count:2780
yes
Evaluation Count:820
820-2780
300}
executed: }
Execution Count:3600
3600
301 -
302QMatchData QCompletionEngine::filterHistory() -
303{ -
304 QAbstractItemModel *source = c->proxy->sourceModel(); -
305 if (curParts.count() <= 1 || c->proxy->showAll || !source)
evaluated: curParts.count() <= 1
TRUEFALSE
yes
Evaluation Count:2993
yes
Evaluation Count:904
evaluated: c->proxy->showAll
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:847
evaluated: !source
TRUEFALSE
yes
Evaluation Count:189
yes
Evaluation Count:658
57-2993
306 return QMatchData();
executed: return QMatchData();
Execution Count:3239
3239
307 -
308 -
309 const bool isDirModel = (qobject_cast<QDirModel *>(source) != 0); -
310 -
311 -
312 -
313 (void)isDirModel; -
314 -
315 const bool isFsModel = (qobject_cast<QFileSystemModel *>(source) != 0); -
316 -
317 -
318 -
319 (void)isFsModel; -
320 QVector<int> v; -
321 QIndexMapper im(v); -
322 QMatchData m(im, -1, true); -
323 -
324 for (int i = 0; i < source->rowCount(); i++) {
evaluated: i < source->rowCount()
TRUEFALSE
yes
Evaluation Count:1141
yes
Evaluation Count:658
658-1141
325 QString str = source->index(i, c->column).data().toString(); -
326 if (str.startsWith(c->prefix, c->cs)
evaluated: str.startsWith(c->prefix, c->cs)
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:1109
32-1109
327 -
328 && ((!isFsModel && !isDirModel) || QDir::toNativeSeparators(str) != QDir::separator())
evaluated: !isFsModel
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:30
partially evaluated: !isDirModel
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: QDir::toNativeSeparators(str) != QDir::separator()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
329 -
330 ) -
331 m.indices.append(i);
executed: m.indices.append(i);
Execution Count:2
2
332 }
executed: }
Execution Count:1141
1141
333 return m;
executed: return m;
Execution Count:658
658
334} -
335 -
336 -
337bool QCompletionEngine::matchHint(QString part, const QModelIndex& parent, QMatchData *hint) -
338{ -
339 if (c->cs == Qt::CaseInsensitive)
evaluated: c->cs == Qt::CaseInsensitive
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:2900
72-2900
340 part = part.toLower();
executed: part = part.toLower();
Execution Count:72
72
341 -
342 const CacheItem& map = cache[parent]; -
343 -
344 QString key = part; -
345 while (!key.isEmpty()) {
evaluated: !key.isEmpty()
TRUEFALSE
yes
Evaluation Count:17001
yes
Evaluation Count:2919
2919-17001
346 key.chop(1); -
347 if (map.contains(key)) {
evaluated: map.contains(key)
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:16948
53-16948
348 *hint = map[key]; -
349 return true;
executed: return true;
Execution Count:53
53
350 } -
351 }
executed: }
Execution Count:16948
16948
352 -
353 return false;
executed: return false;
Execution Count:2919
2919
354} -
355 -
356bool QCompletionEngine::lookupCache(QString part, const QModelIndex& parent, QMatchData *m) -
357{ -
358 if (c->cs == Qt::CaseInsensitive)
evaluated: c->cs == Qt::CaseInsensitive
TRUEFALSE
yes
Evaluation Count:217
yes
Evaluation Count:3388
217-3388
359 part = part.toLower();
executed: part = part.toLower();
Execution Count:217
217
360 const CacheItem& map = cache[parent]; -
361 if (!map.contains(part))
evaluated: !map.contains(part)
TRUEFALSE
yes
Evaluation Count:2972
yes
Evaluation Count:633
633-2972
362 return false;
executed: return false;
Execution Count:2972
2972
363 *m = map[part]; -
364 return true;
executed: return true;
Execution Count:633
633
365} -
366 -
367 -
368void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, const QMatchData& m) -
369{ -
370 QMatchData old = cache[parent].take(part); -
371 cost = cost + m.indices.cost() - old.indices.cost(); -
372 if (cost * sizeof(int) > 1024 * 1024) {
partially evaluated: cost * sizeof(int) > 1024 * 1024
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3523
0-3523
373 QMap<QModelIndex, CacheItem>::iterator it1 = cache.begin(); -
374 while (it1 != cache.end()) {
never evaluated: it1 != cache.end()
0
375 CacheItem& ci = it1.value(); -
376 int sz = ci.count()/2; -
377 QMap<QString, QMatchData>::iterator it2 = ci.begin(); -
378 int i = 0; -
379 while (it2 != ci.end() && i < sz) {
never evaluated: it2 != ci.end()
never evaluated: i < sz
0
380 cost -= it2.value().indices.cost(); -
381 it2 = ci.erase(it2); -
382 i++; -
383 }
never executed: }
0
384 if (ci.count() == 0) {
never evaluated: ci.count() == 0
0
385 it1 = cache.erase(it1); -
386 } else {
never executed: }
0
387 ++it1; -
388 }
never executed: }
0
389 } -
390 }
never executed: }
0
391 -
392 if (c->cs == Qt::CaseInsensitive)
evaluated: c->cs == Qt::CaseInsensitive
TRUEFALSE
yes
Evaluation Count:167
yes
Evaluation Count:3356
167-3356
393 part = part.toLower();
executed: part = part.toLower();
Execution Count:167
167
394 cache[parent][part] = m; -
395}
executed: }
Execution Count:3523
3523
396 -
397 -
398QIndexMapper QSortedModelEngine::indexHint(QString part, const QModelIndex& parent, Qt::SortOrder order) -
399{ -
400 const QAbstractItemModel *model = c->proxy->sourceModel(); -
401 -
402 if (c->cs == Qt::CaseInsensitive)
evaluated: c->cs == Qt::CaseInsensitive
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:16
11-16
403 part = part.toLower();
executed: part = part.toLower();
Execution Count:11
11
404 -
405 const CacheItem& map = cache[parent]; -
406 -
407 -
408 int to = model->rowCount(parent) - 1; -
409 int from = 0; -
410 const CacheItem::const_iterator it = map.lowerBound(part); -
411 -
412 -
413 for(CacheItem::const_iterator it1 = it; it1-- != map.constBegin();) {
evaluated: it1-- != map.constBegin()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:24
3-24
414 const QMatchData& value = it1.value(); -
415 if (value.isValid()) {
partially evaluated: value.isValid()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
416 if (order == Qt::AscendingOrder) {
partially evaluated: order == Qt::AscendingOrder
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
417 from = value.indices.last() + 1; -
418 } else {
executed: }
Execution Count:3
3
419 to = value.indices.first() - 1; -
420 }
never executed: }
0
421 break;
executed: break;
Execution Count:3
3
422 } -
423 }
never executed: }
0
424 -
425 -
426 for(CacheItem::const_iterator it2 = it; it2 != map.constEnd(); ++it2) {
evaluated: it2 != map.constEnd()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:27
4-27
427 const QMatchData& value = it2.value(); -
428 if (value.isValid() && !it2.key().startsWith(part)) {
evaluated: value.isValid()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
partially evaluated: !it2.key().startsWith(part)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
429 if (order == Qt::AscendingOrder) {
never evaluated: order == Qt::AscendingOrder
0
430 to = value.indices.first() - 1; -
431 } else {
never executed: }
0
432 from = value.indices.first() + 1; -
433 }
never executed: }
0
434 break;
never executed: break;
0
435 } -
436 }
executed: }
Execution Count:4
4
437 -
438 return QIndexMapper(from, to);
executed: return QIndexMapper(from, to);
Execution Count:27
27
439} -
440 -
441Qt::SortOrder QSortedModelEngine::sortOrder(const QModelIndex &parent) const -
442{ -
443 const QAbstractItemModel *model = c->proxy->sourceModel(); -
444 -
445 int rowCount = model->rowCount(parent); -
446 if (rowCount < 2)
evaluated: rowCount < 2
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:45
2-45
447 return Qt::AscendingOrder;
executed: return Qt::AscendingOrder;
Execution Count:2
2
448 QString first = model->data(model->index(0, c->column, parent), c->role).toString(); -
449 QString last = model->data(model->index(rowCount - 1, c->column, parent), c->role).toString(); -
450 return QString::compare(first, last, c->cs) <= 0 ? Qt::AscendingOrder : Qt::DescendingOrder;
executed: return QString::compare(first, last, c->cs) <= 0 ? Qt::AscendingOrder : Qt::DescendingOrder;
Execution Count:45
45
451} -
452 -
453QMatchData QSortedModelEngine::filter(const QString& part, const QModelIndex& parent, int) -
454{ -
455 const QAbstractItemModel *model = c->proxy->sourceModel(); -
456 -
457 QMatchData hint; -
458 if (lookupCache(part, parent, &hint))
evaluated: lookupCache(part, parent, &hint)
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:47
47-111
459 return hint;
executed: return hint;
Execution Count:111
111
460 -
461 QIndexMapper indices; -
462 Qt::SortOrder order = sortOrder(parent); -
463 -
464 if (matchHint(part, parent, &hint)) {
evaluated: matchHint(part, parent, &hint)
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:27
20-27
465 if (!hint.isValid())
partially evaluated: !hint.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
466 return QMatchData();
never executed: return QMatchData();
0
467 indices = hint.indices; -
468 } else {
executed: }
Execution Count:20
20
469 indices = indexHint(part, parent, order); -
470 }
executed: }
Execution Count:27
27
471 -
472 -
473 int high = indices.to() + 1; -
474 int low = indices.from() - 1; -
475 int probe; -
476 QModelIndex probeIndex; -
477 QString probeData; -
478 -
479 while (high - low > 1)
evaluated: high - low > 1
TRUEFALSE
yes
Evaluation Count:130
yes
Evaluation Count:47
47-130
480 { -
481 probe = (high + low) / 2; -
482 probeIndex = model->index(probe, c->column, parent); -
483 probeData = model->data(probeIndex, c->role).toString(); -
484 const int cmp = QString::compare(probeData, part, c->cs); -
485 if ((order == Qt::AscendingOrder && cmp >= 0)
evaluated: order == Qt::AscendingOrder
TRUEFALSE
yes
Evaluation Count:121
yes
Evaluation Count:9
evaluated: cmp >= 0
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:53
9-121
486 || (order == Qt::DescendingOrder && cmp < 0)) {
evaluated: order == Qt::DescendingOrder
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:53
evaluated: cmp < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:6
3-53
487 high = probe; -
488 } else {
executed: }
Execution Count:71
71
489 low = probe; -
490 }
executed: }
Execution Count:59
59
491 } -
492 -
493 if ((order == Qt::AscendingOrder && low == indices.to())
evaluated: order == Qt::AscendingOrder
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:2
evaluated: low == indices.to()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:35
2-45
494 || (order == Qt::DescendingOrder && high == indices.from())) {
evaluated: order == Qt::DescendingOrder
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:35
partially evaluated: high == indices.from()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-35
495 saveInCache(part, parent, QMatchData()); -
496 return QMatchData();
executed: return QMatchData();
Execution Count:10
10
497 } -
498 -
499 probeIndex = model->index(order == Qt::AscendingOrder ? low+1 : high-1, c->column, parent); -
500 probeData = model->data(probeIndex, c->role).toString(); -
501 if (!probeData.startsWith(part, c->cs)) {
partially evaluated: !probeData.startsWith(part, c->cs)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
0-37
502 saveInCache(part, parent, QMatchData()); -
503 return QMatchData();
never executed: return QMatchData();
0
504 } -
505 -
506 const bool exactMatch = QString::compare(probeData, part, c->cs) == 0; -
507 int emi = exactMatch ? (order == Qt::AscendingOrder ? low+1 : high-1) : -1;
evaluated: exactMatch
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:18
18-19
508 -
509 int from = 0; -
510 int to = 0; -
511 if (order == Qt::AscendingOrder) {
evaluated: order == Qt::AscendingOrder
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:2
2-35
512 from = low + 1; -
513 high = indices.to() + 1; -
514 low = from; -
515 } else {
executed: }
Execution Count:35
35
516 to = high - 1; -
517 low = indices.from() - 1; -
518 high = to; -
519 }
executed: }
Execution Count:2
2
520 -
521 while (high - low > 1)
evaluated: high - low > 1
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:37
37-100
522 { -
523 probe = (high + low) / 2; -
524 probeIndex = model->index(probe, c->column, parent); -
525 probeData = model->data(probeIndex, c->role).toString(); -
526 const bool startsWith = probeData.startsWith(part, c->cs); -
527 if ((order == Qt::AscendingOrder && startsWith)
evaluated: order == Qt::AscendingOrder
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:9
evaluated: startsWith
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:31
9-91
528 || (order == Qt::DescendingOrder && !startsWith)) {
evaluated: order == Qt::DescendingOrder
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:31
evaluated: !startsWith
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
3-31
529 low = probe; -
530 } else {
executed: }
Execution Count:66
66
531 high = probe; -
532 }
executed: }
Execution Count:34
34
533 } -
534 -
535 QMatchData m(order == Qt::AscendingOrder ? QIndexMapper(from, high - 1) : QIndexMapper(low+1, to), emi, false); -
536 saveInCache(part, parent, m); -
537 return m;
executed: return m;
Execution Count:37
37
538} -
539 -
540 -
541int QUnsortedModelEngine::buildIndices(const QString& str, const QModelIndex& parent, int n, -
542 const QIndexMapper& indices, QMatchData* m) -
543{ -
544 qt_noop(); -
545 qt_noop(); -
546 const QAbstractItemModel *model = c->proxy->sourceModel(); -
547 int i, count = 0; -
548 -
549 for (i = 0; i < indices.count() && count != n; ++i) {
evaluated: i < indices.count()
TRUEFALSE
yes
Evaluation Count:4185
yes
Evaluation Count:74
evaluated: count != n
TRUEFALSE
yes
Evaluation Count:4122
yes
Evaluation Count:63
63-4185
550 QModelIndex idx = model->index(indices[i], c->column, parent); -
551 QString data = model->data(idx, c->role).toString(); -
552 if (!data.startsWith(str, c->cs) || !(model->flags(idx) & Qt::ItemIsSelectable))
evaluated: !data.startsWith(str, c->cs)
TRUEFALSE
yes
Evaluation Count:1116
yes
Evaluation Count:3006
evaluated: !(model->flags(idx) & Qt::ItemIsSelectable)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3005
1-3006
553 continue;
executed: continue;
Execution Count:1117
1117
554 m->indices.append(indices[i]); -
555 ++count; -
556 if (m->exactMatchIndex == -1 && QString::compare(data, str, c->cs) == 0) {
evaluated: m->exactMatchIndex == -1
TRUEFALSE
yes
Evaluation Count:2997
yes
Evaluation Count:8
evaluated: QString::compare(data, str, c->cs) == 0
TRUEFALSE
yes
Evaluation Count:2842
yes
Evaluation Count:155
8-2997
557 m->exactMatchIndex = indices[i]; -
558 if (n == -1)
evaluated: n == -1
TRUEFALSE
yes
Evaluation Count:2823
yes
Evaluation Count:19
19-2823
559 return indices[i];
executed: return indices[i];
Execution Count:2823
2823
560 }
executed: }
Execution Count:19
19
561 }
executed: }
Execution Count:182
182
562 return indices[i-1];
executed: return indices[i-1];
Execution Count:137
137
563} -
564 -
565void QUnsortedModelEngine::filterOnDemand(int n) -
566{ -
567 qt_noop(); -
568 if (!curMatch.partial)
evaluated: !curMatch.partial
TRUEFALSE
yes
Evaluation Count:406
yes
Evaluation Count:33
33-406
569 return;
executed: return;
Execution Count:406
406
570 qt_noop(); -
571 const QAbstractItemModel *model = c->proxy->sourceModel(); -
572 int lastRow = model->rowCount(curParent) - 1; -
573 QIndexMapper im(curMatch.indices.last() + 1, lastRow); -
574 int lastIndex = buildIndices(curParts.last(), curParent, n, im, &curMatch); -
575 curMatch.partial = (lastRow != lastIndex); -
576 saveInCache(curParts.last(), curParent, curMatch); -
577}
executed: }
Execution Count:33
33
578 -
579QMatchData QUnsortedModelEngine::filter(const QString& part, const QModelIndex& parent, int n) -
580{ -
581 QMatchData hint; -
582 -
583 QVector<int> v; -
584 QIndexMapper im(v); -
585 QMatchData m(im, -1, true); -
586 -
587 const QAbstractItemModel *model = c->proxy->sourceModel(); -
588 bool foundInCache = lookupCache(part, parent, &m); -
589 -
590 if (!foundInCache) {
evaluated: !foundInCache
TRUEFALSE
yes
Evaluation Count:2925
yes
Evaluation Count:522
522-2925
591 if (matchHint(part, parent, &hint) && !hint.isValid())
evaluated: matchHint(part, parent, &hint)
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:2892
evaluated: !hint.isValid()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:29
4-2892
592 return QMatchData();
executed: return QMatchData();
Execution Count:4
4
593 }
executed: }
Execution Count:2921
2921
594 -
595 if (!foundInCache && !hint.isValid()) {
evaluated: !foundInCache
TRUEFALSE
yes
Evaluation Count:2921
yes
Evaluation Count:522
evaluated: !hint.isValid()
TRUEFALSE
yes
Evaluation Count:2892
yes
Evaluation Count:29
29-2921
596 const int lastRow = model->rowCount(parent) - 1; -
597 QIndexMapper all(0, lastRow); -
598 int lastIndex = buildIndices(part, parent, n, all, &m); -
599 m.partial = (lastIndex != lastRow); -
600 } else {
executed: }
Execution Count:2892
2892
601 if (!foundInCache) {
evaluated: !foundInCache
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:522
29-522
602 buildIndices(part, parent, 2147483647, hint.indices, &m); -
603 m.partial = hint.partial; -
604 }
executed: }
Execution Count:29
29
605 if (m.partial && ((n == -1 && m.exactMatchIndex == -1) || (m.indices.count() < n))) {
evaluated: m.partial
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:472
evaluated: n == -1
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:36
evaluated: m.exactMatchIndex == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:42
evaluated: (m.indices.count() < n)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:73
1-472
606 -
607 const int lastRow = model->rowCount(parent) - 1; -
608 QIndexMapper rest(hint.indices.last() + 1, lastRow); -
609 int want = n == -1 ? -1 : n - m.indices.count();
evaluated: n == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
610 int lastIndex = buildIndices(part, parent, want, rest, &m); -
611 m.partial = (lastRow != lastIndex); -
612 }
executed: }
Execution Count:6
6
613 }
executed: }
Execution Count:551
551
614 -
615 saveInCache(part, parent, m); -
616 return m;
executed: return m;
Execution Count:3443
3443
617} -
618 -
619 -
620QCompleterPrivate::QCompleterPrivate() -
621: widget(0), proxy(0), popup(0), cs(Qt::CaseSensitive), role(Qt::EditRole), column(0), -
622 maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true), -
623 hiddenBecauseNoMatch(false) -
624{ -
625}
executed: }
Execution Count:375
375
626 -
627void QCompleterPrivate::init(QAbstractItemModel *m) -
628{ -
629 QCompleter * const q = q_func(); -
630 proxy = new QCompletionModel(this, q); -
631 QObject::connect(proxy, "2""rowsAdded()", q, "1""_q_autoResizePopup()"); -
632 q->setModel(m); -
633 -
634 -
635 -
636 q->setCompletionMode(QCompleter::PopupCompletion); -
637 -
638}
executed: }
Execution Count:375
375
639 -
640void QCompleterPrivate::setCurrentIndex(QModelIndex index, bool select) -
641{ -
642 QCompleter * const q = q_func(); -
643 if (!q->popup())
partially evaluated: !q->popup()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
644 return;
never executed: return;
0
645 if (!select) {
evaluated: !select
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:7
2-7
646 popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); -
647 } else {
executed: }
Execution Count:2
2
648 if (!index.isValid())
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
649 popup->selectionModel()->clear();
never executed: popup->selectionModel()->clear();
0
650 else -
651 popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select 7
652 | QItemSelectionModel::Rows);
executed: popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
Execution Count:7
7
653 } -
654 index = popup->selectionModel()->currentIndex(); -
655 if (!index.isValid())
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
656 popup->scrollToTop();
never executed: popup->scrollToTop();
0
657 else -
658 popup->scrollTo(index, QAbstractItemView::PositionAtTop);
executed: popup->scrollTo(index, QAbstractItemView::PositionAtTop);
Execution Count:9
9
659} -
660 -
661void QCompleterPrivate::_q_completionSelected(const QItemSelection& selection) -
662{ -
663 QModelIndex index; -
664 if (!selection.indexes().isEmpty())
partially evaluated: !selection.indexes().isEmpty()
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
665 index = selection.indexes().first();
executed: index = selection.indexes().first();
Execution Count:11
11
666 -
667 _q_complete(index, true); -
668}
executed: }
Execution Count:11
11
669 -
670void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted) -
671{ -
672 QCompleter * const q = q_func(); -
673 QString completion; -
674 -
675 if (!index.isValid() || (!proxy->showAll && (index.row() >= proxy->engine->matchCount()))) {
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
evaluated: !proxy->showAll
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:2
evaluated: (index.row() >= proxy->engine->matchCount())
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:29
0-32
676 completion = prefix; -
677 } else {
executed: }
Execution Count:1
1
678 if (!(index.flags() & Qt::ItemIsEnabled))
evaluated: !(index.flags() & Qt::ItemIsEnabled)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:30
1-30
679 return;
executed: return;
Execution Count:1
1
680 QModelIndex si = proxy->mapToSource(index); -
681 si = si.sibling(si.row(), column); -
682 completion = q->pathFromIndex(si); -
683 -
684 -
685 if (mode == QCompleter::InlineCompletion) {
evaluated: mode == QCompleter::InlineCompletion
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:17
13-17
686 if (qobject_cast<QDirModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
partially evaluated: qobject_cast<QDirModel *>(proxy->sourceModel())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
never evaluated: QFileInfo(completion).isDir()
0-13
687 completion += QDir::separator();
never executed: completion += QDir::separator();
0
688 }
executed: }
Execution Count:13
13
689 -
690 -
691 -
692 if (mode == QCompleter::InlineCompletion) {
evaluated: mode == QCompleter::InlineCompletion
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:17
13-17
693 if (qobject_cast<QFileSystemModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
partially evaluated: qobject_cast<QFileSystemModel *>(proxy->sourceModel())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
never evaluated: QFileInfo(completion).isDir()
0-13
694 completion += QDir::separator();
never executed: completion += QDir::separator();
0
695 }
executed: }
Execution Count:13
13
696 -
697 }
executed: }
Execution Count:30
30
698 -
699 if (highlighted) {
evaluated: highlighted
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:7
7-24
700 q->highlighted(index); -
701 q->highlighted(completion); -
702 } else {
executed: }
Execution Count:24
24
703 q->activated(index); -
704 q->activated(completion); -
705 }
executed: }
Execution Count:7
7
706} -
707 -
708void QCompleterPrivate::_q_autoResizePopup() -
709{ -
710 if (!popup || !popup->isVisible())
evaluated: !popup
TRUEFALSE
yes
Evaluation Count:1731
yes
Evaluation Count:11
evaluated: !popup->isVisible()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:8
3-1731
711 return;
executed: return;
Execution Count:1734
1734
712 showPopup(popupRect); -
713}
executed: }
Execution Count:8
8
714 -
715void QCompleterPrivate::showPopup(const QRect& rect) -
716{ -
717 const QRect screen = QApplication::desktop()->availableGeometry(widget); -
718 Qt::LayoutDirection dir = widget->layoutDirection(); -
719 QPoint pos; -
720 int rh, w; -
721 int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3; -
722 QScrollBar *hsb = popup->horizontalScrollBar(); -
723 if (hsb && hsb->isVisible())
partially evaluated: hsb
TRUEFALSE
yes
Evaluation Count:61
no
Evaluation Count:0
partially evaluated: hsb->isVisible()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
724 h += popup->horizontalScrollBar()->sizeHint().height();
never executed: h += popup->horizontalScrollBar()->sizeHint().height();
0
725 -
726 if (rect.isValid()) {
partially evaluated: rect.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
727 rh = rect.height(); -
728 w = rect.width(); -
729 pos = widget->mapToGlobal(dir == Qt::RightToLeft ? rect.bottomRight() : rect.bottomLeft()); -
730 } else {
never executed: }
0
731 rh = widget->height(); -
732 pos = widget->mapToGlobal(QPoint(0, widget->height() - 2)); -
733 w = widget->width(); -
734 }
executed: }
Execution Count:61
61
735 -
736 if (w > screen.width())
partially evaluated: w > screen.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
737 w = screen.width();
never executed: w = screen.width();
0
738 if ((pos.x() + w) > (screen.x() + screen.width()))
partially evaluated: (pos.x() + w) > (screen.x() + screen.width())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
739 pos.setX(screen.x() + screen.width() - w);
never executed: pos.setX(screen.x() + screen.width() - w);
0
740 if (pos.x() < screen.x())
partially evaluated: pos.x() < screen.x()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
741 pos.setX(screen.x());
never executed: pos.setX(screen.x());
0
742 -
743 int top = pos.y() - rh - screen.top() + 2; -
744 int bottom = screen.bottom() - pos.y(); -
745 h = qMax(h, popup->minimumHeight()); -
746 if (h > bottom) {
partially evaluated: h > bottom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
747 h = qMin(qMax(top, bottom), h); -
748 -
749 if (top > bottom)
never evaluated: top > bottom
0
750 pos.setY(pos.y() - h - rh + 2);
never executed: pos.setY(pos.y() - h - rh + 2);
0
751 }
never executed: }
0
752 -
753 popup->setGeometry(pos.x(), pos.y(), w, h); -
754 -
755 if (!popup->isVisible())
evaluated: !popup->isVisible()
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:42
19-42
756 popup->show();
executed: popup->show();
Execution Count:19
19
757}
executed: }
Execution Count:61
61
758 -
759void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path) -
760{ -
761 QCompleter * const q = q_func(); -
762 -
763 -
764 -
765 if (hiddenBecauseNoMatch
evaluated: hiddenBecauseNoMatch
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:75
1-75
766 && prefix.startsWith(path) && prefix != (path + QLatin1Char('/'))
partially evaluated: prefix.startsWith(path)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: prefix != (path + QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
767 && widget) {
partially evaluated: widget
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
768 q->complete(); -
769 }
executed: }
Execution Count:1
1
770}
executed: }
Execution Count:76
76
771 -
772 -
773 -
774 -
775QCompleter::QCompleter(QObject *parent) -
776: QObject(*new QCompleterPrivate(), parent) -
777{ -
778 QCompleterPrivate * const d = d_func(); -
779 d->init(); -
780}
executed: }
Execution Count:18
18
781 -
782 -
783 -
784 -
785 -
786QCompleter::QCompleter(QAbstractItemModel *model, QObject *parent) -
787 : QObject(*new QCompleterPrivate(), parent) -
788{ -
789 QCompleterPrivate * const d = d_func(); -
790 d->init(model); -
791}
executed: }
Execution Count:348
348
792 -
793 -
794 -
795 -
796 -
797 -
798QCompleter::QCompleter(const QStringList& list, QObject *parent) -
799: QObject(*new QCompleterPrivate(), parent) -
800{ -
801 QCompleterPrivate * const d = d_func(); -
802 d->init(new QStringListModel(list, this)); -
803}
executed: }
Execution Count:9
9
804 -
805 -
806 -
807 -
808 -
809QCompleter::~QCompleter() -
810{ -
811} -
812void QCompleter::setWidget(QWidget *widget) -
813{ -
814 QCompleterPrivate * const d = d_func(); -
815 if (d->widget)
evaluated: d->widget
TRUEFALSE
yes
Evaluation Count:277
yes
Evaluation Count:357
277-357
816 d->widget->removeEventFilter(this);
executed: d->widget->removeEventFilter(this);
Execution Count:277
277
817 d->widget = widget; -
818 if (d->widget)
evaluated: d->widget
TRUEFALSE
yes
Evaluation Count:631
yes
Evaluation Count:3
3-631
819 d->widget->installEventFilter(this);
executed: d->widget->installEventFilter(this);
Execution Count:631
631
820 if (d->popup) {
evaluated: d->popup
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:619
15-619
821 d->popup->hide(); -
822 d->popup->setFocusProxy(d->widget); -
823 }
executed: }
Execution Count:15
15
824}
executed: }
Execution Count:634
634
825 -
826 -
827 -
828 -
829 -
830 -
831QWidget *QCompleter::widget() const -
832{ -
833 const QCompleterPrivate * const d = d_func(); -
834 return d->widget;
executed: return d->widget;
Execution Count:369
369
835} -
836void QCompleter::setModel(QAbstractItemModel *model) -
837{ -
838 QCompleterPrivate * const d = d_func(); -
839 QAbstractItemModel *oldModel = d->proxy->sourceModel(); -
840 d->proxy->setSourceModel(model); -
841 if (d->popup)
evaluated: d->popup
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:536
4-536
842 setPopup(d->popup);
executed: setPopup(d->popup);
Execution Count:4
4
843 if (oldModel && oldModel->QObject::parent() == this)
evaluated: oldModel
TRUEFALSE
yes
Evaluation Count:147
yes
Evaluation Count:393
evaluated: oldModel->QObject::parent() == this
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:142
5-393
844 delete oldModel;
executed: delete oldModel;
Execution Count:5
5
845 -
846 if (qobject_cast<QDirModel *>(model)) {
evaluated: qobject_cast<QDirModel *>(model)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:538
2-538
847 -
848 -
849 -
850 setCaseSensitivity(Qt::CaseSensitive); -
851 -
852 }
executed: }
Execution Count:2
2
853 -
854 -
855 QFileSystemModel *fsModel = qobject_cast<QFileSystemModel *>(model); -
856 if (fsModel) {
evaluated: fsModel
TRUEFALSE
yes
Evaluation Count:195
yes
Evaluation Count:345
195-345
857 -
858 -
859 -
860 setCaseSensitivity(Qt::CaseSensitive); -
861 -
862 setCompletionRole(QFileSystemModel::FileNameRole); -
863 connect(fsModel, "2""directoryLoaded(QString)", this, "1""_q_fileSystemModelDirectoryLoaded(QString)"); -
864 }
executed: }
Execution Count:195
195
865 -
866}
executed: }
Execution Count:540
540
867 -
868 -
869 -
870 -
871 -
872 -
873QAbstractItemModel *QCompleter::model() const -
874{ -
875 const QCompleterPrivate * const d = d_func(); -
876 return d->proxy->sourceModel();
executed: return d->proxy->sourceModel();
Execution Count:241
241
877} -
878void QCompleter::setCompletionMode(QCompleter::CompletionMode mode) -
879{ -
880 QCompleterPrivate * const d = d_func(); -
881 d->mode = mode; -
882 d->proxy->setFiltered(mode != QCompleter::UnfilteredPopupCompletion); -
883 -
884 if (mode == QCompleter::InlineCompletion) {
evaluated: mode == QCompleter::InlineCompletion
TRUEFALSE
yes
Evaluation Count:155
yes
Evaluation Count:393
155-393
885 if (d->widget)
partially evaluated: d->widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:155
0-155
886 d->widget->removeEventFilter(this);
never executed: d->widget->removeEventFilter(this);
0
887 if (d->popup) {
partially evaluated: d->popup
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:155
0-155
888 d->popup->deleteLater(); -
889 d->popup = 0; -
890 }
never executed: }
0
891 } else {
executed: }
Execution Count:155
155
892 if (d->widget)
evaluated: d->widget
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:392
1-392
893 d->widget->installEventFilter(this);
executed: d->widget->installEventFilter(this);
Execution Count:1
1
894 }
executed: }
Execution Count:393
393
895} -
896 -
897QCompleter::CompletionMode QCompleter::completionMode() const -
898{ -
899 const QCompleterPrivate * const d = d_func(); -
900 return d->mode;
executed: return d->mode;
Execution Count:332
332
901} -
902void QCompleter::setPopup(QAbstractItemView *popup) -
903{ -
904 QCompleterPrivate * const d = d_func(); -
905 qt_noop(); -
906 if (d->popup) {
evaluated: d->popup
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:22
5-22
907 QObject::disconnect(d->popup->selectionModel(), 0, this, 0); -
908 QObject::disconnect(d->popup, 0, this, 0); -
909 }
executed: }
Execution Count:5
5
910 if (d->popup != popup)
evaluated: d->popup != popup
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:4
4-23
911 delete d->popup;
executed: delete d->popup;
Execution Count:23
23
912 if (popup->model() != d->proxy)
evaluated: popup->model() != d->proxy
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:4
4-23
913 popup->setModel(d->proxy);
executed: popup->setModel(d->proxy);
Execution Count:23
23
914 popup->hide(); -
915 -
916 Qt::FocusPolicy origPolicy = Qt::NoFocus; -
917 if (d->widget)
evaluated: d->widget
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:5
5-22
918 origPolicy = d->widget->focusPolicy();
executed: origPolicy = d->widget->focusPolicy();
Execution Count:22
22
919 popup->setParent(0, Qt::Popup); -
920 popup->setFocusPolicy(Qt::NoFocus); -
921 if (d->widget)
evaluated: d->widget
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:5
5-22
922 d->widget->setFocusPolicy(origPolicy);
executed: d->widget->setFocusPolicy(origPolicy);
Execution Count:22
22
923 -
924 popup->setFocusProxy(d->widget); -
925 popup->installEventFilter(this); -
926 popup->setItemDelegate(new QCompleterItemDelegate(popup)); -
927 -
928 if (QListView *listView = qobject_cast<QListView *>(popup)) {
partially evaluated: QListView *listView = qobject_cast<QListView *>(popup)
TRUEFALSE
yes
Evaluation Count:27
no
Evaluation Count:0
0-27
929 listView->setModelColumn(d->column); -
930 }
executed: }
Execution Count:27
27
931 -
932 -
933 QObject::connect(popup, "2""clicked(QModelIndex)", -
934 this, "1""_q_complete(QModelIndex)"); -
935 QObject::connect(this, "2""activated(QModelIndex)", -
936 popup, "1""hide()"); -
937 -
938 QObject::connect(popup->selectionModel(), "2""selectionChanged(QItemSelection,QItemSelection)", -
939 this, "1""_q_completionSelected(QItemSelection)"); -
940 d->popup = popup; -
941}
executed: }
Execution Count:27
27
942 -
943 -
944 -
945 -
946 -
947 -
948QAbstractItemView *QCompleter::popup() const -
949{ -
950 const QCompleterPrivate * const d = d_func(); -
951 -
952 if (!d->popup && completionMode() != QCompleter::InlineCompletion) {
evaluated: !d->popup
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:183
evaluated: completionMode() != QCompleter::InlineCompletion
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:6
6-183
953 QListView *listView = new QListView; -
954 listView->setEditTriggers(QAbstractItemView::NoEditTriggers); -
955 listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -
956 listView->setSelectionBehavior(QAbstractItemView::SelectRows); -
957 listView->setSelectionMode(QAbstractItemView::SingleSelection); -
958 listView->setModelColumn(d->column); -
959 QCompleter *that = const_cast<QCompleter*>(this); -
960 that->setPopup(listView); -
961 }
executed: }
Execution Count:22
22
962 -
963 return d->popup;
executed: return d->popup;
Execution Count:211
211
964} -
965 -
966 -
967 -
968 -
969bool QCompleter::event(QEvent *ev) -
970{ -
971 return QObject::event(ev);
executed: return QObject::event(ev);
Execution Count:393
393
972} -
973 -
974 -
975 -
976 -
977bool QCompleter::eventFilter(QObject *o, QEvent *e) -
978{ -
979 QCompleterPrivate * const d = d_func(); -
980 -
981 if (d->eatFocusOut && o == d->widget && e->type() == QEvent::FocusOut) {
evaluated: d->eatFocusOut
TRUEFALSE
yes
Evaluation Count:3399
yes
Evaluation Count:17
evaluated: o == d->widget
TRUEFALSE
yes
Evaluation Count:2938
yes
Evaluation Count:461
evaluated: e->type() == QEvent::FocusOut
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:2861
17-3399
982 d->hiddenBecauseNoMatch = false; -
983 if (d->popup && d->popup->isVisible())
evaluated: d->popup
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:41
evaluated: d->popup->isVisible()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:14
14-41
984 return true;
executed: return true;
Execution Count:22
22
985 }
executed: }
Execution Count:55
55
986 -
987 if (o != d->popup)
evaluated: o != d->popup
TRUEFALSE
yes
Evaluation Count:2944
yes
Evaluation Count:450
450-2944
988 return QObject::eventFilter(o, e);
executed: return QObject::eventFilter(o, e);
Execution Count:2944
2944
989 -
990 switch (e->type()) { -
991 case QEvent::KeyPress: { -
992 QKeyEvent *ke = static_cast<QKeyEvent *>(e); -
993 -
994 QModelIndex curIndex = d->popup->currentIndex(); -
995 QModelIndexList selList = d->popup->selectionModel()->selectedIndexes(); -
996 -
997 const int key = ke->key(); -
998 -
999 if ((key == Qt::Key_Up || key == Qt::Key_Down) && selList.isEmpty() && curIndex.isValid()
evaluated: key == Qt::Key_Up
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:15
evaluated: key == Qt::Key_Down
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:7
evaluated: selList.isEmpty()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:3
evaluated: curIndex.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-15
1000 && d->mode == QCompleter::UnfilteredPopupCompletion) {
partially evaluated: d->mode == QCompleter::UnfilteredPopupCompletion
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1001 d->setCurrentIndex(curIndex); -
1002 return true;
executed: return true;
Execution Count:1
1
1003 } -
1004 -
1005 -
1006 -
1007 switch (key) { -
1008 case Qt::Key_End: -
1009 case Qt::Key_Home: -
1010 if (ke->modifiers() & Qt::ControlModifier)
never evaluated: ke->modifiers() & Qt::ControlModifier
0
1011 return false;
never executed: return false;
0
1012 break;
never executed: break;
0
1013 -
1014 case Qt::Key_Up: -
1015 if (!curIndex.isValid()) {
evaluated: !curIndex.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1016 int rowCount = d->proxy->rowCount(); -
1017 QModelIndex lastIndex = d->proxy->index(rowCount - 1, d->column); -
1018 d->setCurrentIndex(lastIndex); -
1019 return true;
executed: return true;
Execution Count:1
1
1020 } else if (curIndex.row() == 0) {
partially evaluated: curIndex.row() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1021 if (d->wrap)
never evaluated: d->wrap
0
1022 d->setCurrentIndex(QModelIndex());
never executed: d->setCurrentIndex(QModelIndex());
0
1023 return true;
never executed: return true;
0
1024 } -
1025 return false;
executed: return false;
Execution Count:1
1
1026 -
1027 case Qt::Key_Down: -
1028 if (!curIndex.isValid()) {
evaluated: !curIndex.isValid()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
2-5
1029 QModelIndex firstIndex = d->proxy->index(0, d->column); -
1030 d->setCurrentIndex(firstIndex); -
1031 return true;
executed: return true;
Execution Count:5
5
1032 } else if (curIndex.row() == d->proxy->rowCount() - 1) {
partially evaluated: curIndex.row() == d->proxy->rowCount() - 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1033 if (d->wrap)
never evaluated: d->wrap
0
1034 d->setCurrentIndex(QModelIndex());
never executed: d->setCurrentIndex(QModelIndex());
0
1035 return true;
never executed: return true;
0
1036 } -
1037 return false;
executed: return false;
Execution Count:2
2
1038 -
1039 case Qt::Key_PageUp: -
1040 case Qt::Key_PageDown: -
1041 return false;
never executed: return false;
0
1042 } -
1043 -
1044 -
1045 -
1046 d->eatFocusOut = false; -
1047 (static_cast<QObject *>(d->widget))->event(ke); -
1048 d->eatFocusOut = true; -
1049 if (!d->widget || e->isAccepted() || !d->popup->isVisible()) {
partially evaluated: !d->widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
partially evaluated: e->isAccepted()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
evaluated: !d->popup->isVisible()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
0-7
1050 -
1051 if (d->widget && (!d->widget->hasFocus()
partially evaluated: d->widget
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1052 1-5
1053 1-5
1054 1-5
1055 ))
evaluated: (!d->widget->hasFocus() )
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
1056 d->popup->hide();
executed: d->popup->hide();
Execution Count:1
1
1057 if (e->isAccepted())
partially evaluated: e->isAccepted()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1058 return true;
never executed: return true;
0
1059 }
executed: }
Execution Count:6
6
1060 -
1061 -
1062 switch (key) { -
1063 -
1064 -
1065 -
1066 -
1067 -
1068 case Qt::Key_Return: -
1069 case Qt::Key_Enter: -
1070 case Qt::Key_Tab: -
1071 d->popup->hide(); -
1072 if (curIndex.isValid())
partially evaluated: curIndex.isValid()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1073 d->_q_complete(curIndex);
executed: d->_q_complete(curIndex);
Execution Count:6
6
1074 break;
executed: break;
Execution Count:6
6
1075 -
1076 case Qt::Key_F4: -
1077 if (ke->modifiers() & Qt::AltModifier)
never evaluated: ke->modifiers() & Qt::AltModifier
0
1078 d->popup->hide();
never executed: d->popup->hide();
0
1079 break;
never executed: break;
0
1080 -
1081 case Qt::Key_Backtab: -
1082 case Qt::Key_Escape: -
1083 d->popup->hide(); -
1084 break;
executed: break;
Execution Count:1
1
1085 -
1086 default: -
1087 break;
never executed: break;
0
1088 } -
1089 -
1090 return true;
executed: return true;
Execution Count:7
7
1091 } -
1092 case QEvent::MouseButtonPress: { -
1093 if (!d->popup->underMouse()) {
never evaluated: !d->popup->underMouse()
0
1094 d->popup->hide(); -
1095 return true;
never executed: return true;
0
1096 } -
1097 } -
1098 return false;
never executed: return false;
0
1099 -
1100 case QEvent::InputMethod: -
1101 case QEvent::ShortcutOverride: -
1102 QApplication::sendEvent(d->widget, e); -
1103 break;
executed: break;
Execution Count:17
17
1104 -
1105 default: -
1106 return false;
executed: return false;
Execution Count:416
416
1107 } -
1108 return false;
executed: return false;
Execution Count:17
17
1109} -
1110void QCompleter::complete(const QRect& rect) -
1111{ -
1112 QCompleterPrivate * const d = d_func(); -
1113 QModelIndex idx = d->proxy->currentIndex(false); -
1114 d->hiddenBecauseNoMatch = false; -
1115 if (d->mode == QCompleter::InlineCompletion) {
evaluated: d->mode == QCompleter::InlineCompletion
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:102
13-102
1116 if (idx.isValid())
partially evaluated: idx.isValid()
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
1117 d->_q_complete(idx, true);
executed: d->_q_complete(idx, true);
Execution Count:13
13
1118 return;
executed: return;
Execution Count:13
13
1119 } -
1120 -
1121 qt_noop(); -
1122 if ((d->mode == QCompleter::PopupCompletion && !idx.isValid())
evaluated: d->mode == QCompleter::PopupCompletion
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:2
evaluated: !idx.isValid()
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:51
2-100
1123 || (d->mode == QCompleter::UnfilteredPopupCompletion && d->proxy->rowCount() == 0)) {
evaluated: d->mode == QCompleter::UnfilteredPopupCompletion
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:51
partially evaluated: d->proxy->rowCount() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-51
1124 if (d->popup)
partially evaluated: d->popup
TRUEFALSE
yes
Evaluation Count:49
no
Evaluation Count:0
0-49
1125 d->popup->hide();
executed: d->popup->hide();
Execution Count:49
49
1126 d->hiddenBecauseNoMatch = true; -
1127 return;
executed: return;
Execution Count:49
49
1128 } -
1129 -
1130 popup(); -
1131 if (d->mode == QCompleter::UnfilteredPopupCompletion)
evaluated: d->mode == QCompleter::UnfilteredPopupCompletion
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:51
2-51
1132 d->setCurrentIndex(idx, false);
executed: d->setCurrentIndex(idx, false);
Execution Count:2
2
1133 -
1134 d->showPopup(rect); -
1135 d->popupRect = rect; -
1136}
executed: }
Execution Count:53
53
1137bool QCompleter::setCurrentRow(int row) -
1138{ -
1139 QCompleterPrivate * const d = d_func(); -
1140 return d->proxy->setCurrentRow(row);
executed: return d->proxy->setCurrentRow(row);
Execution Count:172
172
1141} -
1142 -
1143 -
1144 -
1145 -
1146 -
1147 -
1148int QCompleter::currentRow() const -
1149{ -
1150 const QCompleterPrivate * const d = d_func(); -
1151 return d->proxy->currentRow();
executed: return d->proxy->currentRow();
Execution Count:156
156
1152} -
1153 -
1154 -
1155 -
1156 -
1157 -
1158 -
1159int QCompleter::completionCount() const -
1160{ -
1161 const QCompleterPrivate * const d = d_func(); -
1162 return d->proxy->completionCount();
executed: return d->proxy->completionCount();
Execution Count:33
33
1163} -
1164void QCompleter::setModelSorting(QCompleter::ModelSorting sorting) -
1165{ -
1166 QCompleterPrivate * const d = d_func(); -
1167 if (d->sorting == sorting)
evaluated: d->sorting == sorting
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:17
1-17
1168 return;
executed: return;
Execution Count:1
1
1169 d->sorting = sorting; -
1170 d->proxy->createEngine(); -
1171 d->proxy->invalidate(); -
1172}
executed: }
Execution Count:17
17
1173 -
1174QCompleter::ModelSorting QCompleter::modelSorting() const -
1175{ -
1176 const QCompleterPrivate * const d = d_func(); -
1177 return d->sorting;
executed: return d->sorting;
Execution Count:3
3
1178} -
1179void QCompleter::setCompletionColumn(int column) -
1180{ -
1181 QCompleterPrivate * const d = d_func(); -
1182 if (d->column == column)
evaluated: d->column == column
TRUEFALSE
yes
Evaluation Count:164
yes
Evaluation Count:3
3-164
1183 return;
executed: return;
Execution Count:164
164
1184 -
1185 if (QListView *listView = qobject_cast<QListView *>(d->popup))
partially evaluated: QListView *listView = qobject_cast<QListView *>(d->popup)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1186 listView->setModelColumn(column);
never executed: listView->setModelColumn(column);
0
1187 -
1188 d->column = column; -
1189 d->proxy->invalidate(); -
1190}
executed: }
Execution Count:3
3
1191 -
1192int QCompleter::completionColumn() const -
1193{ -
1194 const QCompleterPrivate * const d = d_func(); -
1195 return d->column;
executed: return d->column;
Execution Count:2
2
1196} -
1197void QCompleter::setCompletionRole(int role) -
1198{ -
1199 QCompleterPrivate * const d = d_func(); -
1200 if (d->role == role)
evaluated: d->role == role
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:196
1-196
1201 return;
executed: return;
Execution Count:1
1
1202 d->role = role; -
1203 d->proxy->invalidate(); -
1204}
executed: }
Execution Count:196
196
1205 -
1206int QCompleter::completionRole() const -
1207{ -
1208 const QCompleterPrivate * const d = d_func(); -
1209 return d->role;
executed: return d->role;
Execution Count:240
240
1210} -
1211void QCompleter::setWrapAround(bool wrap) -
1212{ -
1213 QCompleterPrivate * const d = d_func(); -
1214 if (d->wrap == wrap)
partially evaluated: d->wrap == wrap
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1215 return;
never executed: return;
0
1216 d->wrap = wrap; -
1217}
executed: }
Execution Count:2
2
1218 -
1219bool QCompleter::wrapAround() const -
1220{ -
1221 const QCompleterPrivate * const d = d_func(); -
1222 return d->wrap;
executed: return d->wrap;
Execution Count:6
6
1223} -
1224int QCompleter::maxVisibleItems() const -
1225{ -
1226 const QCompleterPrivate * const d = d_func(); -
1227 return d->maxVisibleItems;
executed: return d->maxVisibleItems;
Execution Count:3
3
1228} -
1229 -
1230void QCompleter::setMaxVisibleItems(int maxItems) -
1231{ -
1232 QCompleterPrivate * const d = d_func(); -
1233 if (maxItems < 0) {
evaluated: maxItems < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1234 QMessageLogger("util/qcompleter.cpp", 1575, __PRETTY_FUNCTION__).warning("QCompleter::setMaxVisibleItems: " -
1235 "Invalid max visible items (%d) must be >= 0", maxItems); -
1236 return;
executed: return;
Execution Count:1
1
1237 } -
1238 d->maxVisibleItems = maxItems; -
1239}
executed: }
Execution Count:1
1
1240void QCompleter::setCaseSensitivity(Qt::CaseSensitivity cs) -
1241{ -
1242 QCompleterPrivate * const d = d_func(); -
1243 if (d->cs == cs)
evaluated: d->cs == cs
TRUEFALSE
yes
Evaluation Count:203
yes
Evaluation Count:162
162-203
1244 return;
executed: return;
Execution Count:203
203
1245 d->cs = cs; -
1246 d->proxy->createEngine(); -
1247 d->proxy->invalidate(); -
1248}
executed: }
Execution Count:162
162
1249 -
1250Qt::CaseSensitivity QCompleter::caseSensitivity() const -
1251{ -
1252 const QCompleterPrivate * const d = d_func(); -
1253 return d->cs;
executed: return d->cs;
Execution Count:245
245
1254} -
1255void QCompleter::setCompletionPrefix(const QString &prefix) -
1256{ -
1257 QCompleterPrivate * const d = d_func(); -
1258 d->prefix = prefix; -
1259 d->proxy->filter(splitPath(prefix)); -
1260}
executed: }
Execution Count:625
625
1261 -
1262QString QCompleter::completionPrefix() const -
1263{ -
1264 const QCompleterPrivate * const d = d_func(); -
1265 return d->prefix;
executed: return d->prefix;
Execution Count:58
58
1266} -
1267 -
1268 -
1269 -
1270 -
1271 -
1272 -
1273QModelIndex QCompleter::currentIndex() const -
1274{ -
1275 const QCompleterPrivate * const d = d_func(); -
1276 return d->proxy->currentIndex(false);
executed: return d->proxy->currentIndex(false);
Execution Count:26
26
1277} -
1278QString QCompleter::currentCompletion() const -
1279{ -
1280 const QCompleterPrivate * const d = d_func(); -
1281 return pathFromIndex(d->proxy->currentIndex(true));
executed: return pathFromIndex(d->proxy->currentIndex(true));
Execution Count:250
250
1282} -
1283QAbstractItemModel *QCompleter::completionModel() const -
1284{ -
1285 const QCompleterPrivate * const d = d_func(); -
1286 return d->proxy;
executed: return d->proxy;
Execution Count:60
60
1287} -
1288QString QCompleter::pathFromIndex(const QModelIndex& index) const -
1289{ -
1290 const QCompleterPrivate * const d = d_func(); -
1291 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:65
5-65
1292 return QString();
executed: return QString();
Execution Count:5
5
1293 -
1294 QAbstractItemModel *sourceModel = d->proxy->sourceModel(); -
1295 if (!sourceModel)
partially evaluated: !sourceModel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:65
0-65
1296 return QString();
never executed: return QString();
0
1297 bool isDirModel = false; -
1298 bool isFsModel = false; -
1299 -
1300 isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0; -
1301 -
1302 -
1303 isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0; -
1304 -
1305 if (!isDirModel && !isFsModel)
evaluated: !isDirModel
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:8
evaluated: !isFsModel
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:9
8-57
1306 return sourceModel->data(index, d->role).toString();
executed: return sourceModel->data(index, d->role).toString();
Execution Count:48
48
1307 -
1308 QModelIndex idx = index; -
1309 QStringList list; -
1310 do { -
1311 QString t; -
1312 if (isDirModel)
evaluated: isDirModel
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:19
16-19
1313 t = sourceModel->data(idx, Qt::EditRole).toString();
executed: t = sourceModel->data(idx, Qt::EditRole).toString();
Execution Count:16
16
1314 -
1315 else -
1316 t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString();
executed: t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString();
Execution Count:19
19
1317 -
1318 list.prepend(t); -
1319 QModelIndex parent = idx.parent(); -
1320 idx = parent.sibling(parent.row(), index.column()); -
1321 } while (idx.isValid());
executed: }
Execution Count:35
evaluated: idx.isValid()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:17
17-35
1322 -
1323 -
1324 if (list.count() == 1)
evaluated: list.count() == 1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:13
4-13
1325 return list[0];
executed: return list[0];
Execution Count:4
4
1326 list[0].clear() ; -
1327 -
1328 -
1329 return list.join(QDir::separator());
executed: return list.join(QDir::separator());
Execution Count:13
13
1330} -
1331QStringList QCompleter::splitPath(const QString& path) const -
1332{ -
1333 bool isDirModel = false; -
1334 bool isFsModel = false; -
1335 -
1336 const QCompleterPrivate * const d = d_func(); -
1337 isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0; -
1338 -
1339 -
1340 -
1341 -
1342 -
1343 isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0; -
1344 -
1345 -
1346 if ((!isDirModel && !isFsModel) || path.isEmpty())
evaluated: !isDirModel
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:8
evaluated: !isFsModel
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:23
evaluated: path.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:27
4-67
1347 return QStringList(completionPrefix());
executed: return QStringList(completionPrefix());
Execution Count:48
48
1348 -
1349 QString pathCopy = QDir::toNativeSeparators(path); -
1350 QString sep = QDir::separator(); -
1351 QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']')); -
1352 QStringList parts = pathCopy.split(re); -
1353 -
1354 -
1355 -
1356 -
1357 -
1358 if (pathCopy[0] == sep[0])
partially evaluated: pathCopy[0] == sep[0]
TRUEFALSE
yes
Evaluation Count:27
no
Evaluation Count:0
0-27
1359 parts[0] = QDir::fromNativeSeparators(QString(sep[0]));
executed: parts[0] = QDir::fromNativeSeparators(QString(sep[0]));
Execution Count:27
27
1360 -
1361 -
1362 return parts;
executed: return parts;
Execution Count:27
27
1363} -
1364 -
1365 -
1366 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial