qcompleter.cpp

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

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