qsqlquerymodel.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/sql/models/qsqlquerymodel.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7void QSqlQueryModelPrivate::prefetch(int limit)-
8{-
9 QSqlQueryModel * const q = q_func();-
10-
11 if (atEnd
atEndDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 388 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| limit <= bottom.row()
limit <= bottom.row()Description
TRUEnever evaluated
FALSEevaluated 388 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| bottom.column() == -1
bottom.column() == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QItemModel
FALSEevaluated 387 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-388
12 return;
executed 3 times by 2 tests: return;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
3
13-
14 QModelIndex newBottom;-
15 const int oldBottomRow = qMax(bottom.row(), 0);-
16-
17-
18 if (query.seek(limit)
query.seek(limit)Description
TRUEevaluated 130 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 257 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
130-257
19 newBottom = q->createIndex(limit, bottom.column());-
20 }
executed 130 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
else {
130
21-
22 int i = oldBottomRow;-
23 if (query.seek(i)
query.seek(i)Description
TRUEevaluated 246 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
) {
11-246
24 while (query.next()
query.next()Description
TRUEevaluated 526 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 246 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
246-526
25 ++
executed 526 times by 4 tests: ++i;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
i;
executed 526 times by 4 tests: ++i;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
526
26 newBottom = q->createIndex(i, bottom.column());-
27 }
executed 246 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
else {
246
28-
29 newBottom = q->createIndex(-1, bottom.column());-
30 }
executed 11 times by 2 tests: end of block
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
11
31 atEnd = true;-
32 }
executed 257 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
257
33 if (newBottom.row() >= 0
newBottom.row() >= 0Description
TRUEevaluated 376 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
&& newBottom.row() > bottom.row()
newBottom.row() > bottom.row()Description
TRUEevaluated 376 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
) {
0-376
34 q->beginInsertRows(QModelIndex(), bottom.row() + 1, newBottom.row());-
35 bottom = newBottom;-
36 q->endInsertRows();-
37 }
executed 376 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
else {
376
38 bottom = newBottom;-
39 }
executed 11 times by 2 tests: end of block
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
11
40}-
41-
42QSqlQueryModelPrivate::~QSqlQueryModelPrivate()-
43{-
44}-
45-
46void QSqlQueryModelPrivate::initColOffsets(int size)-
47{-
48 colOffsets.resize(size);-
49 memset(colOffsets.data(), 0, colOffsets.size() * sizeof(int));-
50}
executed 438 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
438
51-
52int QSqlQueryModelPrivate::columnInQuery(int modelColumn) const-
53{-
54 if (modelColumn < 0
modelColumn < 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 3254 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| modelColumn >= rec.count()
modelColumn >= rec.count()Description
TRUEnever evaluated
FALSEevaluated 3254 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| !rec.isGenerated(modelColumn)
!rec.isGenerated(modelColumn)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 3242 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| modelColumn >= colOffsets.size()
modelColumn >=...Offsets.size()Description
TRUEnever evaluated
FALSEevaluated 3242 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-3254
55 return
executed 27 times by 1 test: return -1;
Executed by:
  • tst_QSqlQueryModel
-1;
executed 27 times by 1 test: return -1;
Executed by:
  • tst_QSqlQueryModel
27
56 return
executed 3242 times by 4 tests: return modelColumn - colOffsets[modelColumn];
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
modelColumn - colOffsets[modelColumn];
executed 3242 times by 4 tests: return modelColumn - colOffsets[modelColumn];
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
3242
57}-
58QSqlQueryModel::QSqlQueryModel(QObject *parent)-
59 : QAbstractTableModel(*new QSqlQueryModelPrivate, parent)-
60{-
61}
executed 113 times by 2 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
113
62-
63-
64-
65QSqlQueryModel::QSqlQueryModel(QSqlQueryModelPrivate &dd, QObject *parent)-
66 : QAbstractTableModel(dd, parent)-
67{-
68}
executed 174 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
174
69-
70-
71-
72-
73-
74-
75QSqlQueryModel::~QSqlQueryModel()-
76{-
77}-
78void QSqlQueryModel::fetchMore(const QModelIndex &parent)-
79{-
80 QSqlQueryModelPrivate * const d = d_func();-
81 if (parent.isValid()
parent.isValid()Description
TRUEnever evaluated
FALSEevaluated 390 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-390
82 return;
never executed: return;
0
83 d->prefetch(qMax(d->bottom.row(), 0) + 255);-
84}
executed 390 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
390
85bool QSqlQueryModel::canFetchMore(const QModelIndex &parent) const-
86{-
87 const QSqlQueryModelPrivate * const d = d_func();-
88 return
executed 1029 times by 2 tests: return (!parent.isValid() && !d->atEnd);
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
(!parent.isValid() && !d->atEnd);
executed 1029 times by 2 tests: return (!parent.isValid() && !d->atEnd);
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
1029
89}-
90-
91-
92-
93void QSqlQueryModel::beginInsertRows(const QModelIndex &parent, int first, int last)-
94{-
95 QSqlQueryModelPrivate * const d = d_func();-
96 if (!d->nestedResetLevel
!d->nestedResetLevelDescription
TRUEevaluated 85 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 364 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
85-364
97 QAbstractTableModel::beginInsertRows(parent, first, last);
executed 85 times by 4 tests: QAbstractTableModel::beginInsertRows(parent, first, last);
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
85
98}
executed 449 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
449
99-
100-
101-
102void QSqlQueryModel::endInsertRows()-
103{-
104 QSqlQueryModelPrivate * const d = d_func();-
105 if (!d->nestedResetLevel
!d->nestedResetLevelDescription
TRUEevaluated 85 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 364 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
85-364
106 QAbstractTableModel::endInsertRows();
executed 85 times by 4 tests: QAbstractTableModel::endInsertRows();
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
85
107}
executed 449 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
449
108-
109-
110-
111void QSqlQueryModel::beginRemoveRows(const QModelIndex &parent, int first, int last)-
112{-
113 QSqlQueryModelPrivate * const d = d_func();-
114 if (!d->nestedResetLevel
!d->nestedResetLevelDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-32
115 QAbstractTableModel::beginRemoveRows(parent, first, last);
executed 32 times by 2 tests: QAbstractTableModel::beginRemoveRows(parent, first, last);
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
32
116}
executed 32 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
32
117-
118-
119-
120void QSqlQueryModel::endRemoveRows()-
121{-
122 QSqlQueryModelPrivate * const d = d_func();-
123 if (!d->nestedResetLevel
!d->nestedResetLevelDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-32
124 QAbstractTableModel::endRemoveRows();
executed 32 times by 2 tests: QAbstractTableModel::endRemoveRows();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
32
125}
executed 32 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
32
126-
127-
128-
129void QSqlQueryModel::beginInsertColumns(const QModelIndex &parent, int first, int last)-
130{-
131 QSqlQueryModelPrivate * const d = d_func();-
132 if (!d->nestedResetLevel
!d->nestedResetLevelDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-10
133 QAbstractTableModel::beginInsertColumns(parent, first, last);
executed 10 times by 2 tests: QAbstractTableModel::beginInsertColumns(parent, first, last);
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
10
134}
executed 10 times by 2 tests: end of block
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
10
135-
136-
137-
138void QSqlQueryModel::endInsertColumns()-
139{-
140 QSqlQueryModelPrivate * const d = d_func();-
141 if (!d->nestedResetLevel
!d->nestedResetLevelDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-10
142 QAbstractTableModel::endInsertColumns();
executed 10 times by 2 tests: QAbstractTableModel::endInsertColumns();
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
10
143}
executed 10 times by 2 tests: end of block
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
10
144-
145-
146-
147void QSqlQueryModel::beginRemoveColumns(const QModelIndex &parent, int first, int last)-
148{-
149 QSqlQueryModelPrivate * const d = d_func();-
150 if (!d->nestedResetLevel
!d->nestedResetLevelDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEnever evaluated
)
0-4
151 QAbstractTableModel::beginRemoveColumns(parent, first, last);
executed 4 times by 1 test: QAbstractTableModel::beginRemoveColumns(parent, first, last);
Executed by:
  • tst_QSqlQueryModel
4
152}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QSqlQueryModel
4
153-
154-
155-
156void QSqlQueryModel::endRemoveColumns()-
157{-
158 QSqlQueryModelPrivate * const d = d_func();-
159 if (!d->nestedResetLevel
!d->nestedResetLevelDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEnever evaluated
)
0-4
160 QAbstractTableModel::endRemoveColumns();
executed 4 times by 1 test: QAbstractTableModel::endRemoveColumns();
Executed by:
  • tst_QSqlQueryModel
4
161}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QSqlQueryModel
4
162-
163-
164-
165void QSqlQueryModel::beginResetModel()-
166{-
167 QSqlQueryModelPrivate * const d = d_func();-
168 if (!d->nestedResetLevel
!d->nestedResetLevelDescription
TRUEevaluated 574 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 538 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
538-574
169 QAbstractTableModel::beginResetModel();
executed 574 times by 4 tests: QAbstractTableModel::beginResetModel();
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
574
170 ++d->nestedResetLevel;-
171}
executed 1112 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
1112
172-
173-
174-
175void QSqlQueryModel::endResetModel()-
176{-
177 QSqlQueryModelPrivate * const d = d_func();-
178 --d->nestedResetLevel;-
179 if (!d->nestedResetLevel
!d->nestedResetLevelDescription
TRUEevaluated 574 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 538 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
538-574
180 QAbstractTableModel::endResetModel();
executed 574 times by 4 tests: QAbstractTableModel::endResetModel();
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
574
181}
executed 1112 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
1112
182int QSqlQueryModel::rowCount(const QModelIndex &index) const-
183{-
184 const QSqlQueryModelPrivate * const d = d_func();-
185 return
executed 22178 times by 4 tests: return index.isValid() ? 0 : d->bottom.row() + 1;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
index.isValid() ? 0 : d->bottom.row() + 1;
executed 22178 times by 4 tests: return index.isValid() ? 0 : d->bottom.row() + 1;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
22178
186}-
187-
188-
189-
190int QSqlQueryModel::columnCount(const QModelIndex &index) const-
191{-
192 const QSqlQueryModelPrivate * const d = d_func();-
193 return
executed 20241 times by 4 tests: return index.isValid() ? 0 : d->rec.count();
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
index.isValid() ? 0 : d->rec.count();
executed 20241 times by 4 tests: return index.isValid() ? 0 : d->rec.count();
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
20241
194}-
195QVariant QSqlQueryModel::data(const QModelIndex &item, int role) const-
196{-
197 const QSqlQueryModelPrivate * const d = d_func();-
198 if (!item.isValid()
!item.isValid()Description
TRUEevaluated 519 times by 2 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
FALSEevaluated 3240 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
519-3240
199 return
executed 519 times by 2 tests: return QVariant();
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
QVariant();
executed 519 times by 2 tests: return QVariant();
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
519
200-
201 QVariant v;-
202 if (role & ~(Qt::DisplayRole | Qt::EditRole)
role & ~(Qt::D... Qt::EditRole)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QItemModel
FALSEevaluated 3231 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
9-3231
203 return
executed 9 times by 1 test: return v;
Executed by:
  • tst_QItemModel
v;
executed 9 times by 1 test: return v;
Executed by:
  • tst_QItemModel
9
204-
205 if (!d->rec.isGenerated(item.column())
!d->rec.isGene...item.column())Description
TRUEevaluated 20 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 3211 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
20-3211
206 return
executed 20 times by 2 tests: return v;
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
v;
executed 20 times by 2 tests: return v;
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
20
207 QModelIndex dItem = indexInQuery(item);-
208 if (dItem.row() > d->bottom.row()
dItem.row() > d->bottom.row()Description
TRUEnever evaluated
FALSEevaluated 3211 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-3211
209 const_cast<
never executed: const_cast<QSqlQueryModelPrivate *>(d)->prefetch(dItem.row());
QSqlQueryModelPrivate *>(d)->prefetch(dItem.row());
never executed: const_cast<QSqlQueryModelPrivate *>(d)->prefetch(dItem.row());
0
210-
211 if (!d->query.seek(dItem.row())
!d->query.seek(dItem.row())Description
TRUEnever evaluated
FALSEevaluated 3211 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
0-3211
212 d->error = d->query.lastError();-
213 return
never executed: return v;
v;
never executed: return v;
0
214 }-
215-
216 return
executed 3211 times by 4 tests: return d->query.value(dItem.column());
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
d->query.value(dItem.column());
executed 3211 times by 4 tests: return d->query.value(dItem.column());
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
3211
217}-
218-
219-
220-
221-
222-
223QVariant QSqlQueryModel::headerData(int section, Qt::Orientation orientation, int role) const-
224{-
225 const QSqlQueryModelPrivate * const d = d_func();-
226 if (orientation == Qt::Horizontal
orientation == Qt::HorizontalDescription
TRUEevaluated 32 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 1601 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
) {
32-1601
227 QVariant val = d->headers.value(section).value(role);-
228 if (role == Qt::DisplayRole
role == Qt::DisplayRoleDescription
TRUEevaluated 27 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
&& !val.isValid()
!val.isValid()Description
TRUEevaluated 27 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-27
229 val = d->headers.value(section).value(Qt::EditRole);
executed 27 times by 3 tests: val = d->headers.value(section).value(Qt::EditRole);
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
27
230 if (val.isValid()
val.isValid()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 30 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
)
2-30
231 return
executed 2 times by 1 test: return val;
Executed by:
  • tst_QSqlQueryModel
val;
executed 2 times by 1 test: return val;
Executed by:
  • tst_QSqlQueryModel
2
232 if (role == Qt::DisplayRole
role == Qt::DisplayRoleDescription
TRUEevaluated 25 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
&& d->rec.count() > section
d->rec.count() > sectionDescription
TRUEevaluated 20 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
&& d->columnInQuery(section) != -1
d->columnInQue...section) != -1Description
TRUEevaluated 16 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
)
4-25
233 return
executed 16 times by 3 tests: return d->rec.fieldName(section);
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
d->rec.fieldName(section);
executed 16 times by 3 tests: return d->rec.fieldName(section);
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
16
234 }
executed 14 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
14
235 return
executed 1615 times by 3 tests: return QAbstractItemModel::headerData(section, orientation, role);
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
QAbstractItemModel::headerData(section, orientation, role);
executed 1615 times by 3 tests: return QAbstractItemModel::headerData(section, orientation, role);
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
1615
236}-
237void QSqlQueryModel::queryChange()-
238{-
239-
240}-
241void QSqlQueryModel::setQuery(const QSqlQuery &query)-
242{-
243 QSqlQueryModelPrivate * const d = d_func();-
244 beginResetModel();-
245-
246 QSqlRecord newRec = query.record();-
247 bool columnsChanged = (newRec != d->rec);-
248-
249 if (d->colOffsets.size() != newRec.count()
d->colOffsets....newRec.count()Description
TRUEevaluated 66 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 316 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| columnsChanged
columnsChangedDescription
TRUEevaluated 187 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 129 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
66-316
250 d->initColOffsets(newRec.count());
executed 253 times by 4 tests: d->initColOffsets(newRec.count());
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
253
251-
252 d->bottom = QModelIndex();-
253 d->error = QSqlError();-
254 d->query = query;-
255 d->rec = newRec;-
256 d->atEnd = true;-
257-
258 if (query.isForwardOnly()
query.isForwardOnly()Description
TRUEnever evaluated
FALSEevaluated 382 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
0-382
259 d->error = QSqlError(QLatin1String("Forward-only queries "-
260 "cannot be used in a data model"),-
261 QString(), QSqlError::ConnectionError);-
262 endResetModel();-
263 return;
never executed: return;
0
264 }-
265-
266 if (!query.isActive()
!query.isActive()Description
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 375 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
7-375
267 d->error = query.lastError();-
268 endResetModel();-
269 return;
executed 7 times by 2 tests: return;
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
7
270 }-
271-
272 if (query.driver()->hasFeature(QSqlDriver::QuerySize)
query.driver()...er::QuerySize)Description
TRUEnever evaluated
FALSEevaluated 375 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
&& d->query.size() > 0
d->query.size() > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0-375
273 d->bottom = createIndex(d->query.size() - 1, d->rec.count() - 1);-
274 }
never executed: end of block
else {
0
275 d->bottom = createIndex(-1, d->rec.count() - 1);-
276 d->atEnd = false;-
277 }
executed 375 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
375
278-
279-
280-
281 fetchMore();-
282-
283 endResetModel();-
284 queryChange();-
285}
executed 375 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
375
286void QSqlQueryModel::setQuery(const QString &query, const QSqlDatabase &db)-
287{-
288 setQuery(QSqlQuery(query, db));-
289}
executed 57 times by 2 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
57
290-
291-
292-
293-
294void QSqlQueryModel::clear()-
295{-
296 QSqlQueryModelPrivate * const d = d_func();-
297 beginResetModel();-
298 d->error = QSqlError();-
299 d->atEnd = true;-
300 d->query.clear();-
301 d->rec.clear();-
302 d->colOffsets.clear();-
303 d->bottom = QModelIndex();-
304 d->headers.clear();-
305 endResetModel();-
306}
executed 191 times by 4 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
191
307bool QSqlQueryModel::setHeaderData(int section, Qt::Orientation orientation,-
308 const QVariant &value, int role)-
309{-
310 QSqlQueryModelPrivate * const d = d_func();-
311 if (orientation != Qt::Horizontal
orientation != Qt::HorizontalDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
FALSEevaluated 18 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
|| section < 0
section < 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QItemModel
FALSEevaluated 12 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
|| columnCount() <= section
columnCount() <= sectionDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
FALSEevaluated 6 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
)
4-18
312 return
executed 16 times by 2 tests: return false;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
false;
executed 16 times by 2 tests: return false;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
16
313-
314 if (d->headers.size() <= section
d->headers.size() <= sectionDescription
TRUEevaluated 4 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
2-4
315 d->headers.resize(qMax(section + 1, 16));
executed 4 times by 3 tests: d->headers.resize(qMax(section + 1, 16));
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
4
316 d->headers[section][role] = value;-
317 headerDataChanged(orientation, section, section);-
318 return
executed 6 times by 3 tests: return true;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
true;
executed 6 times by 3 tests: return true;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
6
319}-
320-
321-
322-
323-
324-
325-
326QSqlQuery QSqlQueryModel::query() const-
327{-
328 const QSqlQueryModelPrivate * const d = d_func();-
329 return
never executed: return d->query;
d->query;
never executed: return d->query;
0
330}-
331-
332-
333-
334-
335-
336-
337-
338QSqlError QSqlQueryModel::lastError() const-
339{-
340 const QSqlQueryModelPrivate * const d = d_func();-
341 return
executed 796 times by 4 tests: return d->error;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
d->error;
executed 796 times by 4 tests: return d->error;
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
796
342}-
343-
344-
345-
346-
347-
348-
349-
350void QSqlQueryModel::setLastError(const QSqlError &error)-
351{-
352 QSqlQueryModelPrivate * const d = d_func();-
353 d->error = error;-
354}
never executed: end of block
0
355QSqlRecord QSqlQueryModel::record(int row) const-
356{-
357 const QSqlQueryModelPrivate * const d = d_func();-
358 if (row < 0
row < 0Description
TRUEnever evaluated
FALSEevaluated 250 times by 3 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-250
359 return
never executed: return d->rec;
d->rec;
never executed: return d->rec;
0
360-
361 QSqlRecord rec = d->rec;-
362 for (int i = 0; i < rec.count()
i < rec.count()Description
TRUEevaluated 606 times by 3 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 250 times by 3 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i)
250-606
363 rec.setValue(i, data(createIndex(row, i), Qt::EditRole));
executed 606 times by 3 tests: rec.setValue(i, data(createIndex(row, i), Qt::EditRole));
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
606
364 return
executed 250 times by 3 tests: return rec;
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
rec;
executed 250 times by 3 tests: return rec;
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
250
365}-
366QSqlRecord QSqlQueryModel::record() const-
367{-
368 const QSqlQueryModelPrivate * const d = d_func();-
369 return
executed 21 times by 3 tests: return d->rec;
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
d->rec;
executed 21 times by 3 tests: return d->rec;
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
21
370}-
371bool QSqlQueryModel::insertColumns(int column, int count, const QModelIndex &parent)-
372{-
373 QSqlQueryModelPrivate * const d = d_func();-
374 if (count <= 0
count <= 0Description
TRUEnever evaluated
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
|| parent.isValid()
parent.isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 13 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
|| column < 0
column < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
|| column > d->rec.count()
column > d->rec.count()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
)
0-14
375 return
executed 4 times by 1 test: return false;
Executed by:
  • tst_QSqlQueryModel
false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_QSqlQueryModel
4
376-
377 beginInsertColumns(parent, column, column + count - 1);-
378 for (int c = 0; c < count
c < countDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
; ++c) {
10
379 QSqlField field;-
380 field.setReadOnly(true);-
381 field.setGenerated(false);-
382 d->rec.insert(column, field);-
383 if (d->colOffsets.size() < d->rec.count()
d->colOffsets....d->rec.count()Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlQueryModel
) {
1-9
384 int nVal = d->colOffsets.isEmpty()
d->colOffsets.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
? 0 : d->colOffsets[d->colOffsets.size() - 1];
0-9
385 d->colOffsets.append(nVal);-
386 ((!(d->colOffsets.size() >= d->rec.count())) ? qt_assert("d->colOffsets.size() >= d->rec.count()",__FILE__,621) : qt_noop());-
387 }
executed 9 times by 2 tests: end of block
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
9
388 for (int i = column + 1; i < d->colOffsets.count()
i < d->colOffsets.count()Description
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
; ++i)
10-22
389 ++
executed 22 times by 2 tests: ++d->colOffsets[i];
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
d->colOffsets[i];
executed 22 times by 2 tests: ++d->colOffsets[i];
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
22
390 }
executed 10 times by 2 tests: end of block
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
10
391 endInsertColumns();-
392 return
executed 10 times by 2 tests: return true;
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
true;
executed 10 times by 2 tests: return true;
Executed by:
  • tst_QSqlQueryModel
  • tst_QSqlTableModel
10
393}-
394bool QSqlQueryModel::removeColumns(int column, int count, const QModelIndex &parent)-
395{-
396 QSqlQueryModelPrivate * const d = d_func();-
397 if (count <= 0
count <= 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
|| parent.isValid()
parent.isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
|| column < 0
column < 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
|| column >= d->rec.count()
column >= d->rec.count()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
)
0-7
398 return
executed 3 times by 1 test: return false;
Executed by:
  • tst_QSqlQueryModel
false;
executed 3 times by 1 test: return false;
Executed by:
  • tst_QSqlQueryModel
3
399-
400 beginRemoveColumns(parent, column, column + count - 1);-
401-
402 int i;-
403 for (i = 0; i < count
i < countDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
; ++i)
4
404 d->rec.remove(column);
executed 4 times by 1 test: d->rec.remove(column);
Executed by:
  • tst_QSqlQueryModel
4
405 for (i = column; i < d->colOffsets.count()
i < d->colOffsets.count()Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
; ++i)
4-9
406 d->colOffsets[i] -= count;
executed 9 times by 1 test: d->colOffsets[i] -= count;
Executed by:
  • tst_QSqlQueryModel
9
407-
408 endRemoveColumns();-
409 return
executed 4 times by 1 test: return true;
Executed by:
  • tst_QSqlQueryModel
true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_QSqlQueryModel
4
410}-
411QModelIndex QSqlQueryModel::indexInQuery(const QModelIndex &item) const-
412{-
413 const QSqlQueryModelPrivate * const d = d_func();-
414 int modelColumn = d->columnInQuery(item.column());-
415 if (modelColumn < 0
modelColumn < 0Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • tst_QSqlQueryModel
FALSEevaluated 3226 times by 4 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
23-3226
416 return
executed 23 times by 1 test: return QModelIndex();
Executed by:
  • tst_QSqlQueryModel
QModelIndex();
executed 23 times by 1 test: return QModelIndex();
Executed by:
  • tst_QSqlQueryModel
23
417 return
executed 3226 times by 4 tests: return createIndex(item.row(), modelColumn, item.internalPointer());
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
createIndex(item.row(), modelColumn, item.internalPointer());
executed 3226 times by 4 tests: return createIndex(item.row(), modelColumn, item.internalPointer());
Executed by:
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
3226
418}-
419-
420-
Switch to Source codePreprocessed file

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