qcompleter.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/util/qcompleter.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34/*!-
35 \class QCompleter-
36 \brief The QCompleter class provides completions based on an item model.-
37 \since 4.2-
38-
39 \inmodule QtWidgets-
40-
41 You can use QCompleter to provide auto completions in any Qt-
42 widget, such as QLineEdit and QComboBox.-
43 When the user starts typing a word, QCompleter suggests possible ways of-
44 completing the word, based on a word list. The word list is-
45 provided as a QAbstractItemModel. (For simple applications, where-
46 the word list is static, you can pass a QStringList to-
47 QCompleter's constructor.)-
48-
49 \tableofcontents-
50-
51 \section1 Basic Usage-
52-
53 A QCompleter is used typically with a QLineEdit or QComboBox.-
54 For example, here's how to provide auto completions from a simple-
55 word list in a QLineEdit:-
56-
57 \snippet code/src_gui_util_qcompleter.cpp 0-
58-
59 A QFileSystemModel can be used to provide auto completion of file names.-
60 For example:-
61-
62 \snippet code/src_gui_util_qcompleter.cpp 1-
63-
64 To set the model on which QCompleter should operate, call-
65 setModel(). By default, QCompleter will attempt to match the \l-
66 {completionPrefix}{completion prefix} (i.e., the word that the-
67 user has started typing) against the Qt::EditRole data stored in-
68 column 0 in the model case sensitively. This can be changed-
69 using setCompletionRole(), setCompletionColumn(), and-
70 setCaseSensitivity().-
71-
72 If the model is sorted on the column and role that are used for completion,-
73 you can call setModelSorting() with either-
74 QCompleter::CaseSensitivelySortedModel or-
75 QCompleter::CaseInsensitivelySortedModel as the argument. On large models,-
76 this can lead to significant performance improvements, because QCompleter-
77 can then use binary search instead of linear search. The binary search only-
78 works when the filterMode is Qt::MatchStartsWith.-
79-
80 The model can be a \l{QAbstractListModel}{list model},-
81 a \l{QAbstractTableModel}{table model}, or a-
82 \l{QAbstractItemModel}{tree model}. Completion on tree models-
83 is slightly more involved and is covered in the \l{Handling-
84 Tree Models} section below.-
85-
86 The completionMode() determines the mode used to provide completions to-
87 the user.-
88-
89 \section1 Iterating Through Completions-
90-
91 To retrieve a single candidate string, call setCompletionPrefix()-
92 with the text that needs to be completed and call-
93 currentCompletion(). You can iterate through the list of-
94 completions as below:-
95-
96 \snippet code/src_gui_util_qcompleter.cpp 2-
97-
98 completionCount() returns the total number of completions for the-
99 current prefix. completionCount() should be avoided when possible,-
100 since it requires a scan of the entire model.-
101-
102 \section1 The Completion Model-
103-
104 completionModel() return a list model that contains all possible-
105 completions for the current completion prefix, in the order in which-
106 they appear in the model. This model can be used to display the current-
107 completions in a custom view. Calling setCompletionPrefix() automatically-
108 refreshes the completion model.-
109-
110 \section1 Handling Tree Models-
111-
112 QCompleter can look for completions in tree models, assuming-
113 that any item (or sub-item or sub-sub-item) can be unambiguously-
114 represented as a string by specifying the path to the item. The-
115 completion is then performed one level at a time.-
116-
117 Let's take the example of a user typing in a file system path.-
118 The model is a (hierarchical) QFileSystemModel. The completion-
119 occurs for every element in the path. For example, if the current-
120 text is \c C:\Wind, QCompleter might suggest \c Windows to-
121 complete the current path element. Similarly, if the current text-
122 is \c C:\Windows\Sy, QCompleter might suggest \c System.-
123-
124 For this kind of completion to work, QCompleter needs to be able to-
125 split the path into a list of strings that are matched at each level.-
126 For \c C:\Windows\Sy, it needs to be split as "C:", "Windows" and "Sy".-
127 The default implementation of splitPath(), splits the completionPrefix-
128 using QDir::separator() if the model is a QFileSystemModel.-
129-
130 To provide completions, QCompleter needs to know the path from an index.-
131 This is provided by pathFromIndex(). The default implementation of-
132 pathFromIndex(), returns the data for the \l{Qt::EditRole}{edit role}-
133 for list models and the absolute file path if the mode is a QFileSystemModel.-
134-
135 \sa QAbstractItemModel, QLineEdit, QComboBox, {Completer Example}-
136*/-
137-
138#include "qcompleter_p.h"-
139-
140#ifndef QT_NO_COMPLETER-
141-
142#include "QtWidgets/qscrollbar.h"-
143#include "QtCore/qstringlistmodel.h"-
144#include "QtWidgets/qdirmodel.h"-
145#include "QtWidgets/qfilesystemmodel.h"-
146#include "QtWidgets/qheaderview.h"-
147#include "QtWidgets/qlistview.h"-
148#include "QtWidgets/qapplication.h"-
149#include "QtGui/qevent.h"-
150#include "QtWidgets/qdesktopwidget.h"-
151#include "QtWidgets/qlineedit.h"-
152-
153QT_BEGIN_NAMESPACE-
154-
155QCompletionModel::QCompletionModel(QCompleterPrivate *c, QObject *parent)-
156 : QAbstractProxyModel(*new QCompletionModelPrivate, parent),-
157 c(c), showAll(false)-
158{-
159 createEngine();-
160}
never executed: end of block
0
161-
162int QCompletionModel::columnCount(const QModelIndex &) const-
163{-
164 Q_D(const QCompletionModel);-
165 return d->model->columnCount();
never executed: return d->model->columnCount();
0
166}-
167-
168void QCompletionModel::setSourceModel(QAbstractItemModel *source)-
169{-
170 bool hadModel = (sourceModel() != 0);-
171-
172 if (hadModel)
hadModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
173 QObject::disconnect(sourceModel(), 0, this, 0);
never executed: QObject::disconnect(sourceModel(), 0, this, 0);
0
174-
175 QAbstractProxyModel::setSourceModel(source);-
176-
177 if (source) {
sourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
178 // TODO: Optimize updates in the source model-
179 connect(source, SIGNAL(modelReset()), this, SLOT(invalidate()));-
180 connect(source, SIGNAL(destroyed()), this, SLOT(modelDestroyed()));-
181 connect(source, SIGNAL(layoutChanged()), this, SLOT(invalidate()));-
182 connect(source, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted()));-
183 connect(source, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(invalidate()));-
184 connect(source, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(invalidate()));-
185 connect(source, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(invalidate()));-
186 connect(source, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(invalidate()));-
187 }
never executed: end of block
0
188-
189 invalidate();-
190}
never executed: end of block
0
191-
192void QCompletionModel::createEngine()-
193{-
194 bool sortedEngine = false;-
195 if (c->filterMode == Qt::MatchStartsWith) {
c->filterMode ...atchStartsWithDescription
TRUEnever evaluated
FALSEnever evaluated
0
196 switch (c->sorting) {-
197 case QCompleter::UnsortedModel:
never executed: case QCompleter::UnsortedModel:
0
198 sortedEngine = false;-
199 break;
never executed: break;
0
200 case QCompleter::CaseSensitivelySortedModel:
never executed: case QCompleter::CaseSensitivelySortedModel:
0
201 sortedEngine = c->cs == Qt::CaseSensitive;-
202 break;
never executed: break;
0
203 case QCompleter::CaseInsensitivelySortedModel:
never executed: case QCompleter::CaseInsensitivelySortedModel:
0
204 sortedEngine = c->cs == Qt::CaseInsensitive;-
205 break;
never executed: break;
0
206 }-
207 }
never executed: end of block
0
208-
209 if (sortedEngine)
sortedEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
210 engine.reset(new QSortedModelEngine(c));
never executed: engine.reset(new QSortedModelEngine(c));
0
211 else-
212 engine.reset(new QUnsortedModelEngine(c));
never executed: engine.reset(new QUnsortedModelEngine(c));
0
213}-
214-
215QModelIndex QCompletionModel::mapToSource(const QModelIndex& index) const-
216{-
217 Q_D(const QCompletionModel);-
218 if (!index.isValid())
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
219 return engine->curParent;
never executed: return engine->curParent;
0
220-
221 int row;-
222 QModelIndex parent = engine->curParent;-
223 if (!showAll) {
!showAllDescription
TRUEnever evaluated
FALSEnever evaluated
0
224 if (!engine->matchCount())
!engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
225 return QModelIndex();
never executed: return QModelIndex();
0
226 Q_ASSERT(index.row() < engine->matchCount());-
227 QIndexMapper& rootIndices = engine->historyMatch.indices;-
228 if (index.row() < rootIndices.count()) {
index.row() < ...ndices.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
229 row = rootIndices[index.row()];-
230 parent = QModelIndex();-
231 } else {
never executed: end of block
0
232 row = engine->curMatch.indices[index.row() - rootIndices.count()];-
233 }
never executed: end of block
0
234 } else {-
235 row = index.row();-
236 }
never executed: end of block
0
237-
238 return d->model->index(row, index.column(), parent);
never executed: return d->model->index(row, index.column(), parent);
0
239}-
240-
241QModelIndex QCompletionModel::mapFromSource(const QModelIndex& idx) const-
242{-
243 if (!idx.isValid())
!idx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
244 return QModelIndex();
never executed: return QModelIndex();
0
245-
246 int row = -1;-
247 if (!showAll) {
!showAllDescription
TRUEnever evaluated
FALSEnever evaluated
0
248 if (!engine->matchCount())
!engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
249 return QModelIndex();
never executed: return QModelIndex();
0
250-
251 QIndexMapper& rootIndices = engine->historyMatch.indices;-
252 if (idx.parent().isValid()) {
idx.parent().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
253 if (idx.parent() != engine->curParent)
idx.parent() !...ine->curParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
254 return QModelIndex();
never executed: return QModelIndex();
0
255 } else {
never executed: end of block
0
256 row = rootIndices.indexOf(idx.row());-
257 if (row == -1 && engine->curParent.isValid())
row == -1Description
TRUEnever evaluated
FALSEnever evaluated
engine->curParent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
258 return QModelIndex(); // source parent and our parent don't match
never executed: return QModelIndex();
0
259 }
never executed: end of block
0
260-
261 if (row == -1) {
row == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
262 QIndexMapper& indices = engine->curMatch.indices;-
263 engine->filterOnDemand(idx.row() - indices.last());-
264 row = indices.indexOf(idx.row()) + rootIndices.count();-
265 }
never executed: end of block
0
266-
267 if (row == -1)
row == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
268 return QModelIndex();
never executed: return QModelIndex();
0
269 } else {
never executed: end of block
0
270 if (idx.parent() != engine->curParent)
idx.parent() !...ine->curParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
271 return QModelIndex();
never executed: return QModelIndex();
0
272 row = idx.row();-
273 }
never executed: end of block
0
274-
275 return createIndex(row, idx.column());
never executed: return createIndex(row, idx.column());
0
276}-
277-
278bool QCompletionModel::setCurrentRow(int row)-
279{-
280 if (row < 0 || !engine->matchCount())
row < 0Description
TRUEnever evaluated
FALSEnever evaluated
!engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
281 return false;
never executed: return false;
0
282-
283 if (row >= engine->matchCount())
row >= engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
284 engine->filterOnDemand(row + 1 - engine->matchCount());
never executed: engine->filterOnDemand(row + 1 - engine->matchCount());
0
285-
286 if (row >= engine->matchCount()) // invalid row
row >= engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
287 return false;
never executed: return false;
0
288-
289 engine->curRow = row;-
290 return true;
never executed: return true;
0
291}-
292-
293QModelIndex QCompletionModel::currentIndex(bool sourceIndex) const-
294{-
295 if (!engine->matchCount())
!engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
296 return QModelIndex();
never executed: return QModelIndex();
0
297-
298 int row = engine->curRow;-
299 if (showAll)
showAllDescription
TRUEnever evaluated
FALSEnever evaluated
0
300 row = engine->curMatch.indices[engine->curRow];
never executed: row = engine->curMatch.indices[engine->curRow];
0
301-
302 QModelIndex idx = createIndex(row, c->column);-
303 if (!sourceIndex)
!sourceIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
304 return idx;
never executed: return idx;
0
305 return mapToSource(idx);
never executed: return mapToSource(idx);
0
306}-
307-
308QModelIndex QCompletionModel::index(int row, int column, const QModelIndex& parent) const-
309{-
310 Q_D(const QCompletionModel);-
311 if (row < 0 || column < 0 || column >= columnCount(parent) || parent.isValid())
row < 0Description
TRUEnever evaluated
FALSEnever evaluated
column < 0Description
TRUEnever evaluated
FALSEnever evaluated
column >= columnCount(parent)Description
TRUEnever evaluated
FALSEnever evaluated
parent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
312 return QModelIndex();
never executed: return QModelIndex();
0
313-
314 if (!showAll) {
!showAllDescription
TRUEnever evaluated
FALSEnever evaluated
0
315 if (!engine->matchCount())
!engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
316 return QModelIndex();
never executed: return QModelIndex();
0
317 if (row >= engine->historyMatch.indices.count()) {
row >= engine-...ndices.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
318 int want = row + 1 - engine->matchCount();-
319 if (want > 0)
want > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
320 engine->filterOnDemand(want);
never executed: engine->filterOnDemand(want);
0
321 if (row >= engine->matchCount())
row >= engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
322 return QModelIndex();
never executed: return QModelIndex();
0
323 }
never executed: end of block
0
324 } else {
never executed: end of block
0
325 if (row >= d->model->rowCount(engine->curParent))
row >= d->mode...ne->curParent)Description
TRUEnever evaluated
FALSEnever evaluated
0
326 return QModelIndex();
never executed: return QModelIndex();
0
327 }
never executed: end of block
0
328-
329 return createIndex(row, column);
never executed: return createIndex(row, column);
0
330}-
331-
332int QCompletionModel::completionCount() const-
333{-
334 if (!engine->matchCount())
!engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
335 return 0;
never executed: return 0;
0
336-
337 engine->filterOnDemand(INT_MAX);-
338 return engine->matchCount();
never executed: return engine->matchCount();
0
339}-
340-
341int QCompletionModel::rowCount(const QModelIndex &parent) const-
342{-
343 Q_D(const QCompletionModel);-
344 if (parent.isValid())
parent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
345 return 0;
never executed: return 0;
0
346-
347 if (showAll) {
showAllDescription
TRUEnever evaluated
FALSEnever evaluated
0
348 // Show all items below current parent, even if we have no valid matches-
349 if (engine->curParts.count() != 1 && !engine->matchCount()
engine->curParts.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
!engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
350 && !engine->curParent.isValid())
!engine->curParent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
351 return 0;
never executed: return 0;
0
352 return d->model->rowCount(engine->curParent);
never executed: return d->model->rowCount(engine->curParent);
0
353 }-
354-
355 return completionCount();
never executed: return completionCount();
0
356}-
357-
358void QCompletionModel::setFiltered(bool filtered)-
359{-
360 if (showAll == !filtered)
showAll == !filteredDescription
TRUEnever evaluated
FALSEnever evaluated
0
361 return;
never executed: return;
0
362 beginResetModel();-
363 showAll = !filtered;-
364 endResetModel();-
365}
never executed: end of block
0
366-
367bool QCompletionModel::hasChildren(const QModelIndex &parent) const-
368{-
369 Q_D(const QCompletionModel);-
370 if (parent.isValid())
parent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
371 return false;
never executed: return false;
0
372-
373 if (showAll)
showAllDescription
TRUEnever evaluated
FALSEnever evaluated
0
374 return d->model->hasChildren(mapToSource(parent));
never executed: return d->model->hasChildren(mapToSource(parent));
0
375-
376 if (!engine->matchCount())
!engine->matchCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
377 return false;
never executed: return false;
0
378-
379 return true;
never executed: return true;
0
380}-
381-
382QVariant QCompletionModel::data(const QModelIndex& index, int role) const-
383{-
384 Q_D(const QCompletionModel);-
385 return d->model->data(mapToSource(index), role);
never executed: return d->model->data(mapToSource(index), role);
0
386}-
387-
388void QCompletionModel::modelDestroyed()-
389{-
390 QAbstractProxyModel::setSourceModel(0); // switch to static empty model-
391 invalidate();-
392}
never executed: end of block
0
393-
394void QCompletionModel::rowsInserted()-
395{-
396 invalidate();-
397 emit rowsAdded();-
398}
never executed: end of block
0
399-
400void QCompletionModel::invalidate()-
401{-
402 engine->cache.clear();-
403 filter(engine->curParts);-
404}
never executed: end of block
0
405-
406void QCompletionModel::filter(const QStringList& parts)-
407{-
408 Q_D(QCompletionModel);-
409 beginResetModel();-
410 engine->filter(parts);-
411 endResetModel();-
412-
413 if (d->model->canFetchMore(engine->curParent))
d->model->canF...ne->curParent)Description
TRUEnever evaluated
FALSEnever evaluated
0
414 d->model->fetchMore(engine->curParent);
never executed: d->model->fetchMore(engine->curParent);
0
415}
never executed: end of block
0
416-
417//////////////////////////////////////////////////////////////////////////////-
418void QCompletionEngine::filter(const QStringList& parts)-
419{-
420 const QAbstractItemModel *model = c->proxy->sourceModel();-
421 curParts = parts;-
422 if (curParts.isEmpty())
curParts.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
423 curParts.append(QString());
never executed: curParts.append(QString());
0
424-
425 curRow = -1;-
426 curParent = QModelIndex();-
427 curMatch = QMatchData();-
428 historyMatch = filterHistory();-
429-
430 if (!model)
!modelDescription
TRUEnever evaluated
FALSEnever evaluated
0
431 return;
never executed: return;
0
432-
433 QModelIndex parent;-
434 for (int i = 0; i < curParts.count() - 1; i++) {
i < curParts.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
435 QString part = curParts.at(i);-
436 int emi = filter(part, parent, -1).exactMatchIndex;-
437 if (emi == -1)
emi == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
438 return;
never executed: return;
0
439 parent = model->index(emi, c->column, parent);-
440 }
never executed: end of block
0
441-
442 // Note that we set the curParent to a valid parent, even if we have no matches-
443 // When filtering is disabled, we show all the items under this parent-
444 curParent = parent;-
445 if (curParts.constLast().isEmpty())
curParts.constLast().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
446 curMatch = QMatchData(QIndexMapper(0, model->rowCount(curParent) - 1), -1, false);
never executed: curMatch = QMatchData(QIndexMapper(0, model->rowCount(curParent) - 1), -1, false);
0
447 else-
448 curMatch = filter(curParts.constLast(), curParent, 1); // build at least one
never executed: curMatch = filter(curParts.constLast(), curParent, 1);
0
449 curRow = curMatch.isValid() ? 0 : -1;
curMatch.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
450}
never executed: end of block
0
451-
452QMatchData QCompletionEngine::filterHistory()-
453{-
454 QAbstractItemModel *source = c->proxy->sourceModel();-
455 if (curParts.count() <= 1 || c->proxy->showAll || !source)
curParts.count() <= 1Description
TRUEnever evaluated
FALSEnever evaluated
c->proxy->showAllDescription
TRUEnever evaluated
FALSEnever evaluated
!sourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
456 return QMatchData();
never executed: return QMatchData();
0
457-
458#ifndef QT_NO_DIRMODEL-
459 const bool isDirModel = (qobject_cast<QDirModel *>(source) != 0);-
460#else-
461 const bool isDirModel = false;-
462#endif-
463 Q_UNUSED(isDirModel)-
464#ifndef QT_NO_FILESYSTEMMODEL-
465 const bool isFsModel = (qobject_cast<QFileSystemModel *>(source) != 0);-
466#else-
467 const bool isFsModel = false;-
468#endif-
469 Q_UNUSED(isFsModel)-
470 QVector<int> v;-
471 QIndexMapper im(v);-
472 QMatchData m(im, -1, true);-
473-
474 for (int i = 0; i < source->rowCount(); i++) {
i < source->rowCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
475 QString str = source->index(i, c->column).data().toString();-
476 if (str.startsWith(c->prefix, c->cs)
str.startsWith...prefix, c->cs)Description
TRUEnever evaluated
FALSEnever evaluated
0
477#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)-
478 && ((!isFsModel && !isDirModel) || QDir::toNativeSeparators(str) != QDir::separator())
!isFsModelDescription
TRUEnever evaluated
FALSEnever evaluated
!isDirModelDescription
TRUEnever evaluated
FALSEnever evaluated
QDir::toNative...r::separator()Description
TRUEnever evaluated
FALSEnever evaluated
0
479#endif-
480 )-
481 m.indices.append(i);
never executed: m.indices.append(i);
0
482 }
never executed: end of block
0
483 return m;
never executed: return m;
0
484}-
485-
486// Returns a match hint from the cache by chopping the search string-
487bool QCompletionEngine::matchHint(QString part, const QModelIndex& parent, QMatchData *hint)-
488{-
489 if (c->cs == Qt::CaseInsensitive)
c->cs == Qt::CaseInsensitiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
490 part = part.toLower();
never executed: part = part.toLower();
0
491-
492 const CacheItem& map = cache[parent];-
493-
494 QString key = part;-
495 while (!key.isEmpty()) {
!key.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
496 key.chop(1);-
497 if (map.contains(key)) {
map.contains(key)Description
TRUEnever evaluated
FALSEnever evaluated
0
498 *hint = map[key];-
499 return true;
never executed: return true;
0
500 }-
501 }
never executed: end of block
0
502-
503 return false;
never executed: return false;
0
504}-
505-
506bool QCompletionEngine::lookupCache(QString part, const QModelIndex& parent, QMatchData *m)-
507{-
508 if (c->cs == Qt::CaseInsensitive)
c->cs == Qt::CaseInsensitiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
509 part = part.toLower();
never executed: part = part.toLower();
0
510 const CacheItem& map = cache[parent];-
511 if (!map.contains(part))
!map.contains(part)Description
TRUEnever evaluated
FALSEnever evaluated
0
512 return false;
never executed: return false;
0
513 *m = map[part];-
514 return true;
never executed: return true;
0
515}-
516-
517// When the cache size exceeds 1MB, it clears out about 1/2 of the cache.-
518void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, const QMatchData& m)-
519{-
520 if (c->filterMode == Qt::MatchEndsWith)
c->filterMode ...:MatchEndsWithDescription
TRUEnever evaluated
FALSEnever evaluated
0
521 return;
never executed: return;
0
522 QMatchData old = cache[parent].take(part);-
523 cost = cost + m.indices.cost() - old.indices.cost();-
524 if (cost * sizeof(int) > 1024 * 1024) {
cost * sizeof(... > 1024 * 1024Description
TRUEnever evaluated
FALSEnever evaluated
0
525 QMap<QModelIndex, CacheItem>::iterator it1 = cache.begin();-
526 while (it1 != cache.end()) {
it1 != cache.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
527 CacheItem& ci = it1.value();-
528 int sz = ci.count()/2;-
529 QMap<QString, QMatchData>::iterator it2 = ci.begin();-
530 int i = 0;-
531 while (it2 != ci.end() && i < sz) {
it2 != ci.end()Description
TRUEnever evaluated
FALSEnever evaluated
i < szDescription
TRUEnever evaluated
FALSEnever evaluated
0
532 cost -= it2.value().indices.cost();-
533 it2 = ci.erase(it2);-
534 i++;-
535 }
never executed: end of block
0
536 if (ci.count() == 0) {
ci.count() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
537 it1 = cache.erase(it1);-
538 } else {
never executed: end of block
0
539 ++it1;-
540 }
never executed: end of block
0
541 }-
542 }
never executed: end of block
0
543-
544 if (c->cs == Qt::CaseInsensitive)
c->cs == Qt::CaseInsensitiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
545 part = part.toLower();
never executed: part = part.toLower();
0
546 cache[parent][part] = m;-
547}
never executed: end of block
0
548-
549///////////////////////////////////////////////////////////////////////////////////-
550QIndexMapper QSortedModelEngine::indexHint(QString part, const QModelIndex& parent, Qt::SortOrder order)-
551{-
552 const QAbstractItemModel *model = c->proxy->sourceModel();-
553-
554 if (c->cs == Qt::CaseInsensitive)
c->cs == Qt::CaseInsensitiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
555 part = part.toLower();
never executed: part = part.toLower();
0
556-
557 const CacheItem& map = cache[parent];-
558-
559 // Try to find a lower and upper bound for the search from previous results-
560 int to = model->rowCount(parent) - 1;-
561 int from = 0;-
562 const CacheItem::const_iterator it = map.lowerBound(part);-
563-
564 // look backward for first valid hint-
565 for(CacheItem::const_iterator it1 = it; it1-- != map.constBegin();) {
it1-- != map.constBegin()Description
TRUEnever evaluated
FALSEnever evaluated
0
566 const QMatchData& value = it1.value();-
567 if (value.isValid()) {
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
568 if (order == Qt::AscendingOrder) {
order == Qt::AscendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
0
569 from = value.indices.last() + 1;-
570 } else {
never executed: end of block
0
571 to = value.indices.first() - 1;-
572 }
never executed: end of block
0
573 break;
never executed: break;
0
574 }-
575 }
never executed: end of block
0
576-
577 // look forward for first valid hint-
578 for(CacheItem::const_iterator it2 = it; it2 != map.constEnd(); ++it2) {
it2 != map.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
579 const QMatchData& value = it2.value();-
580 if (value.isValid() && !it2.key().startsWith(part)) {
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
!it2.key().startsWith(part)Description
TRUEnever evaluated
FALSEnever evaluated
0
581 if (order == Qt::AscendingOrder) {
order == Qt::AscendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
0
582 to = value.indices.first() - 1;-
583 } else {
never executed: end of block
0
584 from = value.indices.first() + 1;-
585 }
never executed: end of block
0
586 break;
never executed: break;
0
587 }-
588 }
never executed: end of block
0
589-
590 return QIndexMapper(from, to);
never executed: return QIndexMapper(from, to);
0
591}-
592-
593Qt::SortOrder QSortedModelEngine::sortOrder(const QModelIndex &parent) const-
594{-
595 const QAbstractItemModel *model = c->proxy->sourceModel();-
596-
597 int rowCount = model->rowCount(parent);-
598 if (rowCount < 2)
rowCount < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
599 return Qt::AscendingOrder;
never executed: return Qt::AscendingOrder;
0
600 QString first = model->data(model->index(0, c->column, parent), c->role).toString();-
601 QString last = model->data(model->index(rowCount - 1, c->column, parent), c->role).toString();-
602 return 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;
QString::compa...t, c->cs) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
603}-
604-
605QMatchData QSortedModelEngine::filter(const QString& part, const QModelIndex& parent, int)-
606{-
607 const QAbstractItemModel *model = c->proxy->sourceModel();-
608-
609 QMatchData hint;-
610 if (lookupCache(part, parent, &hint))
lookupCache(pa...parent, &hint)Description
TRUEnever evaluated
FALSEnever evaluated
0
611 return hint;
never executed: return hint;
0
612-
613 QIndexMapper indices;-
614 Qt::SortOrder order = sortOrder(parent);-
615-
616 if (matchHint(part, parent, &hint)) {
matchHint(part, parent, &hint)Description
TRUEnever evaluated
FALSEnever evaluated
0
617 if (!hint.isValid())
!hint.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
618 return QMatchData();
never executed: return QMatchData();
0
619 indices = hint.indices;-
620 } else {
never executed: end of block
0
621 indices = indexHint(part, parent, order);-
622 }
never executed: end of block
0
623-
624 // binary search the model within 'indices' for 'part' under 'parent'-
625 int high = indices.to() + 1;-
626 int low = indices.from() - 1;-
627 int probe;-
628 QModelIndex probeIndex;-
629 QString probeData;-
630-
631 while (high - low > 1)
high - low > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
632 {-
633 probe = (high + low) / 2;-
634 probeIndex = model->index(probe, c->column, parent);-
635 probeData = model->data(probeIndex, c->role).toString();-
636 const int cmp = QString::compare(probeData, part, c->cs);-
637 if ((order == Qt::AscendingOrder && cmp >= 0)
order == Qt::AscendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
cmp >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
638 || (order == Qt::DescendingOrder && cmp < 0)) {
order == Qt::DescendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
cmp < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
639 high = probe;-
640 } else {
never executed: end of block
0
641 low = probe;-
642 }
never executed: end of block
0
643 }-
644-
645 if ((order == Qt::AscendingOrder && low == indices.to())
order == Qt::AscendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
low == indices.to()Description
TRUEnever evaluated
FALSEnever evaluated
0
646 || (order == Qt::DescendingOrder && high == indices.from())) { // not found
order == Qt::DescendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
high == indices.from()Description
TRUEnever evaluated
FALSEnever evaluated
0
647 saveInCache(part, parent, QMatchData());-
648 return QMatchData();
never executed: return QMatchData();
0
649 }-
650-
651 probeIndex = model->index(order == Qt::AscendingOrder ? low+1 : high-1, c->column, parent);-
652 probeData = model->data(probeIndex, c->role).toString();-
653 if (!probeData.startsWith(part, c->cs)) {
!probeData.sta...h(part, c->cs)Description
TRUEnever evaluated
FALSEnever evaluated
0
654 saveInCache(part, parent, QMatchData());-
655 return QMatchData();
never executed: return QMatchData();
0
656 }-
657-
658 const bool exactMatch = QString::compare(probeData, part, c->cs) == 0;-
659 int emi = exactMatch ? (order == Qt::AscendingOrder ? low+1 : high-1) : -1;
exactMatchDescription
TRUEnever evaluated
FALSEnever evaluated
order == Qt::AscendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
0
660-
661 int from = 0;-
662 int to = 0;-
663 if (order == Qt::AscendingOrder) {
order == Qt::AscendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
0
664 from = low + 1;-
665 high = indices.to() + 1;-
666 low = from;-
667 } else {
never executed: end of block
0
668 to = high - 1;-
669 low = indices.from() - 1;-
670 high = to;-
671 }
never executed: end of block
0
672-
673 while (high - low > 1)
high - low > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
674 {-
675 probe = (high + low) / 2;-
676 probeIndex = model->index(probe, c->column, parent);-
677 probeData = model->data(probeIndex, c->role).toString();-
678 const bool startsWith = probeData.startsWith(part, c->cs);-
679 if ((order == Qt::AscendingOrder && startsWith)
order == Qt::AscendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
startsWithDescription
TRUEnever evaluated
FALSEnever evaluated
0
680 || (order == Qt::DescendingOrder && !startsWith)) {
order == Qt::DescendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
!startsWithDescription
TRUEnever evaluated
FALSEnever evaluated
0
681 low = probe;-
682 } else {
never executed: end of block
0
683 high = probe;-
684 }
never executed: end of block
0
685 }-
686-
687 QMatchData m(order == Qt::AscendingOrder ? QIndexMapper(from, high - 1) : QIndexMapper(low+1, to), emi, false);-
688 saveInCache(part, parent, m);-
689 return m;
never executed: return m;
0
690}-
691-
692////////////////////////////////////////////////////////////////////////////////////////-
693int QUnsortedModelEngine::buildIndices(const QString& str, const QModelIndex& parent, int n,-
694 const QIndexMapper& indices, QMatchData* m)-
695{-
696 Q_ASSERT(m->partial);-
697 Q_ASSERT(n != -1 || m->exactMatchIndex == -1);-
698 const QAbstractItemModel *model = c->proxy->sourceModel();-
699 int i, count = 0;-
700-
701 for (i = 0; i < indices.count() && count != n; ++i) {
i < indices.count()Description
TRUEnever evaluated
FALSEnever evaluated
count != nDescription
TRUEnever evaluated
FALSEnever evaluated
0
702 QModelIndex idx = model->index(indices[i], c->column, parent);-
703-
704 if (!(model->flags(idx) & Qt::ItemIsSelectable))
!(model->flags...mIsSelectable)Description
TRUEnever evaluated
FALSEnever evaluated
0
705 continue;
never executed: continue;
0
706-
707 QString data = model->data(idx, c->role).toString();-
708-
709 switch (c->filterMode) {-
710 case Qt::MatchStartsWith:
never executed: case Qt::MatchStartsWith:
0
711 if (!data.startsWith(str, c->cs))
!data.startsWith(str, c->cs)Description
TRUEnever evaluated
FALSEnever evaluated
0
712 continue;
never executed: continue;
0
713 break;
never executed: break;
0
714 case Qt::MatchContains:
never executed: case Qt::MatchContains:
0
715 if (!data.contains(str, c->cs))
!data.contains(str, c->cs)Description
TRUEnever evaluated
FALSEnever evaluated
0
716 continue;
never executed: continue;
0
717 break;
never executed: break;
0
718 case Qt::MatchEndsWith:
never executed: case Qt::MatchEndsWith:
0
719 if (!data.endsWith(str, c->cs))
!data.endsWith(str, c->cs)Description
TRUEnever evaluated
FALSEnever evaluated
0
720 continue;
never executed: continue;
0
721 break;
never executed: break;
0
722 case Qt::MatchExactly:
never executed: case Qt::MatchExactly:
0
723 case Qt::MatchFixedString:
never executed: case Qt::MatchFixedString:
0
724 case Qt::MatchCaseSensitive:
never executed: case Qt::MatchCaseSensitive:
0
725 case Qt::MatchRegExp:
never executed: case Qt::MatchRegExp:
0
726 case Qt::MatchWildcard:
never executed: case Qt::MatchWildcard:
0
727 case Qt::MatchWrap:
never executed: case Qt::MatchWrap:
0
728 case Qt::MatchRecursive:
never executed: case Qt::MatchRecursive:
0
729 Q_UNREACHABLE();-
730 break;
never executed: break;
0
731 }-
732 m->indices.append(indices[i]);-
733 ++count;-
734 if (m->exactMatchIndex == -1 && QString::compare(data, str, c->cs) == 0) {
m->exactMatchIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
QString::compa...r, c->cs) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
735 m->exactMatchIndex = indices[i];-
736 if (n == -1)
n == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
737 return indices[i];
never executed: return indices[i];
0
738 }
never executed: end of block
0
739 }
never executed: end of block
0
740 return indices[i-1];
never executed: return indices[i-1];
0
741}-
742-
743void QUnsortedModelEngine::filterOnDemand(int n)-
744{-
745 Q_ASSERT(matchCount());-
746 if (!curMatch.partial)
!curMatch.partialDescription
TRUEnever evaluated
FALSEnever evaluated
0
747 return;
never executed: return;
0
748 Q_ASSERT(n >= -1);-
749 const QAbstractItemModel *model = c->proxy->sourceModel();-
750 int lastRow = model->rowCount(curParent) - 1;-
751 QIndexMapper im(curMatch.indices.last() + 1, lastRow);-
752 int lastIndex = buildIndices(curParts.last(), curParent, n, im, &curMatch);-
753 curMatch.partial = (lastRow != lastIndex);-
754 saveInCache(curParts.last(), curParent, curMatch);-
755}
never executed: end of block
0
756-
757QMatchData QUnsortedModelEngine::filter(const QString& part, const QModelIndex& parent, int n)-
758{-
759 QMatchData hint;-
760-
761 QVector<int> v;-
762 QIndexMapper im(v);-
763 QMatchData m(im, -1, true);-
764-
765 const QAbstractItemModel *model = c->proxy->sourceModel();-
766 bool foundInCache = lookupCache(part, parent, &m);-
767-
768 if (!foundInCache) {
!foundInCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
769 if (matchHint(part, parent, &hint) && !hint.isValid())
matchHint(part, parent, &hint)Description
TRUEnever evaluated
FALSEnever evaluated
!hint.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
770 return QMatchData();
never executed: return QMatchData();
0
771 }
never executed: end of block
0
772-
773 if (!foundInCache && !hint.isValid()) {
!foundInCacheDescription
TRUEnever evaluated
FALSEnever evaluated
!hint.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
774 const int lastRow = model->rowCount(parent) - 1;-
775 QIndexMapper all(0, lastRow);-
776 int lastIndex = buildIndices(part, parent, n, all, &m);-
777 m.partial = (lastIndex != lastRow);-
778 } else {
never executed: end of block
0
779 if (!foundInCache) { // build from hint as much as we can
!foundInCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
780 buildIndices(part, parent, INT_MAX, hint.indices, &m);-
781 m.partial = hint.partial;-
782 }
never executed: end of block
0
783 if (m.partial && ((n == -1 && m.exactMatchIndex == -1) || (m.indices.count() < n))) {
m.partialDescription
TRUEnever evaluated
FALSEnever evaluated
n == -1Description
TRUEnever evaluated
FALSEnever evaluated
m.exactMatchIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
(m.indices.count() < n)Description
TRUEnever evaluated
FALSEnever evaluated
0
784 // need more and have more-
785 const int lastRow = model->rowCount(parent) - 1;-
786 QIndexMapper rest(hint.indices.last() + 1, lastRow);-
787 int want = n == -1 ? -1 : n - m.indices.count();
n == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
788 int lastIndex = buildIndices(part, parent, want, rest, &m);-
789 m.partial = (lastRow != lastIndex);-
790 }
never executed: end of block
0
791 }
never executed: end of block
0
792-
793 saveInCache(part, parent, m);-
794 return m;
never executed: return m;
0
795}-
796-
797///////////////////////////////////////////////////////////////////////////////-
798QCompleterPrivate::QCompleterPrivate()-
799: widget(0), proxy(0), popup(0), filterMode(Qt::MatchStartsWith), cs(Qt::CaseSensitive),-
800 role(Qt::EditRole), column(0), maxVisibleItems(7), sorting(QCompleter::UnsortedModel),-
801 wrap(true), eatFocusOut(true), hiddenBecauseNoMatch(false)-
802{-
803}
never executed: end of block
0
804-
805void QCompleterPrivate::init(QAbstractItemModel *m)-
806{-
807 Q_Q(QCompleter);-
808 proxy = new QCompletionModel(this, q);-
809 QObject::connect(proxy, SIGNAL(rowsAdded()), q, SLOT(_q_autoResizePopup()));-
810 q->setModel(m);-
811#ifdef QT_NO_LISTVIEW-
812 q->setCompletionMode(QCompleter::InlineCompletion);-
813#else-
814 q->setCompletionMode(QCompleter::PopupCompletion);-
815#endif // QT_NO_LISTVIEW-
816}
never executed: end of block
0
817-
818void QCompleterPrivate::setCurrentIndex(QModelIndex index, bool select)-
819{-
820 Q_Q(QCompleter);-
821 if (!q->popup())
!q->popup()Description
TRUEnever evaluated
FALSEnever evaluated
0
822 return;
never executed: return;
0
823 if (!select) {
!selectDescription
TRUEnever evaluated
FALSEnever evaluated
0
824 popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);-
825 } else {
never executed: end of block
0
826 if (!index.isValid())
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
827 popup->selectionModel()->clear();
never executed: popup->selectionModel()->clear();
0
828 else-
829 popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select
never executed: popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
0
830 | QItemSelectionModel::Rows);
never executed: popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
0
831 }-
832 index = popup->selectionModel()->currentIndex();-
833 if (!index.isValid())
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
834 popup->scrollToTop();
never executed: popup->scrollToTop();
0
835 else-
836 popup->scrollTo(index, QAbstractItemView::PositionAtTop);
never executed: popup->scrollTo(index, QAbstractItemView::PositionAtTop);
0
837}-
838-
839void QCompleterPrivate::_q_completionSelected(const QItemSelection& selection)-
840{-
841 QModelIndex index;-
842 if (!selection.indexes().isEmpty())
!selection.indexes().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
843 index = selection.indexes().first();
never executed: index = selection.indexes().first();
0
844-
845 _q_complete(index, true);-
846}
never executed: end of block
0
847-
848void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted)-
849{-
850 Q_Q(QCompleter);-
851 QString completion;-
852-
853 if (!index.isValid() || (!proxy->showAll && (index.row() >= proxy->engine->matchCount()))) {
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
!proxy->showAllDescription
TRUEnever evaluated
FALSEnever evaluated
(index.row() >...>matchCount())Description
TRUEnever evaluated
FALSEnever evaluated
0
854 completion = prefix;-
855 index = QModelIndex();-
856 } else {
never executed: end of block
0
857 if (!(index.flags() & Qt::ItemIsEnabled))
!(index.flags(...ItemIsEnabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
858 return;
never executed: return;
0
859 QModelIndex si = proxy->mapToSource(index);-
860 si = si.sibling(si.row(), column); // for clicked()-
861 completion = q->pathFromIndex(si);-
862#ifndef QT_NO_DIRMODEL-
863 // add a trailing separator in inline-
864 if (mode == QCompleter::InlineCompletion) {
mode == QCompl...lineCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
0
865 if (qobject_cast<QDirModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
qobject_cast<Q...sourceModel())Description
TRUEnever evaluated
FALSEnever evaluated
QFileInfo(completion).isDir()Description
TRUEnever evaluated
FALSEnever evaluated
0
866 completion += QDir::separator();
never executed: completion += QDir::separator();
0
867 }
never executed: end of block
0
868#endif-
869#ifndef QT_NO_FILESYSTEMMODEL-
870 // add a trailing separator in inline-
871 if (mode == QCompleter::InlineCompletion) {
mode == QCompl...lineCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
0
872 if (qobject_cast<QFileSystemModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
qobject_cast<Q...sourceModel())Description
TRUEnever evaluated
FALSEnever evaluated
QFileInfo(completion).isDir()Description
TRUEnever evaluated
FALSEnever evaluated
0
873 completion += QDir::separator();
never executed: completion += QDir::separator();
0
874 }
never executed: end of block
0
875#endif-
876 }
never executed: end of block
0
877-
878 if (highlighted) {
highlightedDescription
TRUEnever evaluated
FALSEnever evaluated
0
879 emit q->highlighted(index);-
880 emit q->highlighted(completion);-
881 } else {
never executed: end of block
0
882 emit q->activated(index);-
883 emit q->activated(completion);-
884 }
never executed: end of block
0
885}-
886-
887void QCompleterPrivate::_q_autoResizePopup()-
888{-
889 if (!popup || !popup->isVisible())
!popupDescription
TRUEnever evaluated
FALSEnever evaluated
!popup->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
890 return;
never executed: return;
0
891 showPopup(popupRect);-
892}
never executed: end of block
0
893-
894void QCompleterPrivate::showPopup(const QRect& rect)-
895{-
896 const QRect screen = QApplication::desktop()->availableGeometry(widget);-
897 Qt::LayoutDirection dir = widget->layoutDirection();-
898 QPoint pos;-
899 int rh, w;-
900 int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3;-
901 QScrollBar *hsb = popup->horizontalScrollBar();-
902 if (hsb && hsb->isVisible())
hsbDescription
TRUEnever evaluated
FALSEnever evaluated
hsb->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
903 h += popup->horizontalScrollBar()->sizeHint().height();
never executed: h += popup->horizontalScrollBar()->sizeHint().height();
0
904-
905 if (rect.isValid()) {
rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
906 rh = rect.height();-
907 w = rect.width();-
908 pos = widget->mapToGlobal(dir == Qt::RightToLeft ? rect.bottomRight() : rect.bottomLeft());-
909 } else {
never executed: end of block
0
910 rh = widget->height();-
911 pos = widget->mapToGlobal(QPoint(0, widget->height() - 2));-
912 w = widget->width();-
913 }
never executed: end of block
0
914-
915 if (w > screen.width())
w > screen.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
916 w = screen.width();
never executed: w = screen.width();
0
917 if ((pos.x() + w) > (screen.x() + screen.width()))
(pos.x() + w) ...creen.width())Description
TRUEnever evaluated
FALSEnever evaluated
0
918 pos.setX(screen.x() + screen.width() - w);
never executed: pos.setX(screen.x() + screen.width() - w);
0
919 if (pos.x() < screen.x())
pos.x() < screen.x()Description
TRUEnever evaluated
FALSEnever evaluated
0
920 pos.setX(screen.x());
never executed: pos.setX(screen.x());
0
921-
922 int top = pos.y() - rh - screen.top() + 2;-
923 int bottom = screen.bottom() - pos.y();-
924 h = qMax(h, popup->minimumHeight());-
925 if (h > bottom) {
h > bottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
926 h = qMin(qMax(top, bottom), h);-
927-
928 if (top > bottom)
top > bottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
929 pos.setY(pos.y() - h - rh + 2);
never executed: pos.setY(pos.y() - h - rh + 2);
0
930 }
never executed: end of block
0
931-
932 popup->setGeometry(pos.x(), pos.y(), w, h);-
933-
934 if (!popup->isVisible())
!popup->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
935 popup->show();
never executed: popup->show();
0
936}
never executed: end of block
0
937-
938void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path)-
939{-
940 Q_Q(QCompleter);-
941 // Slot called when QFileSystemModel has finished loading.-
942 // If we hide the popup because there was no match because the model was not loaded yet,-
943 // we re-start the completion when we get the results-
944 if (hiddenBecauseNoMatch
hiddenBecauseNoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
945 && prefix.startsWith(path) && prefix != (path + QLatin1Char('/'))
prefix.startsWith(path)Description
TRUEnever evaluated
FALSEnever evaluated
prefix != (pat...tin1Char('/'))Description
TRUEnever evaluated
FALSEnever evaluated
0
946 && widget) {
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
947 q->complete();-
948 }
never executed: end of block
0
949}
never executed: end of block
0
950-
951/*!-
952 Constructs a completer object with the given \a parent.-
953*/-
954QCompleter::QCompleter(QObject *parent)-
955: QObject(*new QCompleterPrivate(), parent)-
956{-
957 Q_D(QCompleter);-
958 d->init();-
959}
never executed: end of block
0
960-
961/*!-
962 Constructs a completer object with the given \a parent that provides completions-
963 from the specified \a model.-
964*/-
965QCompleter::QCompleter(QAbstractItemModel *model, QObject *parent)-
966 : QObject(*new QCompleterPrivate(), parent)-
967{-
968 Q_D(QCompleter);-
969 d->init(model);-
970}
never executed: end of block
0
971-
972#ifndef QT_NO_STRINGLISTMODEL-
973/*!-
974 Constructs a QCompleter object with the given \a parent that uses the specified-
975 \a list as a source of possible completions.-
976*/-
977QCompleter::QCompleter(const QStringList& list, QObject *parent)-
978: QObject(*new QCompleterPrivate(), parent)-
979{-
980 Q_D(QCompleter);-
981 d->init(new QStringListModel(list, this));-
982}
never executed: end of block
0
983#endif // QT_NO_STRINGLISTMODEL-
984-
985/*!-
986 Destroys the completer object.-
987*/-
988QCompleter::~QCompleter()-
989{-
990}-
991-
992/*!-
993 Sets the widget for which completion are provided for to \a widget. This-
994 function is automatically called when a QCompleter is set on a QLineEdit-
995 using QLineEdit::setCompleter() or on a QComboBox using-
996 QComboBox::setCompleter(). The widget needs to be set explicitly when-
997 providing completions for custom widgets.-
998-
999 \sa widget(), setModel(), setPopup()-
1000 */-
1001void QCompleter::setWidget(QWidget *widget)-
1002{-
1003 Q_D(QCompleter);-
1004 if (d->widget)
d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1005 d->widget->removeEventFilter(this);
never executed: d->widget->removeEventFilter(this);
0
1006 d->widget = widget;-
1007 if (d->widget)
d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1008 d->widget->installEventFilter(this);
never executed: d->widget->installEventFilter(this);
0
1009 if (d->popup) {
d->popupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1010 d->popup->hide();-
1011 d->popup->setFocusProxy(d->widget);-
1012 }
never executed: end of block
0
1013}
never executed: end of block
0
1014-
1015/*!-
1016 Returns the widget for which the completer object is providing completions.-
1017-
1018 \sa setWidget()-
1019 */-
1020QWidget *QCompleter::widget() const-
1021{-
1022 Q_D(const QCompleter);-
1023 return d->widget;
never executed: return d->widget;
0
1024}-
1025-
1026/*!-
1027 Sets the model which provides completions to \a model. The \a model can-
1028 be list model or a tree model. If a model has been already previously set-
1029 and it has the QCompleter as its parent, it is deleted.-
1030-
1031 For convenience, if \a model is a QFileSystemModel, QCompleter switches its-
1032 caseSensitivity to Qt::CaseInsensitive on Windows and Qt::CaseSensitive-
1033 on other platforms.-
1034-
1035 \sa completionModel(), modelSorting, {Handling Tree Models}-
1036*/-
1037void QCompleter::setModel(QAbstractItemModel *model)-
1038{-
1039 Q_D(QCompleter);-
1040 QAbstractItemModel *oldModel = d->proxy->sourceModel();-
1041#ifndef QT_NO_FILESYSTEMMODEL-
1042 if (qobject_cast<const QFileSystemModel *>(oldModel))
qobject_cast<c...l *>(oldModel)Description
TRUEnever evaluated
FALSEnever evaluated
0
1043 setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
never executed: setCompletionRole(Qt::EditRole);
0
1044#endif-
1045 d->proxy->setSourceModel(model);-
1046 if (d->popup)
d->popupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1047 setPopup(d->popup); // set the model and make new connections
never executed: setPopup(d->popup);
0
1048 if (oldModel && oldModel->QObject::parent() == this)
oldModelDescription
TRUEnever evaluated
FALSEnever evaluated
oldModel->QObj...rent() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1049 delete oldModel;
never executed: delete oldModel;
0
1050#ifndef QT_NO_DIRMODEL-
1051 if (qobject_cast<QDirModel *>(model)) {
qobject_cast<Q...odel *>(model)Description
TRUEnever evaluated
FALSEnever evaluated
0
1052#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)-
1053 setCaseSensitivity(Qt::CaseInsensitive);-
1054#else-
1055 setCaseSensitivity(Qt::CaseSensitive);-
1056#endif-
1057 }
never executed: end of block
0
1058#endif // QT_NO_DIRMODEL-
1059#ifndef QT_NO_FILESYSTEMMODEL-
1060 QFileSystemModel *fsModel = qobject_cast<QFileSystemModel *>(model);-
1061 if (fsModel) {
fsModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1062#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)-
1063 setCaseSensitivity(Qt::CaseInsensitive);-
1064#else-
1065 setCaseSensitivity(Qt::CaseSensitive);-
1066#endif-
1067 setCompletionRole(QFileSystemModel::FileNameRole);-
1068 connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString)));-
1069 }
never executed: end of block
0
1070#endif // QT_NO_FILESYSTEMMODEL-
1071}
never executed: end of block
0
1072-
1073/*!-
1074 Returns the model that provides completion strings.-
1075-
1076 \sa completionModel()-
1077*/-
1078QAbstractItemModel *QCompleter::model() const-
1079{-
1080 Q_D(const QCompleter);-
1081 return d->proxy->sourceModel();
never executed: return d->proxy->sourceModel();
0
1082}-
1083-
1084/*!-
1085 \enum QCompleter::CompletionMode-
1086-
1087 This enum specifies how completions are provided to the user.-
1088-
1089 \value PopupCompletion Current completions are displayed in a popup window.-
1090 \value InlineCompletion Completions appear inline (as selected text).-
1091 \value UnfilteredPopupCompletion All possible completions are displayed in a popup window with the most likely suggestion indicated as current.-
1092-
1093 \sa setCompletionMode()-
1094*/-
1095-
1096/*!-
1097 \property QCompleter::completionMode-
1098 \brief how the completions are provided to the user-
1099-
1100 The default value is QCompleter::PopupCompletion.-
1101*/-
1102void QCompleter::setCompletionMode(QCompleter::CompletionMode mode)-
1103{-
1104 Q_D(QCompleter);-
1105 d->mode = mode;-
1106 d->proxy->setFiltered(mode != QCompleter::UnfilteredPopupCompletion);-
1107-
1108 if (mode == QCompleter::InlineCompletion) {
mode == QCompl...lineCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1109 if (d->widget)
d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1110 d->widget->removeEventFilter(this);
never executed: d->widget->removeEventFilter(this);
0
1111 if (d->popup) {
d->popupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1112 d->popup->deleteLater();-
1113 d->popup = 0;-
1114 }
never executed: end of block
0
1115 } else {
never executed: end of block
0
1116 if (d->widget)
d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1117 d->widget->installEventFilter(this);
never executed: d->widget->installEventFilter(this);
0
1118 }
never executed: end of block
0
1119}-
1120-
1121QCompleter::CompletionMode QCompleter::completionMode() const-
1122{-
1123 Q_D(const QCompleter);-
1124 return d->mode;
never executed: return d->mode;
0
1125}-
1126-
1127/*!-
1128 \property QCompleter::filterMode-
1129 \brief how the filtering is performed-
1130 \since 5.2-
1131-
1132 If filterMode is set to Qt::MatchStartsWith, only those entries that start-
1133 with the typed characters will be displayed. Qt::MatchContains will display-
1134 the entries that contain the typed characters, and Qt::MatchEndsWith the-
1135 ones that end with the typed characters.-
1136-
1137 Currently, only these three modes are implemented. Setting filterMode to-
1138 any other Qt::MatchFlag will issue a warning, and no action will be-
1139 performed.-
1140-
1141 The default mode is Qt::MatchStartsWith.-
1142*/-
1143-
1144void QCompleter::setFilterMode(Qt::MatchFlags filterMode)-
1145{-
1146 Q_D(QCompleter);-
1147-
1148 if (d->filterMode == filterMode)
d->filterMode == filterModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1149 return;
never executed: return;
0
1150-
1151 if (filterMode != Qt::MatchStartsWith
filterMode != ...atchStartsWithDescription
TRUEnever evaluated
FALSEnever evaluated
0
1152 && filterMode != Qt::MatchContains
filterMode != ...:MatchContainsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1153 && filterMode != Qt::MatchEndsWith) {
filterMode != ...:MatchEndsWithDescription
TRUEnever evaluated
FALSEnever evaluated
0
1154 qWarning("Unhandled QCompleter::filterMode flag is used.");-
1155 return;
never executed: return;
0
1156 }-
1157-
1158 d->filterMode = filterMode;-
1159 d->proxy->createEngine();-
1160 d->proxy->invalidate();-
1161}
never executed: end of block
0
1162-
1163Qt::MatchFlags QCompleter::filterMode() const-
1164{-
1165 Q_D(const QCompleter);-
1166 return d->filterMode;
never executed: return d->filterMode;
0
1167}-
1168-
1169/*!-
1170 Sets the popup used to display completions to \a popup. QCompleter takes-
1171 ownership of the view.-
1172-
1173 A QListView is automatically created when the completionMode() is set to-
1174 QCompleter::PopupCompletion or QCompleter::UnfilteredPopupCompletion. The-
1175 default popup displays the completionColumn().-
1176-
1177 Ensure that this function is called before the view settings are modified.-
1178 This is required since view's properties may require that a model has been-
1179 set on the view (for example, hiding columns in the view requires a model-
1180 to be set on the view).-
1181-
1182 \sa popup()-
1183*/-
1184void QCompleter::setPopup(QAbstractItemView *popup)-
1185{-
1186 Q_D(QCompleter);-
1187 Q_ASSERT(popup != 0);-
1188 if (d->popup) {
d->popupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1189 QObject::disconnect(d->popup->selectionModel(), 0, this, 0);-
1190 QObject::disconnect(d->popup, 0, this, 0);-
1191 }
never executed: end of block
0
1192 if (d->popup != popup)
d->popup != popupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1193 delete d->popup;
never executed: delete d->popup;
0
1194 if (popup->model() != d->proxy)
popup->model() != d->proxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1195 popup->setModel(d->proxy);
never executed: popup->setModel(d->proxy);
0
1196 popup->hide();-
1197-
1198 Qt::FocusPolicy origPolicy = Qt::NoFocus;-
1199 if (d->widget)
d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1200 origPolicy = d->widget->focusPolicy();
never executed: origPolicy = d->widget->focusPolicy();
0
1201 popup->setParent(0, Qt::Popup);-
1202 popup->setFocusPolicy(Qt::NoFocus);-
1203 if (d->widget)
d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1204 d->widget->setFocusPolicy(origPolicy);
never executed: d->widget->setFocusPolicy(origPolicy);
0
1205-
1206 popup->setFocusProxy(d->widget);-
1207 popup->installEventFilter(this);-
1208 popup->setItemDelegate(new QCompleterItemDelegate(popup));-
1209#ifndef QT_NO_LISTVIEW-
1210 if (QListView *listView = qobject_cast<QListView *>(popup)) {
QListView *lis...View *>(popup)Description
TRUEnever evaluated
FALSEnever evaluated
0
1211 listView->setModelColumn(d->column);-
1212 }
never executed: end of block
0
1213#endif-
1214-
1215 QObject::connect(popup, SIGNAL(clicked(QModelIndex)),-
1216 this, SLOT(_q_complete(QModelIndex)));-
1217 QObject::connect(this, SIGNAL(activated(QModelIndex)),-
1218 popup, SLOT(hide()));-
1219-
1220 QObject::connect(popup->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),-
1221 this, SLOT(_q_completionSelected(QItemSelection)));-
1222 d->popup = popup;-
1223}
never executed: end of block
0
1224-
1225/*!-
1226 Returns the popup used to display completions.-
1227-
1228 \sa setPopup()-
1229*/-
1230QAbstractItemView *QCompleter::popup() const-
1231{-
1232 Q_D(const QCompleter);-
1233#ifndef QT_NO_LISTVIEW-
1234 if (!d->popup && completionMode() != QCompleter::InlineCompletion) {
!d->popupDescription
TRUEnever evaluated
FALSEnever evaluated
completionMode...lineCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1235 QListView *listView = new QListView;-
1236 listView->setEditTriggers(QAbstractItemView::NoEditTriggers);-
1237 listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);-
1238 listView->setSelectionBehavior(QAbstractItemView::SelectRows);-
1239 listView->setSelectionMode(QAbstractItemView::SingleSelection);-
1240 listView->setModelColumn(d->column);-
1241 QCompleter *that = const_cast<QCompleter*>(this);-
1242 that->setPopup(listView);-
1243 }
never executed: end of block
0
1244#endif // QT_NO_LISTVIEW-
1245 return d->popup;
never executed: return d->popup;
0
1246}-
1247-
1248/*!-
1249 \reimp-
1250*/-
1251bool QCompleter::event(QEvent *ev)-
1252{-
1253 return QObject::event(ev);
never executed: return QObject::event(ev);
0
1254}-
1255-
1256/*!-
1257 \reimp-
1258*/-
1259bool QCompleter::eventFilter(QObject *o, QEvent *e)-
1260{-
1261 Q_D(QCompleter);-
1262-
1263 if (d->eatFocusOut && o == d->widget && e->type() == QEvent::FocusOut) {
d->eatFocusOutDescription
TRUEnever evaluated
FALSEnever evaluated
o == d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
e->type() == QEvent::FocusOutDescription
TRUEnever evaluated
FALSEnever evaluated
0
1264 d->hiddenBecauseNoMatch = false;-
1265 if (d->popup && d->popup->isVisible())
d->popupDescription
TRUEnever evaluated
FALSEnever evaluated
d->popup->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
1266 return true;
never executed: return true;
0
1267 }
never executed: end of block
0
1268-
1269 if (o != d->popup)
o != d->popupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1270 return QObject::eventFilter(o, e);
never executed: return QObject::eventFilter(o, e);
0
1271-
1272 switch (e->type()) {-
1273 case QEvent::KeyPress: {
never executed: case QEvent::KeyPress:
0
1274 QKeyEvent *ke = static_cast<QKeyEvent *>(e);-
1275-
1276 QModelIndex curIndex = d->popup->currentIndex();-
1277 QModelIndexList selList = d->popup->selectionModel()->selectedIndexes();-
1278-
1279 const int key = ke->key();-
1280 // In UnFilteredPopup mode, select the current item-
1281 if ((key == Qt::Key_Up || key == Qt::Key_Down) && selList.isEmpty() && curIndex.isValid()
key == Qt::Key_UpDescription
TRUEnever evaluated
FALSEnever evaluated
key == Qt::Key_DownDescription
TRUEnever evaluated
FALSEnever evaluated
selList.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
curIndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1282 && d->mode == QCompleter::UnfilteredPopupCompletion) {
d->mode == QCo...opupCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1283 d->setCurrentIndex(curIndex);-
1284 return true;
never executed: return true;
0
1285 }-
1286-
1287 // Handle popup navigation keys. These are hardcoded because up/down might make the-
1288 // widget do something else (lineedit cursor moves to home/end on mac, for instance)-
1289 switch (key) {-
1290 case Qt::Key_End:
never executed: case Qt::Key_End:
0
1291 case Qt::Key_Home:
never executed: case Qt::Key_Home:
0
1292 if (ke->modifiers() & Qt::ControlModifier)
ke->modifiers(...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
1293 return false;
never executed: return false;
0
1294 break;
never executed: break;
0
1295-
1296 case Qt::Key_Up:
never executed: case Qt::Key_Up:
0
1297 if (!curIndex.isValid()) {
!curIndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1298 int rowCount = d->proxy->rowCount();-
1299 QModelIndex lastIndex = d->proxy->index(rowCount - 1, d->column);-
1300 d->setCurrentIndex(lastIndex);-
1301 return true;
never executed: return true;
0
1302 } else if (curIndex.row() == 0) {
curIndex.row() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1303 if (d->wrap)
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
1304 d->setCurrentIndex(QModelIndex());
never executed: d->setCurrentIndex(QModelIndex());
0
1305 return true;
never executed: return true;
0
1306 }-
1307 return false;
never executed: return false;
0
1308-
1309 case Qt::Key_Down:
never executed: case Qt::Key_Down:
0
1310 if (!curIndex.isValid()) {
!curIndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1311 QModelIndex firstIndex = d->proxy->index(0, d->column);-
1312 d->setCurrentIndex(firstIndex);-
1313 return true;
never executed: return true;
0
1314 } else if (curIndex.row() == d->proxy->rowCount() - 1) {
curIndex.row()...rowCount() - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1315 if (d->wrap)
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
1316 d->setCurrentIndex(QModelIndex());
never executed: d->setCurrentIndex(QModelIndex());
0
1317 return true;
never executed: return true;
0
1318 }-
1319 return false;
never executed: return false;
0
1320-
1321 case Qt::Key_PageUp:
never executed: case Qt::Key_PageUp:
0
1322 case Qt::Key_PageDown:
never executed: case Qt::Key_PageDown:
0
1323 return false;
never executed: return false;
0
1324 }-
1325-
1326 // Send the event to the widget. If the widget accepted the event, do nothing-
1327 // If the widget did not accept the event, provide a default implementation-
1328 d->eatFocusOut = false;-
1329 (static_cast<QObject *>(d->widget))->event(ke);-
1330 d->eatFocusOut = true;-
1331 if (!d->widget || e->isAccepted() || !d->popup->isVisible()) {
!d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
e->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
!d->popup->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
1332 // widget lost focus, hide the popup-
1333 if (d->widget && (!d->widget->hasFocus()
d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
(!d->widget->hasFocus() )Description
TRUEnever evaluated
FALSEnever evaluated
0
1334#ifdef QT_KEYPAD_NAVIGATION
(!d->widget->hasFocus() )Description
TRUEnever evaluated
FALSEnever evaluated
0
1335 || (QApplication::keypadNavigationEnabled() && !d->widget->hasEditFocus())
(!d->widget->hasFocus() )Description
TRUEnever evaluated
FALSEnever evaluated
0
1336#endif
(!d->widget->hasFocus() )Description
TRUEnever evaluated
FALSEnever evaluated
0
1337 ))
(!d->widget->hasFocus() )Description
TRUEnever evaluated
FALSEnever evaluated
0
1338 d->popup->hide();
never executed: d->popup->hide();
0
1339 if (e->isAccepted())
e->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
1340 return true;
never executed: return true;
0
1341 }
never executed: end of block
0
1342-
1343 // default implementation for keys not handled by the widget when popup is open-
1344 if (ke->matches(QKeySequence::Cancel)) {
ke->matches(QK...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
0
1345 d->popup->hide();-
1346 return true;
never executed: return true;
0
1347 }-
1348-
1349 switch (key) {-
1350#ifdef QT_KEYPAD_NAVIGATION-
1351 case Qt::Key_Select:-
1352 if (!QApplication::keypadNavigationEnabled())-
1353 break;-
1354#endif-
1355 case Qt::Key_Return:
never executed: case Qt::Key_Return:
0
1356 case Qt::Key_Enter:
never executed: case Qt::Key_Enter:
0
1357 case Qt::Key_Tab:
never executed: case Qt::Key_Tab:
0
1358 d->popup->hide();-
1359 if (curIndex.isValid())
curIndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1360 d->_q_complete(curIndex);
never executed: d->_q_complete(curIndex);
0
1361 break;
never executed: break;
0
1362-
1363 case Qt::Key_F4:
never executed: case Qt::Key_F4:
0
1364 if (ke->modifiers() & Qt::AltModifier)
ke->modifiers(...t::AltModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
1365 d->popup->hide();
never executed: d->popup->hide();
0
1366 break;
never executed: break;
0
1367-
1368 case Qt::Key_Backtab:
never executed: case Qt::Key_Backtab:
0
1369 d->popup->hide();-
1370 break;
never executed: break;
0
1371-
1372 default:
never executed: default:
0
1373 break;
never executed: break;
0
1374 }-
1375-
1376 return true;
never executed: return true;
0
1377 }-
1378-
1379#ifdef QT_KEYPAD_NAVIGATION-
1380 case QEvent::KeyRelease: {-
1381 QKeyEvent *ke = static_cast<QKeyEvent *>(e);-
1382 if (QApplication::keypadNavigationEnabled() && ke->key() == Qt::Key_Back) {-
1383 // Send the event to the 'widget'. This is what we did for KeyPress, so we need-
1384 // to do the same for KeyRelease, in case the widget's KeyPress event set-
1385 // up something (such as a timer) that is relying on also receiving the-
1386 // key release. I see this as a bug in Qt, and should really set it up for all-
1387 // the affected keys. However, it is difficult to tell how this will affect-
1388 // existing code, and I can't test for every combination!-
1389 d->eatFocusOut = false;-
1390 static_cast<QObject *>(d->widget)->event(ke);-
1391 d->eatFocusOut = true;-
1392 }-
1393 break;-
1394 }-
1395#endif-
1396-
1397 case QEvent::MouseButtonPress: {
never executed: case QEvent::MouseButtonPress:
0
1398#ifdef QT_KEYPAD_NAVIGATION-
1399 if (QApplication::keypadNavigationEnabled()) {-
1400 // if we've clicked in the widget (or its descendant), let it handle the click-
1401 QWidget *source = qobject_cast<QWidget *>(o);-
1402 if (source) {-
1403 QPoint pos = source->mapToGlobal((static_cast<QMouseEvent *>(e))->pos());-
1404 QWidget *target = QApplication::widgetAt(pos);-
1405 if (target && (d->widget->isAncestorOf(target) ||-
1406 target == d->widget)) {-
1407 d->eatFocusOut = false;-
1408 static_cast<QObject *>(target)->event(e);-
1409 d->eatFocusOut = true;-
1410 return true;-
1411 }-
1412 }-
1413 }-
1414#endif-
1415 if (!d->popup->underMouse()) {
!d->popup->underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
0
1416 d->popup->hide();-
1417 return true;
never executed: return true;
0
1418 }-
1419 }-
1420 return false;
never executed: return false;
0
1421-
1422 case QEvent::InputMethod:
never executed: case QEvent::InputMethod:
0
1423 case QEvent::ShortcutOverride:
never executed: case QEvent::ShortcutOverride:
0
1424 QApplication::sendEvent(d->widget, e);-
1425 break;
never executed: break;
0
1426-
1427 default:
never executed: default:
0
1428 return false;
never executed: return false;
0
1429 }-
1430 return false;
never executed: return false;
0
1431}-
1432-
1433/*!-
1434 For QCompleter::PopupCompletion and QCompletion::UnfilteredPopupCompletion-
1435 modes, calling this function displays the popup displaying the current-
1436 completions. By default, if \a rect is not specified, the popup is displayed-
1437 on the bottom of the widget(). If \a rect is specified the popup is-
1438 displayed on the left edge of the rectangle.-
1439-
1440 For QCompleter::InlineCompletion mode, the highlighted() signal is fired-
1441 with the current completion.-
1442*/-
1443void QCompleter::complete(const QRect& rect)-
1444{-
1445 Q_D(QCompleter);-
1446 QModelIndex idx = d->proxy->currentIndex(false);-
1447 d->hiddenBecauseNoMatch = false;-
1448 if (d->mode == QCompleter::InlineCompletion) {
d->mode == QCo...lineCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1449 if (idx.isValid())
idx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1450 d->_q_complete(idx, true);
never executed: d->_q_complete(idx, true);
0
1451 return;
never executed: return;
0
1452 }-
1453-
1454 Q_ASSERT(d->widget != 0);-
1455 if ((d->mode == QCompleter::PopupCompletion && !idx.isValid())
d->mode == QCo...opupCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
!idx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1456 || (d->mode == QCompleter::UnfilteredPopupCompletion && d->proxy->rowCount() == 0)) {
d->mode == QCo...opupCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
d->proxy->rowCount() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1457 if (d->popup)
d->popupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1458 d->popup->hide(); // no suggestion, hide
never executed: d->popup->hide();
0
1459 d->hiddenBecauseNoMatch = true;-
1460 return;
never executed: return;
0
1461 }-
1462-
1463 popup();-
1464 if (d->mode == QCompleter::UnfilteredPopupCompletion)
d->mode == QCo...opupCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1465 d->setCurrentIndex(idx, false);
never executed: d->setCurrentIndex(idx, false);
0
1466-
1467 d->showPopup(rect);-
1468 d->popupRect = rect;-
1469}
never executed: end of block
0
1470-
1471/*!-
1472 Sets the current row to the \a row specified. Returns \c true if successful;-
1473 otherwise returns \c false.-
1474-
1475 This function may be used along with currentCompletion() to iterate-
1476 through all the possible completions.-
1477-
1478 \sa currentCompletion(), completionCount()-
1479*/-
1480bool QCompleter::setCurrentRow(int row)-
1481{-
1482 Q_D(QCompleter);-
1483 return d->proxy->setCurrentRow(row);
never executed: return d->proxy->setCurrentRow(row);
0
1484}-
1485-
1486/*!-
1487 Returns the current row.-
1488-
1489 \sa setCurrentRow()-
1490*/-
1491int QCompleter::currentRow() const-
1492{-
1493 Q_D(const QCompleter);-
1494 return d->proxy->currentRow();
never executed: return d->proxy->currentRow();
0
1495}-
1496-
1497/*!-
1498 Returns the number of completions for the current prefix. For an unsorted-
1499 model with a large number of items this can be expensive. Use setCurrentRow()-
1500 and currentCompletion() to iterate through all the completions.-
1501*/-
1502int QCompleter::completionCount() const-
1503{-
1504 Q_D(const QCompleter);-
1505 return d->proxy->completionCount();
never executed: return d->proxy->completionCount();
0
1506}-
1507-
1508/*!-
1509 \enum QCompleter::ModelSorting-
1510-
1511 This enum specifies how the items in the model are sorted.-
1512-
1513 \value UnsortedModel The model is unsorted.-
1514 \value CaseSensitivelySortedModel The model is sorted case sensitively.-
1515 \value CaseInsensitivelySortedModel The model is sorted case insensitively.-
1516-
1517 \sa setModelSorting()-
1518*/-
1519-
1520/*!-
1521 \property QCompleter::modelSorting-
1522 \brief the way the model is sorted-
1523-
1524 By default, no assumptions are made about the order of the items-
1525 in the model that provides the completions.-
1526-
1527 If the model's data for the completionColumn() and completionRole() is sorted in-
1528 ascending order, you can set this property to \l CaseSensitivelySortedModel-
1529 or \l CaseInsensitivelySortedModel. On large models, this can lead to-
1530 significant performance improvements because the completer object can-
1531 then use a binary search algorithm instead of linear search algorithm.-
1532-
1533 The sort order (i.e ascending or descending order) of the model is determined-
1534 dynamically by inspecting the contents of the model.-
1535-
1536 \b{Note:} The performance improvements described above cannot take place-
1537 when the completer's \l caseSensitivity is different to the case sensitivity-
1538 used by the model's when sorting.-
1539-
1540 \sa setCaseSensitivity(), QCompleter::ModelSorting-
1541*/-
1542void QCompleter::setModelSorting(QCompleter::ModelSorting sorting)-
1543{-
1544 Q_D(QCompleter);-
1545 if (d->sorting == sorting)
d->sorting == sortingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1546 return;
never executed: return;
0
1547 d->sorting = sorting;-
1548 d->proxy->createEngine();-
1549 d->proxy->invalidate();-
1550}
never executed: end of block
0
1551-
1552QCompleter::ModelSorting QCompleter::modelSorting() const-
1553{-
1554 Q_D(const QCompleter);-
1555 return d->sorting;
never executed: return d->sorting;
0
1556}-
1557-
1558/*!-
1559 \property QCompleter::completionColumn-
1560 \brief the column in the model in which completions are searched for.-
1561-
1562 If the popup() is a QListView, it is automatically setup to display-
1563 this column.-
1564-
1565 By default, the match column is 0.-
1566-
1567 \sa completionRole, caseSensitivity-
1568*/-
1569void QCompleter::setCompletionColumn(int column)-
1570{-
1571 Q_D(QCompleter);-
1572 if (d->column == column)
d->column == columnDescription
TRUEnever evaluated
FALSEnever evaluated
0
1573 return;
never executed: return;
0
1574#ifndef QT_NO_LISTVIEW-
1575 if (QListView *listView = qobject_cast<QListView *>(d->popup))
QListView *lis...w *>(d->popup)Description
TRUEnever evaluated
FALSEnever evaluated
0
1576 listView->setModelColumn(column);
never executed: listView->setModelColumn(column);
0
1577#endif-
1578 d->column = column;-
1579 d->proxy->invalidate();-
1580}
never executed: end of block
0
1581-
1582int QCompleter::completionColumn() const-
1583{-
1584 Q_D(const QCompleter);-
1585 return d->column;
never executed: return d->column;
0
1586}-
1587-
1588/*!-
1589 \property QCompleter::completionRole-
1590 \brief the item role to be used to query the contents of items for matching.-
1591-
1592 The default role is Qt::EditRole.-
1593-
1594 \sa completionColumn, caseSensitivity-
1595*/-
1596void QCompleter::setCompletionRole(int role)-
1597{-
1598 Q_D(QCompleter);-
1599 if (d->role == role)
d->role == roleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1600 return;
never executed: return;
0
1601 d->role = role;-
1602 d->proxy->invalidate();-
1603}
never executed: end of block
0
1604-
1605int QCompleter::completionRole() const-
1606{-
1607 Q_D(const QCompleter);-
1608 return d->role;
never executed: return d->role;
0
1609}-
1610-
1611/*!-
1612 \property QCompleter::wrapAround-
1613 \brief the completions wrap around when navigating through items-
1614 \since 4.3-
1615-
1616 The default is true.-
1617*/-
1618void QCompleter::setWrapAround(bool wrap)-
1619{-
1620 Q_D(QCompleter);-
1621 if (d->wrap == wrap)
d->wrap == wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
1622 return;
never executed: return;
0
1623 d->wrap = wrap;-
1624}
never executed: end of block
0
1625-
1626bool QCompleter::wrapAround() const-
1627{-
1628 Q_D(const QCompleter);-
1629 return d->wrap;
never executed: return d->wrap;
0
1630}-
1631-
1632/*!-
1633 \property QCompleter::maxVisibleItems-
1634 \brief the maximum allowed size on screen of the completer, measured in items-
1635 \since 4.6-
1636-
1637 By default, this property has a value of 7.-
1638*/-
1639int QCompleter::maxVisibleItems() const-
1640{-
1641 Q_D(const QCompleter);-
1642 return d->maxVisibleItems;
never executed: return d->maxVisibleItems;
0
1643}-
1644-
1645void QCompleter::setMaxVisibleItems(int maxItems)-
1646{-
1647 Q_D(QCompleter);-
1648 if (maxItems < 0) {
maxItems < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1649 qWarning("QCompleter::setMaxVisibleItems: "-
1650 "Invalid max visible items (%d) must be >= 0", maxItems);-
1651 return;
never executed: return;
0
1652 }-
1653 d->maxVisibleItems = maxItems;-
1654}
never executed: end of block
0
1655-
1656/*!-
1657 \property QCompleter::caseSensitivity-
1658 \brief the case sensitivity of the matching-
1659-
1660 The default is Qt::CaseSensitive.-
1661-
1662 \sa completionColumn, completionRole, modelSorting-
1663*/-
1664void QCompleter::setCaseSensitivity(Qt::CaseSensitivity cs)-
1665{-
1666 Q_D(QCompleter);-
1667 if (d->cs == cs)
d->cs == csDescription
TRUEnever evaluated
FALSEnever evaluated
0
1668 return;
never executed: return;
0
1669 d->cs = cs;-
1670 d->proxy->createEngine();-
1671 d->proxy->invalidate();-
1672}
never executed: end of block
0
1673-
1674Qt::CaseSensitivity QCompleter::caseSensitivity() const-
1675{-
1676 Q_D(const QCompleter);-
1677 return d->cs;
never executed: return d->cs;
0
1678}-
1679-
1680/*!-
1681 \property QCompleter::completionPrefix-
1682 \brief the completion prefix used to provide completions.-
1683-
1684 The completionModel() is updated to reflect the list of possible-
1685 matches for \a prefix.-
1686*/-
1687void QCompleter::setCompletionPrefix(const QString &prefix)-
1688{-
1689 Q_D(QCompleter);-
1690 d->prefix = prefix;-
1691 d->proxy->filter(splitPath(prefix));-
1692}
never executed: end of block
0
1693-
1694QString QCompleter::completionPrefix() const-
1695{-
1696 Q_D(const QCompleter);-
1697 return d->prefix;
never executed: return d->prefix;
0
1698}-
1699-
1700/*!-
1701 Returns the model index of the current completion in the completionModel().-
1702-
1703 \sa setCurrentRow(), currentCompletion(), model()-
1704*/-
1705QModelIndex QCompleter::currentIndex() const-
1706{-
1707 Q_D(const QCompleter);-
1708 return d->proxy->currentIndex(false);
never executed: return d->proxy->currentIndex(false);
0
1709}-
1710-
1711/*!-
1712 Returns the current completion string. This includes the \l completionPrefix.-
1713 When used alongside setCurrentRow(), it can be used to iterate through-
1714 all the matches.-
1715-
1716 \sa setCurrentRow(), currentIndex()-
1717*/-
1718QString QCompleter::currentCompletion() const-
1719{-
1720 Q_D(const QCompleter);-
1721 return pathFromIndex(d->proxy->currentIndex(true));
never executed: return pathFromIndex(d->proxy->currentIndex(true));
0
1722}-
1723-
1724/*!-
1725 Returns the completion model. The completion model is a read-only list model-
1726 that contains all the possible matches for the current completion prefix.-
1727 The completion model is auto-updated to reflect the current completions.-
1728-
1729 \note The return value of this function is defined to be an QAbstractItemModel-
1730 purely for generality. This actual kind of model returned is an instance of an-
1731 QAbstractProxyModel subclass.-
1732-
1733 \sa completionPrefix, model()-
1734*/-
1735QAbstractItemModel *QCompleter::completionModel() const-
1736{-
1737 Q_D(const QCompleter);-
1738 return d->proxy;
never executed: return d->proxy;
0
1739}-
1740-
1741/*!-
1742 Returns the path for the given \a index. The completer object uses this to-
1743 obtain the completion text from the underlying model.-
1744-
1745 The default implementation returns the \l{Qt::EditRole}{edit role} of the-
1746 item for list models. It returns the absolute file path if the model is a-
1747 QFileSystemModel.-
1748-
1749 \sa splitPath()-
1750*/-
1751-
1752QString QCompleter::pathFromIndex(const QModelIndex& index) const-
1753{-
1754 Q_D(const QCompleter);-
1755 if (!index.isValid())
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1756 return QString();
never executed: return QString();
0
1757-
1758 QAbstractItemModel *sourceModel = d->proxy->sourceModel();-
1759 if (!sourceModel)
!sourceModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1760 return QString();
never executed: return QString();
0
1761 bool isDirModel = false;-
1762 bool isFsModel = false;-
1763#ifndef QT_NO_DIRMODEL-
1764 isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0;-
1765#endif-
1766#ifndef QT_NO_FILESYSTEMMODEL-
1767 isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0;-
1768#endif-
1769 if (!isDirModel && !isFsModel)
!isDirModelDescription
TRUEnever evaluated
FALSEnever evaluated
!isFsModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1770 return sourceModel->data(index, d->role).toString();
never executed: return sourceModel->data(index, d->role).toString();
0
1771-
1772 QModelIndex idx = index;-
1773 QStringList list;-
1774 do {-
1775 QString t;-
1776 if (isDirModel)
isDirModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1777 t = sourceModel->data(idx, Qt::EditRole).toString();
never executed: t = sourceModel->data(idx, Qt::EditRole).toString();
0
1778#ifndef QT_NO_FILESYSTEMMODEL-
1779 else-
1780 t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString();
never executed: t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString();
0
1781#endif-
1782 list.prepend(t);-
1783 QModelIndex parent = idx.parent();-
1784 idx = parent.sibling(parent.row(), index.column());-
1785 } while (idx.isValid());
never executed: end of block
idx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1786-
1787#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)-
1788 if (list.count() == 1) // only the separator or some other text
list.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1789 return list[0];
never executed: return list[0];
0
1790 list[0].clear() ; // the join below will provide the separator-
1791#endif-
1792-
1793 return list.join(QDir::separator());
never executed: return list.join(QDir::separator());
0
1794}-
1795-
1796/*!-
1797 Splits the given \a path into strings that are used to match at each level-
1798 in the model().-
1799-
1800 The default implementation of splitPath() splits a file system path based on-
1801 QDir::separator() when the sourceModel() is a QFileSystemModel.-
1802-
1803 When used with list models, the first item in the returned list is used for-
1804 matching.-
1805-
1806 \sa pathFromIndex(), {Handling Tree Models}-
1807*/-
1808QStringList QCompleter::splitPath(const QString& path) const-
1809{-
1810 bool isDirModel = false;-
1811 bool isFsModel = false;-
1812#ifndef QT_NO_DIRMODEL-
1813 Q_D(const QCompleter);-
1814 isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0;-
1815#endif-
1816#ifndef QT_NO_FILESYSTEMMODEL-
1817#ifdef QT_NO_DIRMODEL-
1818 Q_D(const QCompleter);-
1819#endif-
1820 isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0;-
1821#endif-
1822-
1823 if ((!isDirModel && !isFsModel) || path.isEmpty())
!isDirModelDescription
TRUEnever evaluated
FALSEnever evaluated
!isFsModelDescription
TRUEnever evaluated
FALSEnever evaluated
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1824 return QStringList(completionPrefix());
never executed: return QStringList(completionPrefix());
0
1825-
1826 QString pathCopy = QDir::toNativeSeparators(path);-
1827#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)-
1828 if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\"))-
1829 return QStringList(pathCopy);-
1830 const bool startsWithDoubleSlash = pathCopy.startsWith(QLatin1String("\\\\"));-
1831 if (startsWithDoubleSlash)-
1832 pathCopy = pathCopy.mid(2);-
1833#endif-
1834-
1835 const QChar sep = QDir::separator();-
1836 QStringList parts = pathCopy.split(sep);-
1837-
1838#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)-
1839 if (startsWithDoubleSlash)-
1840 parts[0].prepend(QLatin1String("\\\\"));-
1841#else-
1842 if (pathCopy[0] == sep) // readd the "/" at the beginning as the split removed it
pathCopy[0] == sepDescription
TRUEnever evaluated
FALSEnever evaluated
0
1843 parts[0] = QLatin1Char('/');
never executed: parts[0] = QLatin1Char('/');
0
1844#endif-
1845-
1846 return parts;
never executed: return parts;
0
1847}-
1848-
1849/*!-
1850 \fn void QCompleter::activated(const QModelIndex& index)-
1851-
1852 This signal is sent when an item in the popup() is activated by the user.-
1853 (by clicking or pressing return). The item's \a index in the completionModel()-
1854 is given.-
1855-
1856*/-
1857-
1858/*!-
1859 \fn void QCompleter::activated(const QString &text)-
1860-
1861 This signal is sent when an item in the popup() is activated by the user (by-
1862 clicking or pressing return). The item's \a text is given.-
1863-
1864*/-
1865-
1866/*!-
1867 \fn void QCompleter::highlighted(const QModelIndex& index)-
1868-
1869 This signal is sent when an item in the popup() is highlighted by-
1870 the user. It is also sent if complete() is called with the completionMode()-
1871 set to QCompleter::InlineCompletion. The item's \a index in the completionModel()-
1872 is given.-
1873*/-
1874-
1875/*!-
1876 \fn void QCompleter::highlighted(const QString &text)-
1877-
1878 This signal is sent when an item in the popup() is highlighted by-
1879 the user. It is also sent if complete() is called with the completionMode()-
1880 set to QCompleter::InlineCompletion. The item's \a text is given.-
1881*/-
1882-
1883QT_END_NAMESPACE-
1884-
1885#include "moc_qcompleter.cpp"-
1886-
1887#include "moc_qcompleter_p.cpp"-
1888-
1889#endif // QT_NO_COMPLETER-
Source codeSwitch to Preprocessed file

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