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