qsqltablemodel.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/sql/models/qsqltablemodel.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7typedef QSqlTableModelSql Sql;-
8-
9-
10-
11-
12QSqlRecord QSqlTableModelPrivate::record(const QVector<QVariant> &values) const-
13{-
14 QSqlRecord r = rec;-
15 for (int i = 0; i < r.count()
i < r.count()Description
TRUEnever evaluated
FALSEnever evaluated
&& i < values.count()
i < values.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
16 r.setValue(i, values.at(i));
never executed: r.setValue(i, values.at(i));
0
17 return
never executed: return r;
r;
never executed: return r;
0
18}-
19-
20int QSqlTableModelPrivate::nameToIndex(const QString &name) const-
21{-
22 return
executed 116 times by 2 tests: return rec.indexOf(strippedFieldName(name));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
rec.indexOf(strippedFieldName(name));
executed 116 times by 2 tests: return rec.indexOf(strippedFieldName(name));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
116
23}-
24-
25QString QSqlTableModelPrivate::strippedFieldName(const QString &name) const-
26{-
27 QString fieldname = name;-
28 if (db.driver()->isIdentifierEscaped(fieldname, QSqlDriver::FieldName)
db.driver()->i...er::FieldName)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlRelationalTableModel
FALSEevaluated 129 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
4-129
29 fieldname = db.driver()->stripDelimiters(fieldname, QSqlDriver::FieldName);
executed 4 times by 1 test: fieldname = db.driver()->stripDelimiters(fieldname, QSqlDriver::FieldName);
Executed by:
  • tst_QSqlRelationalTableModel
4
30 return
executed 133 times by 2 tests: return fieldname;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
fieldname;
executed 133 times by 2 tests: return fieldname;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
133
31}-
32-
33int QSqlTableModelPrivate::insertCount(int maxRow) const-
34{-
35 int cnt = 0;-
36 CacheMap::ConstIterator i = cache.constBegin();-
37 const CacheMap::ConstIterator e = cache.constEnd();-
38 for ( ; i != e
i != eDescription
TRUEevaluated 2172 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 12805 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
&& (maxRow < 0
maxRow < 0Description
TRUEevaluated 1714 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 458 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| i.key() <= maxRow
i.key() <= maxRowDescription
TRUEevaluated 380 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 78 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
); ++i)
78-12805
39 if (i.value().insert()
i.value().insert()Description
TRUEevaluated 1278 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 816 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
816-1278
40 ++
executed 1278 times by 2 tests: ++cnt;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
cnt;
executed 1278 times by 2 tests: ++cnt;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
1278
41-
42 return
executed 12883 times by 3 tests: return cnt;
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
cnt;
executed 12883 times by 3 tests: return cnt;
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
12883
43}-
44-
45void QSqlTableModelPrivate::initRecordAndPrimaryIndex()-
46{-
47 rec = db.record(tableName);-
48 primaryIndex = db.primaryIndex(tableName);-
49 initColOffsets(rec.count());-
50}
executed 185 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
185
51-
52void QSqlTableModelPrivate::clear()-
53{-
54 sortColumn = -1;-
55 sortOrder = Qt::AscendingOrder;-
56 tableName.clear();-
57 editQuery.clear();-
58 cache.clear();-
59 primaryIndex.clear();-
60 rec.clear();-
61 filter.clear();-
62}
executed 190 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
190
63-
64void QSqlTableModelPrivate::clearCache()-
65{-
66 cache.clear();-
67}
executed 315 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
315
68-
69void QSqlTableModelPrivate::revertCachedRow(int row)-
70{-
71 QSqlTableModel * const q = q_func();-
72 ModifiedRow r = cache.value(row);-
73-
74 switch (r.op()) {-
75 case
never executed: case QSqlTableModelPrivate::None:
QSqlTableModelPrivate::None:
never executed: case QSqlTableModelPrivate::None:
0
76 ((!(false)) ? qt_assert_x("QSqlTableModelPrivate::revertCachedRow()", "Invalid entry in cache map",__FILE__,125) : qt_noop());-
77 return;
never executed: return;
0
78 case
executed 17 times by 2 tests: case QSqlTableModelPrivate::Update:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QSqlTableModelPrivate::Update:
executed 17 times by 2 tests: case QSqlTableModelPrivate::Update:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
17
79 case
executed 3 times by 1 test: case QSqlTableModelPrivate::Delete:
Executed by:
  • tst_QSqlTableModel
QSqlTableModelPrivate::Delete:
executed 3 times by 1 test: case QSqlTableModelPrivate::Delete:
Executed by:
  • tst_QSqlTableModel
3
80 if (!r.submitted()
!r.submitted()Description
TRUEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlRelationalTableModel
) {
3-17
81 cache[row].revert();-
82 q->dataChanged(q->createIndex(row, 0),-
83 q->createIndex(row, q->columnCount() - 1));-
84 }
executed 17 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
17
85 break;
executed 20 times by 2 tests: break;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
20
86 case
executed 32 times by 2 tests: case QSqlTableModelPrivate::Insert:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QSqlTableModelPrivate::Insert:
executed 32 times by 2 tests: case QSqlTableModelPrivate::Insert:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
{
32
87 QMap<int, QSqlTableModelPrivate::ModifiedRow>::Iterator it = cache.find(row);-
88 if (it == cache.end()
it == cache.end()Description
TRUEnever evaluated
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-32
89 return;
never executed: return;
0
90 q->beginRemoveRows(QModelIndex(), row, row);-
91 it = cache.erase(it);-
92 while (it != cache.end()
it != cache.end()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
5-32
93 int oldKey = it.key();-
94 const QSqlTableModelPrivate::ModifiedRow oldValue = it.value();-
95 cache.erase(it);-
96 it = cache.insert(oldKey - 1, oldValue);-
97 ++it;-
98 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QSqlTableModel
5
99 q->endRemoveRows();-
100 break;
executed 32 times by 2 tests: break;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
}
32
101 }-
102}
executed 52 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
52
103-
104bool QSqlTableModelPrivate::exec(const QString &stmt, bool prepStatement,-
105 const QSqlRecord &rec, const QSqlRecord &whereValues)-
106{-
107 if (stmt.isEmpty()
stmt.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 123 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-123
108 return
never executed: return false;
false;
never executed: return false;
0
109-
110-
111 if (editQuery.driver() != db.driver()
editQuery.driv...!= db.driver()Description
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
51-72
112 editQuery = QSqlQuery(db);
executed 51 times by 2 tests: editQuery = QSqlQuery(db);
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
51
113-
114-
115-
116 if (db.driver()->hasFeature(QSqlDriver::SimpleLocking)
db.driver()->h...SimpleLocking)Description
TRUEevaluated 123 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-123
117 const_cast<
executed 123 times by 2 tests: const_cast<QSqlResult *>(query.result())->detachFromResultSet();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QSqlResult *>(query.result())->detachFromResultSet();
executed 123 times by 2 tests: const_cast<QSqlResult *>(query.result())->detachFromResultSet();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
123
118-
119 if (prepStatement
prepStatementDescription
TRUEevaluated 123 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
) {
0-123
120 if (editQuery.lastQuery() != stmt
editQuery.lastQuery() != stmtDescription
TRUEevaluated 79 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 44 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
44-79
121 if (!editQuery.prepare(stmt)
!editQuery.prepare(stmt)Description
TRUEnever evaluated
FALSEevaluated 79 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
0-79
122 error = editQuery.lastError();-
123 return
never executed: return false;
false;
never executed: return false;
0
124 }-
125 }
executed 79 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
79
126 int i;-
127 for (i = 0; i < rec.count()
i < rec.count()Description
TRUEevaluated 298 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 123 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i)
123-298
128 if (rec.isGenerated(i)
rec.isGenerated(i)Description
TRUEevaluated 192 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 106 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
106-192
129 editQuery.addBindValue(rec.value(i));
executed 192 times by 2 tests: editQuery.addBindValue(rec.value(i));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
192
130 for (i = 0; i < whereValues.count()
i < whereValues.count()Description
TRUEevaluated 156 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 123 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i)
123-156
131 if (whereValues.isGenerated(i)
whereValues.isGenerated(i)Description
TRUEevaluated 156 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
&& !whereValues.isNull(i)
!whereValues.isNull(i)Description
TRUEevaluated 150 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
0-156
132 editQuery.addBindValue(whereValues.value(i));
executed 150 times by 2 tests: editQuery.addBindValue(whereValues.value(i));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
150
133-
134 if (!editQuery.exec()
!editQuery.exec()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 117 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
6-117
135 error = editQuery.lastError();-
136 return
executed 6 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
false;
executed 6 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
6
137 }-
138 }
executed 117 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
else {
117
139 if (!editQuery.exec(stmt)
!editQuery.exec(stmt)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
140 error = editQuery.lastError();-
141 return
never executed: return false;
false;
never executed: return false;
0
142 }-
143 }
never executed: end of block
0
144 return
executed 117 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
true;
executed 117 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
117
145}-
146QSqlTableModel::QSqlTableModel(QObject *parent, QSqlDatabase db)-
147 : QSqlQueryModel(*new QSqlTableModelPrivate, parent)-
148{-
149 QSqlTableModelPrivate * const d = d_func();-
150 d->db = db.isValid()
db.isValid()Description
TRUEevaluated 92 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 51 times by 1 test
Evaluated by:
  • tst_QItemModel
? db : QSqlDatabase::database();
51-92
151}
executed 143 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
143
152-
153-
154-
155QSqlTableModel::QSqlTableModel(QSqlTableModelPrivate &dd, QObject *parent, QSqlDatabase db)-
156 : QSqlQueryModel(dd, parent)-
157{-
158 QSqlTableModelPrivate * const d = d_func();-
159 d->db = db.isValid()
db.isValid()Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • tst_QSqlRelationalTableModel
FALSEnever evaluated
? db : QSqlDatabase::database();
0-31
160}
executed 31 times by 1 test: end of block
Executed by:
  • tst_QSqlRelationalTableModel
31
161-
162-
163-
164-
165QSqlTableModel::~QSqlTableModel()-
166{-
167}-
168void QSqlTableModel::setTable(const QString &tableName)-
169{-
170 QSqlTableModelPrivate * const d = d_func();-
171 clear();-
172 d->tableName = tableName;-
173 d->initRecordAndPrimaryIndex();-
174-
175 if (d->rec.count() == 0
d->rec.count() == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 182 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
1-182
176 d->error = QSqlError(QLatin1String("Unable to find table ") + d->tableName, QString(),
executed 1 time by 1 test: d->error = QSqlError(QLatin1String("Unable to find table ") + d->tableName, QString(), QSqlError::StatementError);
Executed by:
  • tst_QSqlTableModel
1
177 QSqlError::StatementError);
executed 1 time by 1 test: d->error = QSqlError(QLatin1String("Unable to find table ") + d->tableName, QString(), QSqlError::StatementError);
Executed by:
  • tst_QSqlTableModel
1
178-
179-
180-
181 d->autoColumn.clear();-
182 for (int c = 0; c < d->rec.count()
c < d->rec.count()Description
TRUEevaluated 450 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 178 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++c) {
178-450
183 if (d->rec.field(c).isAutoValue()
d->rec.field(c).isAutoValue()Description
TRUEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 445 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
5-445
184 d->autoColumn = d->rec.fieldName(c);-
185 break;
executed 5 times by 2 tests: break;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
5
186 }-
187 }
executed 445 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
445
188}
executed 183 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
183
189-
190-
191-
192-
193QString QSqlTableModel::tableName() const-
194{-
195 const QSqlTableModelPrivate * const d = d_func();-
196 return
executed 475 times by 1 test: return d->tableName;
Executed by:
  • tst_QSqlRelationalTableModel
d->tableName;
executed 475 times by 1 test: return d->tableName;
Executed by:
  • tst_QSqlRelationalTableModel
475
197}-
198bool QSqlTableModel::select()-
199{-
200 QSqlTableModelPrivate * const d = d_func();-
201 const QString query = selectStatement();-
202 if (query.isEmpty()
query.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 315 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
1-315
203 return
executed 1 time by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
1
204-
205 beginResetModel();-
206-
207 d->clearCache();-
208-
209 QSqlQuery qu(query, d->db);-
210 setQuery(qu);-
211-
212 if (!qu.isActive()
!qu.isActive()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 313 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| lastError().isValid()
lastError().isValid()Description
TRUEnever evaluated
FALSEevaluated 313 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
0-313
213-
214 d->initRecordAndPrimaryIndex();-
215 endResetModel();-
216 return
executed 2 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
2
217 }-
218 endResetModel();-
219 return
executed 313 times by 3 tests: return true;
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
true;
executed 313 times by 3 tests: return true;
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
313
220}-
221bool QSqlTableModel::selectRow(int row)-
222{-
223 QSqlTableModelPrivate * const d = d_func();-
224-
225 if (row < 0
row < 0Description
TRUEnever evaluated
FALSEevaluated 62 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| row >= rowCount()
row >= rowCount()Description
TRUEnever evaluated
FALSEevaluated 62 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-62
226 return
never executed: return false;
false;
never executed: return false;
0
227-
228 const int table_sort_col = d->sortColumn;-
229 d->sortColumn = -1;-
230 const QString table_filter = d->filter;-
231 d->filter = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement,-
232 d->tableName,-
233 primaryValues(row),-
234 false);-
235 static const QString wh = Sql::where() + Sql::sp();-
236 if (d->filter.startsWith(wh, Qt::CaseInsensitive)
d->filter.star...seInsensitive)Description
TRUEevaluated 62 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-62
237 d->filter.remove(0, wh.length());
executed 62 times by 2 tests: d->filter.remove(0, wh.length());
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
62
238-
239 QString stmt;-
240-
241 if (!d->filter.isEmpty()
!d->filter.isEmpty()Description
TRUEevaluated 62 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-62
242 stmt = selectStatement();
executed 62 times by 2 tests: stmt = selectStatement();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
62
243-
244 d->sortColumn = table_sort_col;-
245 d->filter = table_filter;-
246-
247 if (stmt.isEmpty()
stmt.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 62 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-62
248 return
never executed: return false;
false;
never executed: return false;
0
249-
250 bool exists;-
251 QSqlRecord newValues;-
252-
253 {-
254 QSqlQuery q(d->db);-
255 q.setForwardOnly(true);-
256 if (!q.exec(stmt)
!q.exec(stmt)Description
TRUEnever evaluated
FALSEevaluated 62 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-62
257 return
never executed: return false;
false;
never executed: return false;
0
258-
259 exists = q.next();-
260 newValues = q.record();-
261 }-
262-
263 bool needsAddingToCache = !exists
!existsDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 53 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| d->cache.contains(row)
d->cache.contains(row)Description
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
;
2-53
264-
265 if (!needsAddingToCache
!needsAddingToCacheDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 60 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
2-60
266 const QSqlRecord curValues = record(row);-
267 needsAddingToCache = curValues.count() != newValues.count();-
268 if (!needsAddingToCache
!needsAddingToCacheDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEnever evaluated
) {
0-2
269-
270-
271 for (int f = curValues.count() - 1; f >= 0
f >= 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlTableModel
; --f) {
1-3
272 if (curValues.value(f) != newValues.value(f)
curValues.valu...alues.value(f)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
) {
1-2
273 needsAddingToCache = true;-
274 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QSqlTableModel
1
275 }-
276 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QSqlTableModel
2
277 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QSqlTableModel
2
278 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QSqlTableModel
2
279-
280 if (needsAddingToCache
needsAddingToCacheDescription
TRUEevaluated 61 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlTableModel
) {
1-61
281 d->cache[row].refresh(exists, newValues);-
282 headerDataChanged(Qt::Vertical, row, row);-
283 dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));-
284 }
executed 61 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
61
285-
286 return
executed 62 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
true;
executed 62 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
62
287}-
288-
289-
290-
291-
292QVariant QSqlTableModel::data(const QModelIndex &index, int role) const-
293{-
294 const QSqlTableModelPrivate * const d = d_func();-
295 if (!index.isValid()
!index.isValid()Description
TRUEevaluated 318 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 2596 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| (role != Qt::DisplayRole
role != Qt::DisplayRoleDescription
TRUEevaluated 868 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 1728 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
&& role != Qt::EditRole
role != Qt::EditRoleDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QItemModel
FALSEevaluated 859 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
))
9-2596
296 return
executed 327 times by 3 tests: return QVariant();
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QVariant();
executed 327 times by 3 tests: return QVariant();
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
327
297-
298 const QSqlTableModelPrivate::ModifiedRow mrow = d->cache.value(index.row());-
299 if (mrow.op() != QSqlTableModelPrivate::None
mrow.op() != Q...lPrivate::NoneDescription
TRUEevaluated 392 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 2195 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
392-2195
300 return
executed 392 times by 2 tests: return mrow.rec().value(index.column());
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
mrow.rec().value(index.column());
executed 392 times by 2 tests: return mrow.rec().value(index.column());
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
392
301-
302 return
executed 2195 times by 3 tests: return QSqlQueryModel::data(index, role);
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QSqlQueryModel::data(index, role);
executed 2195 times by 3 tests: return QSqlQueryModel::data(index, role);
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
2195
303}-
304-
305-
306-
307-
308QVariant QSqlTableModel::headerData(int section, Qt::Orientation orientation, int role) const-
309{-
310 const QSqlTableModelPrivate * const d = d_func();-
311 if (orientation == Qt::Vertical
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlTableModel
&& role == Qt::DisplayRole
role == Qt::DisplayRoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0-4
312 const QSqlTableModelPrivate::Op op = d->cache.value(section).op();-
313 if (op == QSqlTableModelPrivate::Insert
op == QSqlTabl...rivate::InsertDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
314 return
never executed: return QLatin1String("*");
QLatin1String("*");
never executed: return QLatin1String("*");
0
315 else if (op == QSqlTableModelPrivate::Delete
op == QSqlTabl...rivate::DeleteDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
316 return
never executed: return QLatin1String("!");
QLatin1String("!");
never executed: return QLatin1String("!");
0
317 }
never executed: end of block
0
318 return
executed 4 times by 2 tests: return QSqlQueryModel::headerData(section, orientation, role);
Executed by:
  • tst_QItemModel
  • tst_QSqlTableModel
QSqlQueryModel::headerData(section, orientation, role);
executed 4 times by 2 tests: return QSqlQueryModel::headerData(section, orientation, role);
Executed by:
  • tst_QItemModel
  • tst_QSqlTableModel
4
319}-
320bool QSqlTableModel::isDirty() const-
321{-
322 const QSqlTableModelPrivate * const d = d_func();-
323 QSqlTableModelPrivate::CacheMap::ConstIterator i = d->cache.constBegin();-
324 const QSqlTableModelPrivate::CacheMap::ConstIterator e = d->cache.constEnd();-
325 for (; i != e
i != eDescription
TRUEevaluated 74 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 144 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i) {
74-144
326 if (!i.value().submitted()
!i.value().submitted()Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 38 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
36-38
327 return
executed 36 times by 1 test: return true;
Executed by:
  • tst_QSqlTableModel
true;
executed 36 times by 1 test: return true;
Executed by:
  • tst_QSqlTableModel
36
328 }
executed 38 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
38
329 return
executed 144 times by 2 tests: return false;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
false;
executed 144 times by 2 tests: return false;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
144
330}-
331bool QSqlTableModel::isDirty(const QModelIndex &index) const-
332{-
333 const QSqlTableModelPrivate * const d = d_func();-
334 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEevaluated 79 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-79
335 return
never executed: return false;
false;
never executed: return false;
0
336-
337 const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());-
338 if (row.submitted()
row.submitted()Description
TRUEevaluated 57 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
22-57
339 return
executed 57 times by 2 tests: return false;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
false;
executed 57 times by 2 tests: return false;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
57
340-
341 return
executed 22 times by 1 test: return row.op() == QSqlTableModelPrivate::Insert || row.op() == QSqlTableModelPrivate::Delete || (row.op() == QSqlTableModelPrivate::Update && row.rec().isGenerated(index.column()));
Executed by:
  • tst_QSqlTableModel
row.op() == QSqlTableModelPrivate::Insert
executed 22 times by 1 test: return row.op() == QSqlTableModelPrivate::Insert || row.op() == QSqlTableModelPrivate::Delete || (row.op() == QSqlTableModelPrivate::Update && row.rec().isGenerated(index.column()));
Executed by:
  • tst_QSqlTableModel
22
342 || row.op() == QSqlTableModelPrivate::Delete
executed 22 times by 1 test: return row.op() == QSqlTableModelPrivate::Insert || row.op() == QSqlTableModelPrivate::Delete || (row.op() == QSqlTableModelPrivate::Update && row.rec().isGenerated(index.column()));
Executed by:
  • tst_QSqlTableModel
22
343 || (row.op() == QSqlTableModelPrivate::Update
executed 22 times by 1 test: return row.op() == QSqlTableModelPrivate::Insert || row.op() == QSqlTableModelPrivate::Delete || (row.op() == QSqlTableModelPrivate::Update && row.rec().isGenerated(index.column()));
Executed by:
  • tst_QSqlTableModel
22
344 && row.rec().isGenerated(index.column()));
executed 22 times by 1 test: return row.op() == QSqlTableModelPrivate::Insert || row.op() == QSqlTableModelPrivate::Delete || (row.op() == QSqlTableModelPrivate::Update && row.rec().isGenerated(index.column()));
Executed by:
  • tst_QSqlTableModel
22
345}-
346bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, int role)-
347{-
348 QSqlTableModelPrivate * const d = d_func();-
349 if (d->busyInsertingRows
d->busyInsertingRowsDescription
TRUEnever evaluated
FALSEevaluated 270 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-270
350 return
never executed: return false;
false;
never executed: return false;
0
351-
352 if (role != Qt::EditRole
role != Qt::EditRoleDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QItemModel
FALSEevaluated 268 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
2-268
353 return
executed 2 times by 1 test: return QSqlQueryModel::setData(index, value, role);
Executed by:
  • tst_QItemModel
QSqlQueryModel::setData(index, value, role);
executed 2 times by 1 test: return QSqlQueryModel::setData(index, value, role);
Executed by:
  • tst_QItemModel
2
354-
355 if (!index.isValid()
!index.isValid()Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
FALSEevaluated 265 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| index.column() >= d->rec.count()
index.column()...d->rec.count()Description
TRUEnever evaluated
FALSEevaluated 265 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| index.row() >= rowCount()
index.row() >= rowCount()Description
TRUEnever evaluated
FALSEevaluated 265 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-265
356 return
executed 3 times by 2 tests: return false;
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
false;
executed 3 times by 2 tests: return false;
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
3
357-
358 if (!(flags(index) & Qt::ItemIsEditable)
!(flags(index)...temIsEditable)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 262 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
3-262
359 return
executed 3 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
false;
executed 3 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
3
360-
361 const QVariant oldValue = QSqlTableModel::data(index, role);-
362 if (value == oldValue
value == oldValueDescription
TRUEevaluated 33 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 229 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
33-229
363 && value.isNull() == oldValue.isNull()
value.isNull()...Value.isNull()Description
TRUEevaluated 30 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
3-30
364 && d->cache.value(index.row()).op() != QSqlTableModelPrivate::Insert
d->cache.value...rivate::InsertDescription
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
7-23
365 return
executed 23 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
true;
executed 23 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
23
366-
367 QSqlTableModelPrivate::ModifiedRow &row = d->cache[index.row()];-
368-
369 if (row.op() == QSqlTableModelPrivate::None
row.op() == QS...lPrivate::NoneDescription
TRUEevaluated 47 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 192 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
47-192
370 row = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Update,
executed 47 times by 2 tests: row = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Update, QSqlQueryModel::record(index.row()));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
47
371 QSqlQueryModel::record(index.row()));
executed 47 times by 2 tests: row = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Update, QSqlQueryModel::record(index.row()));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
47
372-
373 row.setValue(index.column(), value);-
374 dataChanged(index, index);-
375-
376 if (d->strategy == OnFieldChange
d->strategy == OnFieldChangeDescription
TRUEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 224 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
&& row.op() != QSqlTableModelPrivate::Insert
row.op() != QS...rivate::InsertDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
7-224
377 return
executed 8 times by 2 tests: return submit();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
submit();
executed 8 times by 2 tests: return submit();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
8
378-
379 return
executed 231 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
true;
executed 231 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
231
380}-
381void QSqlTableModel::setQuery(const QSqlQuery &query)-
382{-
383 QSqlQueryModel::setQuery(query);-
384}
executed 315 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
315
385bool QSqlTableModel::updateRowInTable(int row, const QSqlRecord &values)-
386{-
387 QSqlTableModelPrivate * const d = d_func();-
388 QSqlRecord rec(values);-
389 beforeUpdate(row, rec);-
390-
391 const QSqlRecord whereValues = primaryValues(row);-
392 const bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries);-
393 const QString stmt = d->db.driver()->sqlStatement(QSqlDriver::UpdateStatement, d->tableName,-
394 rec, prepStatement);-
395 const QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement, d->tableName,-
396 whereValues, prepStatement);-
397-
398 if (stmt.isEmpty()
stmt.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| where.
where.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
isEmpty()
where.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| row < 0
row < 0Description
TRUEnever evaluated
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| row >= rowCount()
row >= rowCount()Description
TRUEnever evaluated
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
0-49
399 d->error = QSqlError(QLatin1String("No Fields to update"), QString(),-
400 QSqlError::StatementError);-
401 return
never executed: return false;
false;
never executed: return false;
0
402 }-
403-
404 return
executed 49 times by 2 tests: return d->exec(Sql::concat(stmt, where), prepStatement, rec, whereValues);
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
d->exec(Sql::concat(stmt, where), prepStatement, rec, whereValues);
executed 49 times by 2 tests: return d->exec(Sql::concat(stmt, where), prepStatement, rec, whereValues);
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
49
405}-
406bool QSqlTableModel::insertRowIntoTable(const QSqlRecord &values)-
407{-
408 QSqlTableModelPrivate * const d = d_func();-
409 QSqlRecord rec = values;-
410 beforeInsert(rec);-
411-
412 const bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries);-
413 const QString stmt = d->db.driver()->sqlStatement(QSqlDriver::InsertStatement, d->tableName,-
414 rec, prepStatement);-
415-
416 if (stmt.isEmpty()
stmt.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 52 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
1-52
417 d->error = QSqlError(QLatin1String("No Fields to update"), QString(),-
418 QSqlError::StatementError);-
419 return
executed 1 time by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
1
420 }-
421-
422 return
executed 52 times by 2 tests: return d->exec(stmt, prepStatement, rec, QSqlRecord() );
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
d->exec(stmt, prepStatement, rec, QSqlRecord() );
executed 52 times by 2 tests: return d->exec(stmt, prepStatement, rec, QSqlRecord() );
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
52
423}-
424bool QSqlTableModel::deleteRowFromTable(int row)-
425{-
426 QSqlTableModelPrivate * const d = d_func();-
427 beforeDelete(row);-
428-
429 const QSqlRecord whereValues = primaryValues(row);-
430 const bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries);-
431 const QString stmt = d->db.driver()->sqlStatement(QSqlDriver::DeleteStatement,-
432 d->tableName,-
433 QSqlRecord(),-
434 prepStatement);-
435 const QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement,-
436 d->tableName,-
437 whereValues,-
438 prepStatement);-
439-
440 if (stmt.isEmpty()
stmt.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
|| where.
where.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
isEmpty()
where.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
) {
0-22
441 d->error = QSqlError(QLatin1String("Unable to delete row"), QString(),-
442 QSqlError::StatementError);-
443 return
never executed: return false;
false;
never executed: return false;
0
444 }-
445-
446 return
executed 22 times by 1 test: return d->exec(Sql::concat(stmt, where), prepStatement, QSqlRecord() , whereValues);
Executed by:
  • tst_QSqlTableModel
d->exec(Sql::concat(stmt, where), prepStatement, QSqlRecord() , whereValues);
executed 22 times by 1 test: return d->exec(Sql::concat(stmt, where), prepStatement, QSqlRecord() , whereValues);
Executed by:
  • tst_QSqlTableModel
22
447}-
448bool QSqlTableModel::submitAll()-
449{-
450 QSqlTableModelPrivate * const d = d_func();-
451-
452 bool success = true;-
453-
454 const auto cachedKeys = d->cache.keys();-
455 for (int row : cachedKeys) {-
456-
457 QSqlTableModelPrivate::CacheMap::iterator it = d->cache.find(row);-
458 if (it == d->cache.end()
it == d->cache.end()Description
TRUEnever evaluated
FALSEevaluated 160 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-160
459 continue;
never executed: continue;
0
460-
461 QSqlTableModelPrivate::ModifiedRow &mrow = it.value();-
462 if (mrow.submitted()
mrow.submitted()Description
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 124 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
36-124
463 continue;
executed 36 times by 2 tests: continue;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
36
464-
465 switch (mrow.op()) {-
466 case
executed 53 times by 2 tests: case QSqlTableModelPrivate::Insert:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QSqlTableModelPrivate::Insert:
executed 53 times by 2 tests: case QSqlTableModelPrivate::Insert:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
53
467 success = insertRowIntoTable(mrow.rec());-
468 break;
executed 53 times by 2 tests: break;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
53
469 case
executed 49 times by 2 tests: case QSqlTableModelPrivate::Update:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QSqlTableModelPrivate::Update:
executed 49 times by 2 tests: case QSqlTableModelPrivate::Update:
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
49
470 success = updateRowInTable(row, mrow.rec());-
471 break;
executed 49 times by 2 tests: break;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
49
472 case
executed 22 times by 1 test: case QSqlTableModelPrivate::Delete:
Executed by:
  • tst_QSqlTableModel
QSqlTableModelPrivate::Delete:
executed 22 times by 1 test: case QSqlTableModelPrivate::Delete:
Executed by:
  • tst_QSqlTableModel
22
473 success = deleteRowFromTable(row);-
474 break;
executed 22 times by 1 test: break;
Executed by:
  • tst_QSqlTableModel
22
475 case
never executed: case QSqlTableModelPrivate::None:
QSqlTableModelPrivate::None:
never executed: case QSqlTableModelPrivate::None:
0
476 ((!(false)) ? qt_assert_x("QSqlTableModel::submitAll()", "Invalid cache operation",__FILE__,761) : qt_noop());-
477 break;
never executed: break;
0
478 }-
479-
480 if (success
successDescription
TRUEevaluated 117 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
) {
7-117
481 if (d->strategy != OnManualSubmit
d->strategy != OnManualSubmitDescription
TRUEevaluated 60 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 57 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
&& mrow.op() == QSqlTableModelPrivate::Insert
mrow.op() == Q...rivate::InsertDescription
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 37 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
23-60
482 int c = mrow.rec().indexOf(d->autoColumn);-
483 if (c != -1
c != -1Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
&& !mrow.rec().isGenerated(c)
!mrow.rec().isGenerated(c)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-17
484 mrow.setValue(c, d->editQuery.lastInsertId());
executed 6 times by 1 test: mrow.setValue(c, d->editQuery.lastInsertId());
Executed by:
  • tst_QSqlTableModel
6
485 }
executed 23 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
23
486 mrow.setSubmitted();-
487 if (d->strategy != OnManualSubmit
d->strategy != OnManualSubmitDescription
TRUEevaluated 60 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 57 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
57-60
488 success = selectRow(row);
executed 60 times by 2 tests: success = selectRow(row);
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
60
489 }
executed 117 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
117
490-
491 if (!success
!successDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 117 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
7-117
492 break;
executed 7 times by 1 test: break;
Executed by:
  • tst_QSqlTableModel
7
493 }
executed 117 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
117
494-
495 if (success
successDescription
TRUEevaluated 118 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
) {
7-118
496 if (d->strategy == OnManualSubmit
d->strategy == OnManualSubmitDescription
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 82 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
36-82
497 success = select();
executed 36 times by 2 tests: success = select();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
36
498 }
executed 118 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
118
499-
500 return
executed 125 times by 2 tests: return success;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
success;
executed 125 times by 2 tests: return success;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
125
501}-
502bool QSqlTableModel::submit()-
503{-
504 QSqlTableModelPrivate * const d = d_func();-
505 if (d->strategy == OnRowChange
d->strategy == OnRowChangeDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 25 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| d->strategy == OnFieldChange
d->strategy == OnFieldChangeDescription
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QItemModel
)
1-32
506 return
executed 56 times by 2 tests: return submitAll();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
submitAll();
executed 56 times by 2 tests: return submitAll();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
56
507 return
executed 1 time by 1 test: return true;
Executed by:
  • tst_QItemModel
true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QItemModel
1
508}-
509void QSqlTableModel::revert()-
510{-
511 QSqlTableModelPrivate * const d = d_func();-
512 if (d->strategy == OnRowChange
d->strategy == OnRowChangeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlTableModel
|| d->strategy == OnFieldChange
d->strategy == OnFieldChangeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlTableModel
)
4-9
513 revertAll();
executed 8 times by 1 test: revertAll();
Executed by:
  • tst_QSqlTableModel
8
514}
executed 13 times by 2 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlTableModel
13
515void QSqlTableModel::setEditStrategy(EditStrategy strategy)-
516{-
517 QSqlTableModelPrivate * const d = d_func();-
518 revertAll();-
519 d->strategy = strategy;-
520}
executed 108 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
108
521-
522-
523-
524-
525-
526-
527QSqlTableModel::EditStrategy QSqlTableModel::editStrategy() const-
528{-
529 const QSqlTableModelPrivate * const d = d_func();-
530 return
executed 13 times by 2 tests: return d->strategy;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
d->strategy;
executed 13 times by 2 tests: return d->strategy;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
13
531}-
532-
533-
534-
535-
536-
537-
538void QSqlTableModel::revertAll()-
539{-
540 QSqlTableModelPrivate * const d = d_func();-
541-
542 const QList<int> rows(d->cache.keys());-
543 for (int i = rows.size() - 1; i >= 0
i >= 0Description
TRUEevaluated 35 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 134 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; --i)
35-134
544 revertRow(rows.value(i));
executed 35 times by 2 tests: revertRow(rows.value(i));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
35
545}
executed 134 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
134
546-
547-
548-
549-
550-
551-
552void QSqlTableModel::revertRow(int row)-
553{-
554 if (row < 0
row < 0Description
TRUEnever evaluated
FALSEevaluated 52 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-52
555 return;
never executed: return;
0
556-
557 QSqlTableModelPrivate * const d = d_func();-
558 d->revertCachedRow(row);-
559}
executed 52 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
52
560-
561-
562-
563-
564-
565-
566-
567QSqlIndex QSqlTableModel::primaryKey() const-
568{-
569 const QSqlTableModelPrivate * const d = d_func();-
570 return
executed 1 time by 1 test: return d->primaryIndex;
Executed by:
  • tst_QSqlTableModel
d->primaryIndex;
executed 1 time by 1 test: return d->primaryIndex;
Executed by:
  • tst_QSqlTableModel
1
571}-
572void QSqlTableModel::setPrimaryKey(const QSqlIndex &key)-
573{-
574 QSqlTableModelPrivate * const d = d_func();-
575 d->primaryIndex = key;-
576}
never executed: end of block
0
577-
578-
579-
580-
581QSqlDatabase QSqlTableModel::database() const-
582{-
583 const QSqlTableModelPrivate * const d = d_func();-
584 return
executed 447 times by 1 test: return d->db;
Executed by:
  • tst_QSqlRelationalTableModel
d->db;
executed 447 times by 1 test: return d->db;
Executed by:
  • tst_QSqlRelationalTableModel
447
585}-
586void QSqlTableModel::sort(int column, Qt::SortOrder order)-
587{-
588 setSort(column, order);-
589 select();-
590}
executed 12 times by 1 test: end of block
Executed by:
  • tst_QItemModel
12
591void QSqlTableModel::setSort(int column, Qt::SortOrder order)-
592{-
593 QSqlTableModelPrivate * const d = d_func();-
594 d->sortColumn = column;-
595 d->sortOrder = order;-
596}
executed 72 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
72
597-
598-
599-
600-
601-
602-
603-
604QString QSqlTableModel::orderByClause() const-
605{-
606 const QSqlTableModelPrivate * const d = d_func();-
607 QSqlField f = d->rec.field(d->sortColumn);-
608 if (!f.isValid()
!f.isValid()Description
TRUEevaluated 235 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 138 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
138-235
609 return
executed 235 times by 3 tests: return QString();
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QString();
executed 235 times by 3 tests: return QString();
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
235
610-
611-
612-
613 QString field = d->db.driver()->escapeIdentifier(f.name(), QSqlDriver::FieldName);-
614 field.prepend(QLatin1Char('.')).prepend(d->tableName);-
615 field = d->sortOrder == Qt::AscendingOrder
d->sortOrder =...AscendingOrderDescription
TRUEevaluated 133 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QSqlRelationalTableModel
? Sql::asc(field) : Sql::desc(field);
5-133
616 return
executed 138 times by 3 tests: return Sql::orderBy(field);
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
Sql::orderBy(field);
executed 138 times by 3 tests: return Sql::orderBy(field);
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
138
617}-
618-
619-
620-
621-
622-
623int QSqlTableModel::fieldIndex(const QString &fieldName) const-
624{-
625 const QSqlTableModelPrivate * const d = d_func();-
626 return
never executed: return d->rec.indexOf(fieldName);
d->rec.indexOf(fieldName);
never executed: return d->rec.indexOf(fieldName);
0
627}-
628QString QSqlTableModel::selectStatement() const-
629{-
630 const QSqlTableModelPrivate * const d = d_func();-
631 if (d->tableName.isEmpty()
d->tableName.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 294 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
0-294
632 d->error = QSqlError(QLatin1String("No table name given"), QString(),-
633 QSqlError::StatementError);-
634 return
never executed: return QString();
QString();
never executed: return QString();
0
635 }-
636 if (d->rec.isEmpty()
d->rec.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 293 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
1-293
637 d->error = QSqlError(QLatin1String("Unable to find table ") + d->tableName, QString(),-
638 QSqlError::StatementError);-
639 return
executed 1 time by 1 test: return QString();
Executed by:
  • tst_QSqlTableModel
QString();
executed 1 time by 1 test: return QString();
Executed by:
  • tst_QSqlTableModel
1
640 }-
641-
642 const QString stmt = d->db.driver()->sqlStatement(QSqlDriver::SelectStatement,-
643 d->tableName,-
644 d->rec,-
645 false);-
646 if (stmt.isEmpty()
stmt.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 293 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
0-293
647 d->error = QSqlError(QLatin1String("Unable to select fields from table ") + d->tableName,-
648 QString(), QSqlError::StatementError);-
649 return
never executed: return stmt;
stmt;
never executed: return stmt;
0
650 }-
651 return
executed 293 times by 3 tests: return Sql::concat(Sql::concat(stmt, Sql::where(d->filter)), orderByClause());
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
Sql::concat(Sql::concat(stmt, Sql::where(d->filter)), orderByClause());
executed 293 times by 3 tests: return Sql::concat(Sql::concat(stmt, Sql::where(d->filter)), orderByClause());
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
293
652}-
653bool QSqlTableModel::removeColumns(int column, int count, const QModelIndex &parent)-
654{-
655 QSqlTableModelPrivate * const d = d_func();-
656 if (parent.isValid()
parent.isValid()Description
TRUEnever evaluated
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| column < 0
column < 0Description
TRUEnever evaluated
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| column + count > d->rec.count()
column + count...d->rec.count()Description
TRUEnever evaluated
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-5
657 return
never executed: return false;
false;
never executed: return false;
0
658 for (int i = 0; i < count
i < countDescription
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i)
5-7
659 d->rec.remove(column);
executed 7 times by 2 tests: d->rec.remove(column);
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
7
660 if (d->query.isActive()
d->query.isActive()Description
TRUEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
)
0-5
661 return
executed 5 times by 2 tests: return select();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
select();
executed 5 times by 2 tests: return select();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
5
662 return
never executed: return true;
true;
never executed: return true;
0
663}-
664bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent)-
665{-
666 QSqlTableModelPrivate * const d = d_func();-
667 if (parent.isValid()
parent.isValid()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 41 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
|| row < 0
row < 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 37 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
|| count <= 0
count <= 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 35 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
2-41
668 return
executed 8 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
false;
executed 8 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
8
669 else if (row + count > rowCount()
row + count > rowCount()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 33 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
2-33
670 return
executed 2 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
2
671 else if (!count
!countDescription
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
0-33
672 return
never executed: return true;
true;
never executed: return true;
0
673-
674 if (d->strategy != OnManualSubmit
d->strategy != OnManualSubmitDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
16-17
675 if (count > 1
count > 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
|| (d->cache.value(row).submitted()
d->cache.value...w).submitted()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
&& isDirty()
isDirty()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
))
1-16
676 return
executed 4 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
4
677-
678-
679-
680 for (int idx = row + count - 1; idx >= row
idx >= rowDescription
TRUEevaluated 37 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 29 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
; --idx) {
29-37
681 QSqlTableModelPrivate::ModifiedRow& mrow = d->cache[idx];-
682 if (mrow.op() == QSqlTableModelPrivate::Insert
mrow.op() == Q...rivate::InsertDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
) {
13-24
683 revertRow(idx);-
684 }
executed 13 times by 1 test: end of block
Executed by:
  • tst_QSqlTableModel
else {
13
685 if (mrow.op() == QSqlTableModelPrivate::None
mrow.op() == Q...lPrivate::NoneDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
2-22
686 mrow = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Delete,
executed 22 times by 1 test: mrow = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Delete, QSqlQueryModel::record(idx));
Executed by:
  • tst_QSqlTableModel
22
687 QSqlQueryModel::record(idx));
executed 22 times by 1 test: mrow = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Delete, QSqlQueryModel::record(idx));
Executed by:
  • tst_QSqlTableModel
22
688 else-
689 mrow.setOp(QSqlTableModelPrivate::Delete);
executed 2 times by 1 test: mrow.setOp(QSqlTableModelPrivate::Delete);
Executed by:
  • tst_QSqlTableModel
2
690 if (d->strategy == OnManualSubmit
d->strategy == OnManualSubmitDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
11-13
691 headerDataChanged(Qt::Vertical, idx, idx);
executed 13 times by 1 test: headerDataChanged(Qt::Vertical, idx, idx);
Executed by:
  • tst_QSqlTableModel
13
692 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_QSqlTableModel
24
693 }-
694-
695 if (d->strategy != OnManualSubmit
d->strategy != OnManualSubmitDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
13-16
696 return
executed 13 times by 1 test: return submit();
Executed by:
  • tst_QSqlTableModel
submit();
executed 13 times by 1 test: return submit();
Executed by:
  • tst_QSqlTableModel
13
697-
698 return
executed 16 times by 1 test: return true;
Executed by:
  • tst_QSqlTableModel
true;
executed 16 times by 1 test: return true;
Executed by:
  • tst_QSqlTableModel
16
699}-
700bool QSqlTableModel::insertRows(int row, int count, const QModelIndex &parent)-
701{-
702 QSqlTableModelPrivate * const d = d_func();-
703 if (row < 0
row < 0Description
TRUEnever evaluated
FALSEevaluated 76 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| count <= 0
count <= 0Description
TRUEnever evaluated
FALSEevaluated 76 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| row > rowCount()
row > rowCount()Description
TRUEnever evaluated
FALSEevaluated 76 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| parent.isValid()
parent.isValid()Description
TRUEnever evaluated
FALSEevaluated 76 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-76
704 return
never executed: return false;
false;
never executed: return false;
0
705-
706 if (d->strategy != OnManualSubmit
d->strategy != OnManualSubmitDescription
TRUEevaluated 34 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 42 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
34-42
707 if (count != 1
count != 1Description
TRUEnever evaluated
FALSEevaluated 34 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| isDirty()
isDirty()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 31 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-34
708 return
executed 3 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
false;
executed 3 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
3
709-
710 d->busyInsertingRows = true;-
711 beginInsertRows(parent, row, row + count - 1);-
712-
713 if (d->strategy != OnManualSubmit
d->strategy != OnManualSubmitDescription
TRUEevaluated 31 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 42 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
31-42
714 d->cache.empty();
executed 31 times by 2 tests: d->cache.empty();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
31
715-
716 if (!d->cache.isEmpty()
!d->cache.isEmpty()Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
24-49
717 QMap<int, QSqlTableModelPrivate::ModifiedRow>::Iterator it = d->cache.end();-
718 while (it != d->cache.begin()
it != d->cache.begin()Description
TRUEevaluated 28 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
&& (--
(--it).key() >= rowDescription
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
it).key() >= row
(--it).key() >= rowDescription
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
7-28
719 int oldKey = it.key();-
720 const QSqlTableModelPrivate::ModifiedRow oldValue = it.value();-
721 d->cache.erase(it);-
722 it = d->cache.insert(oldKey + count, oldValue);-
723 }
executed 11 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
11
724 }
executed 24 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
24
725-
726 for (int i = 0; i < count
i < countDescription
TRUEevaluated 91 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 73 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i) {
73-91
727 d->cache[row + i] = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Insert,-
728 d->rec);-
729 primeInsert(row + i, d->cache[row + i].recRef());-
730 }
executed 91 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
91
731-
732 endInsertRows();-
733 d->busyInsertingRows = false;-
734 return
executed 73 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
true;
executed 73 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
73
735}-
736bool QSqlTableModel::insertRecord(int row, const QSqlRecord &record)-
737{-
738 if (row < 0
row < 0Description
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
7-22
739 row = rowCount();
executed 7 times by 2 tests: row = rowCount();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
7
740 if (!insertRow(row, QModelIndex())
!insertRow(row, QModelIndex())Description
TRUEnever evaluated
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-29
741 return
never executed: return false;
false;
never executed: return false;
0
742 if (!setRecord(row, record)
!setRecord(row, record)Description
TRUEnever evaluated
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
0-29
743 revertRow(row);-
744 return
never executed: return false;
false;
never executed: return false;
0
745 }-
746 return
executed 29 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
true;
executed 29 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
29
747}-
748-
749-
750-
751int QSqlTableModel::rowCount(const QModelIndex &parent) const-
752{-
753 const QSqlTableModelPrivate * const d = d_func();-
754-
755 if (parent.isValid()
parent.isValid()Description
TRUEevaluated 1028 times by 1 test
Evaluated by:
  • tst_QItemModel
FALSEevaluated 10706 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
1028-10706
756 return
executed 1028 times by 1 test: return 0;
Executed by:
  • tst_QItemModel
0;
executed 1028 times by 1 test: return 0;
Executed by:
  • tst_QItemModel
1028
757-
758 return
executed 10706 times by 3 tests: return QSqlQueryModel::rowCount() + d->insertCount();
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QSqlQueryModel::rowCount() + d->insertCount();
executed 10706 times by 3 tests: return QSqlQueryModel::rowCount() + d->insertCount();
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
10706
759}-
760QModelIndex QSqlTableModel::indexInQuery(const QModelIndex &item) const-
761{-
762 const QSqlTableModelPrivate * const d = d_func();-
763 if (d->cache.value(item.row()).insert()
d->cache.value...ow()).insert()Description
TRUEnever evaluated
FALSEevaluated 2177 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-2177
764 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
765-
766 const int rowOffset = d->insertCount(item.row());-
767 return
executed 2177 times by 3 tests: return QSqlQueryModel::indexInQuery(createIndex(item.row() - rowOffset, item.column(), item.internalPointer()));
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QSqlQueryModel::indexInQuery(createIndex(item.row() - rowOffset, item.column(), item.internalPointer()));
executed 2177 times by 3 tests: return QSqlQueryModel::indexInQuery(createIndex(item.row() - rowOffset, item.column(), item.internalPointer()));
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
2177
768}-
769-
770-
771-
772-
773-
774-
775QString QSqlTableModel::filter() const-
776{-
777 const QSqlTableModelPrivate * const d = d_func();-
778 return
executed 86 times by 2 tests: return d->filter;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
d->filter;
executed 86 times by 2 tests: return d->filter;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
86
779}-
780void QSqlTableModel::setFilter(const QString &filter)-
781{-
782 QSqlTableModelPrivate * const d = d_func();-
783 d->filter = filter;-
784 if (d->query.isActive()
d->query.isActive()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
3-4
785 select();
executed 3 times by 1 test: select();
Executed by:
  • tst_QSqlTableModel
3
786}
executed 7 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
7
787-
788-
789-
790void QSqlTableModel::clear()-
791{-
792 QSqlTableModelPrivate * const d = d_func();-
793 beginResetModel();-
794 d->clear();-
795 QSqlQueryModel::clear();-
796 endResetModel();-
797}
executed 190 times by 3 tests: end of block
Executed by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
190
798-
799-
800-
801Qt::ItemFlags QSqlTableModel::flags(const QModelIndex &index) const-
802{-
803 const QSqlTableModelPrivate * const d = d_func();-
804 if (index.internalPointer()
index.internalPointer()Description
TRUEnever evaluated
FALSEevaluated 267 times by 3 tests
Evaluated by:
  • tst_QItemModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| index.column() < 0
index.column() < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QItemModel
FALSEevaluated 266 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
|| index.column() >= d->rec.count()
index.column()...d->rec.count()Description
TRUEnever evaluated
FALSEevaluated 266 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
0-267
805 || index.row() < 0
index.row() < 0Description
TRUEnever evaluated
FALSEevaluated 266 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-266
806 return
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QItemModel
0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QItemModel
1
807-
808 bool editable = true;-
809-
810 if (d->rec.field(index.column()).isReadOnly()
d->rec.field(i...).isReadOnly()Description
TRUEnever evaluated
FALSEevaluated 266 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
0-266
811 editable = false;-
812 }
never executed: end of block
0
813 else {-
814 const QSqlTableModelPrivate::ModifiedRow mrow = d->cache.value(index.row());-
815 if (mrow.op() == QSqlTableModelPrivate::Delete
mrow.op() == Q...rivate::DeleteDescription
TRUEnever evaluated
FALSEevaluated 266 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
0-266
816 editable = false;-
817 }
never executed: end of block
0
818 else if (d->strategy == OnFieldChange
d->strategy == OnFieldChangeDescription
TRUEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 249 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
17-249
819 if (mrow.op() != QSqlTableModelPrivate::Insert
mrow.op() != Q...rivate::InsertDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
7-10
820 if (!isDirty(index)
!isDirty(index)Description
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEnever evaluated
&& isDirty()
isDirty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-10
821 editable = false;
executed 1 time by 1 test: editable = false;
Executed by:
  • tst_QSqlTableModel
1
822 }
executed 17 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
17
823 else if (d->strategy == OnRowChange
d->strategy == OnRowChangeDescription
TRUEevaluated 48 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 201 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
48-201
824 if (mrow.submitted()
mrow.submitted()Description
TRUEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 19 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
&& isDirty()
isDirty()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
3-29
825 editable = false;
executed 3 times by 1 test: editable = false;
Executed by:
  • tst_QSqlTableModel
3
826 }
executed 48 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
48
827 }
executed 266 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
266
828-
829 if (!editable
!editableDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 262 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
4-262
830 return
executed 4 times by 1 test: return QSqlQueryModel::flags(index);
Executed by:
  • tst_QSqlTableModel
QSqlQueryModel::flags(index);
executed 4 times by 1 test: return QSqlQueryModel::flags(index);
Executed by:
  • tst_QSqlTableModel
4
831 else-
832 return
executed 262 times by 2 tests: return QSqlQueryModel::flags(index) | Qt::ItemIsEditable;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QSqlQueryModel::flags(index) | Qt::ItemIsEditable;
executed 262 times by 2 tests: return QSqlQueryModel::flags(index) | Qt::ItemIsEditable;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
262
833}-
834QSqlRecord QSqlTableModel::record() const-
835{-
836 return
executed 13 times by 2 tests: return QSqlQueryModel::record();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
QSqlQueryModel::record();
executed 13 times by 2 tests: return QSqlQueryModel::record();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
13
837}-
838QSqlRecord QSqlTableModel::record(int row) const-
839{-
840 const QSqlTableModelPrivate * const d = d_func();-
841-
842-
843 QSqlRecord rec = QSqlQueryModel::record(row);-
844-
845-
846 const QSqlTableModelPrivate::ModifiedRow mrow = d->cache.value(row);-
847 if (mrow.op() != QSqlTableModelPrivate::None
mrow.op() != Q...lPrivate::NoneDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 160 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
) {
5-160
848 const QSqlRecord crec = mrow.rec();-
849 for (int i = 0, cnt = rec.count(); i < cnt
i < cntDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
; ++i)
5-15
850 rec.setGenerated(i, crec.isGenerated(i));
executed 15 times by 1 test: rec.setGenerated(i, crec.isGenerated(i));
Executed by:
  • tst_QSqlTableModel
15
851 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QSqlTableModel
5
852-
853 return
executed 165 times by 2 tests: return rec;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
rec;
executed 165 times by 2 tests: return rec;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
165
854}-
855bool QSqlTableModel::setRecord(int row, const QSqlRecord &values)-
856{-
857 QSqlTableModelPrivate * const d = d_func();-
858 ((!(row >= 0)) ? qt_assert_x("QSqlTableModel::setRecord()", "Cannot set a record to a row less than 0",__FILE__,1382) : qt_noop());-
859 if (d->busyInsertingRows
d->busyInsertingRowsDescription
TRUEnever evaluated
FALSEevaluated 50 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-50
860 return
never executed: return false;
false;
never executed: return false;
0
861-
862 if (row >= rowCount()
row >= rowCount()Description
TRUEnever evaluated
FALSEevaluated 50 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-50
863 return
never executed: return false;
false;
never executed: return false;
0
864-
865 if (d->cache.value(row).op() == QSqlTableModelPrivate::Delete
d->cache.value...rivate::DeleteDescription
TRUEnever evaluated
FALSEevaluated 50 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-50
866 return
never executed: return false;
false;
never executed: return false;
0
867-
868 if (d->strategy != OnManualSubmit
d->strategy != OnManualSubmitDescription
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
&& d->cache.value(row).submitted()
d->cache.value...w).submitted()Description
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
&& isDirty()
isDirty()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
3-26
869 return
executed 3 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
false;
executed 3 times by 1 test: return false;
Executed by:
  • tst_QSqlTableModel
3
870-
871-
872 typedef QMap<int, int> Map;-
873 Map map;-
874 for (int i = 0; i < values.count()
i < values.count()Description
TRUEevaluated 132 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 47 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i) {
47-132
875 int idx = d->nameToIndex(values.fieldName(i));-
876 if (idx == -1
idx == -1Description
TRUEnever evaluated
FALSEevaluated 132 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
0-132
877 return
never executed: return false;
false;
never executed: return false;
0
878 map[i] = idx;-
879 }
executed 132 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
132
880-
881 QSqlTableModelPrivate::ModifiedRow &mrow = d->cache[row];-
882 if (mrow.op() == QSqlTableModelPrivate::None
mrow.op() == Q...lPrivate::NoneDescription
TRUEevaluated 13 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 34 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
13-34
883 mrow = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Update,
executed 13 times by 2 tests: mrow = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Update, QSqlQueryModel::record(row));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
13
884 QSqlQueryModel::record(row));
executed 13 times by 2 tests: mrow = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Update, QSqlQueryModel::record(row));
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
13
885-
886 Map::const_iterator i = map.constBegin();-
887 const Map::const_iterator e = map.constEnd();-
888 for ( ; i != e
i != eDescription
TRUEevaluated 132 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 47 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
; ++i) {
47-132
889-
890 EditStrategy strategy = d->strategy;-
891 d->strategy = OnManualSubmit;-
892 QModelIndex cIndex = createIndex(row, i.value());-
893 setData(cIndex, values.value(i.key()));-
894 d->strategy = strategy;-
895-
896 if (!values.isGenerated(i.key())
!values.isGenerated(i.key())Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 129 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
3-129
897 mrow.recRef().setGenerated(i.value(), false);
executed 3 times by 1 test: mrow.recRef().setGenerated(i.value(), false);
Executed by:
  • tst_QSqlTableModel
3
898 }
executed 132 times by 2 tests: end of block
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
132
899-
900 if (d->strategy != OnManualSubmit
d->strategy != OnManualSubmitDescription
TRUEevaluated 21 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
)
21-26
901 return
executed 21 times by 2 tests: return submit();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
submit();
executed 21 times by 2 tests: return submit();
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
21
902-
903 return
executed 26 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
true;
executed 26 times by 2 tests: return true;
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
26
904}-
905QSqlRecord QSqlTableModel::primaryValues(int row) const-
906{-
907 const QSqlTableModelPrivate * const d = d_func();-
908-
909 const QSqlRecord &pIndex = d->primaryIndex.isEmpty()
d->primaryIndex.isEmpty()Description
TRUEevaluated 73 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
FALSEevaluated 60 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
? d->rec : d->primaryIndex;
60-73
910-
911 QSqlTableModelPrivate::ModifiedRow mr = d->cache.value(row);-
912 if (mr.op() != QSqlTableModelPrivate::None
mr.op() != QSq...lPrivate::NoneDescription
TRUEevaluated 131 times by 2 tests
Evaluated by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSqlTableModel
)
2-131
913 return
executed 131 times by 2 tests: return mr.primaryValues(pIndex);
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
mr.primaryValues(pIndex);
executed 131 times by 2 tests: return mr.primaryValues(pIndex);
Executed by:
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
131
914 else-
915 return
executed 2 times by 1 test: return QSqlQueryModel::record(row).keyValues(pIndex);
Executed by:
  • tst_QSqlTableModel
QSqlQueryModel::record(row).keyValues(pIndex);
executed 2 times by 1 test: return QSqlQueryModel::record(row).keyValues(pIndex);
Executed by:
  • tst_QSqlTableModel
2
916}-
917-
918-
Switch to Source codePreprocessed file

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