Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | QTableModel::QTableModel(int rows, int columns, QTableWidget *parent) | - |
9 | : QAbstractTableModel(parent), | - |
10 | prototype(0), | - |
11 | tableItems(rows * columns, 0), | - |
12 | verticalHeaderItems(rows, 0), | - |
13 | horizontalHeaderItems(columns, 0) | - |
14 | {} executed: } Execution Count:146 | 146 |
15 | | - |
16 | QTableModel::~QTableModel() | - |
17 | { | - |
18 | clear(); | - |
19 | delete prototype; | - |
20 | } executed: } Execution Count:146 | 146 |
21 | | - |
22 | bool QTableModel::insertRows(int row, int count, const QModelIndex &) | - |
23 | { | - |
24 | if (count < 1 || row < 0 || row > verticalHeaderItems.count()) evaluated: count < 1 yes Evaluation Count:16 | yes Evaluation Count:188 |
evaluated: row < 0 yes Evaluation Count:5 | yes Evaluation Count:183 |
evaluated: row > verticalHeaderItems.count() yes Evaluation Count:5 | yes Evaluation Count:178 |
| 5-188 |
25 | return false; executed: return false; Execution Count:26 | 26 |
26 | | - |
27 | beginInsertRows(QModelIndex(), row, row + count - 1); | - |
28 | int rc = verticalHeaderItems.count(); | - |
29 | int cc = horizontalHeaderItems.count(); | - |
30 | verticalHeaderItems.insert(row, count, 0); | - |
31 | if (rc == 0) evaluated: rc == 0 yes Evaluation Count:104 | yes Evaluation Count:74 |
| 74-104 |
32 | tableItems.resize(cc * count); executed: tableItems.resize(cc * count); Execution Count:104 | 104 |
33 | else | - |
34 | tableItems.insert(tableIndex(row, 0), cc * count, 0); executed: tableItems.insert(tableIndex(row, 0), cc * count, 0); Execution Count:74 | 74 |
35 | endInsertRows(); | - |
36 | return true; executed: return true; Execution Count:178 | 178 |
37 | } | - |
38 | | - |
39 | bool QTableModel::insertColumns(int column, int count, const QModelIndex &) | - |
40 | { | - |
41 | if (count < 1 || column < 0 || column > horizontalHeaderItems.count()) evaluated: count < 1 yes Evaluation Count:16 | yes Evaluation Count:176 |
evaluated: column < 0 yes Evaluation Count:5 | yes Evaluation Count:171 |
evaluated: column > horizontalHeaderItems.count() yes Evaluation Count:5 | yes Evaluation Count:166 |
| 5-176 |
42 | return false; executed: return false; Execution Count:26 | 26 |
43 | | - |
44 | beginInsertColumns(QModelIndex(), column, column + count - 1); | - |
45 | int rc = verticalHeaderItems.count(); | - |
46 | int cc = horizontalHeaderItems.count(); | - |
47 | horizontalHeaderItems.insert(column, count, 0); | - |
48 | if (cc == 0) evaluated: cc == 0 yes Evaluation Count:104 | yes Evaluation Count:62 |
| 62-104 |
49 | tableItems.resize(rc * count); executed: tableItems.resize(rc * count); Execution Count:104 | 104 |
50 | else | - |
51 | for (int row = 0; row < rc; ++row) evaluated: row < rc yes Evaluation Count:608 | yes Evaluation Count:62 |
| 62-608 |
52 | tableItems.insert(tableIndex(row, column), count, 0); executed: tableItems.insert(tableIndex(row, column), count, 0); Execution Count:608 | 608 |
53 | endInsertColumns(); | - |
54 | return true; executed: return true; Execution Count:166 | 166 |
55 | } | - |
56 | | - |
57 | bool QTableModel::removeRows(int row, int count, const QModelIndex &) | - |
58 | { | - |
59 | if (count < 1 || row < 0 || row + count > verticalHeaderItems.count()) evaluated: count < 1 yes Evaluation Count:16 | yes Evaluation Count:97 |
evaluated: row < 0 yes Evaluation Count:6 | yes Evaluation Count:91 |
evaluated: row + count > verticalHeaderItems.count() yes Evaluation Count:9 | yes Evaluation Count:82 |
| 6-97 |
60 | return false; executed: return false; Execution Count:31 | 31 |
61 | | - |
62 | beginRemoveRows(QModelIndex(), row, row + count - 1); | - |
63 | int i = tableIndex(row, 0); | - |
64 | int n = count * columnCount(); | - |
65 | QTableWidgetItem *oldItem = 0; | - |
66 | for (int j = i; j < n + i; ++j) { evaluated: j < n + i yes Evaluation Count:2721 | yes Evaluation Count:82 |
| 82-2721 |
67 | oldItem = tableItems.at(j); | - |
68 | if (oldItem) evaluated: oldItem yes Evaluation Count:11 | yes Evaluation Count:2710 |
| 11-2710 |
69 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:11 | 11 |
70 | delete oldItem; | - |
71 | } executed: } Execution Count:2721 | 2721 |
72 | tableItems.remove(qMax(i, 0), n); | - |
73 | for (int v = row; v < row + count; ++v) { evaluated: v < row + count yes Evaluation Count:260 | yes Evaluation Count:82 |
| 82-260 |
74 | oldItem = verticalHeaderItems.at(v); | - |
75 | if (oldItem) evaluated: oldItem yes Evaluation Count:1 | yes Evaluation Count:259 |
| 1-259 |
76 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:1 | 1 |
77 | delete oldItem; | - |
78 | } executed: } Execution Count:260 | 260 |
79 | verticalHeaderItems.remove(row, count); | - |
80 | endRemoveRows(); | - |
81 | return true; executed: return true; Execution Count:82 | 82 |
82 | } | - |
83 | | - |
84 | bool QTableModel::removeColumns(int column, int count, const QModelIndex &) | - |
85 | { | - |
86 | if (count < 1 || column < 0 || column + count > horizontalHeaderItems.count()) evaluated: count < 1 yes Evaluation Count:16 | yes Evaluation Count:84 |
evaluated: column < 0 yes Evaluation Count:6 | yes Evaluation Count:78 |
evaluated: column + count > horizontalHeaderItems.count() yes Evaluation Count:9 | yes Evaluation Count:69 |
| 6-84 |
87 | return false; executed: return false; Execution Count:31 | 31 |
88 | | - |
89 | beginRemoveColumns(QModelIndex(), column, column + count - 1); | - |
90 | QTableWidgetItem *oldItem = 0; | - |
91 | for (int row = rowCount() - 1; row >= 0; --row) { evaluated: row >= 0 yes Evaluation Count:324 | yes Evaluation Count:69 |
| 69-324 |
92 | int i = tableIndex(row, column); | - |
93 | for (int j = i; j < i + count; ++j) { evaluated: j < i + count yes Evaluation Count:996 | yes Evaluation Count:324 |
| 324-996 |
94 | oldItem = tableItems.at(j); | - |
95 | if (oldItem) evaluated: oldItem yes Evaluation Count:11 | yes Evaluation Count:985 |
| 11-985 |
96 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:11 | 11 |
97 | delete oldItem; | - |
98 | } executed: } Execution Count:996 | 996 |
99 | tableItems.remove(i, count); | - |
100 | } executed: } Execution Count:324 | 324 |
101 | for (int h=column; h<column+count; ++h) { evaluated: h<column+count yes Evaluation Count:237 | yes Evaluation Count:69 |
| 69-237 |
102 | oldItem = horizontalHeaderItems.at(h); | - |
103 | if (oldItem) evaluated: oldItem yes Evaluation Count:1 | yes Evaluation Count:236 |
| 1-236 |
104 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:1 | 1 |
105 | delete oldItem; | - |
106 | } executed: } Execution Count:237 | 237 |
107 | horizontalHeaderItems.remove(column, count); | - |
108 | endRemoveColumns(); | - |
109 | return true; executed: return true; Execution Count:69 | 69 |
110 | } | - |
111 | | - |
112 | void QTableModel::setItem(int row, int column, QTableWidgetItem *item) | - |
113 | { | - |
114 | int i = tableIndex(row, column); | - |
115 | if (i < 0 || i >= tableItems.count()) partially evaluated: i < 0 no Evaluation Count:0 | yes Evaluation Count:984 |
partially evaluated: i >= tableItems.count() no Evaluation Count:0 | yes Evaluation Count:984 |
| 0-984 |
116 | return; | 0 |
117 | QTableWidgetItem *oldItem = tableItems.at(i); | - |
118 | if (item == oldItem) partially evaluated: item == oldItem no Evaluation Count:0 | yes Evaluation Count:984 |
| 0-984 |
119 | return; | 0 |
120 | | - |
121 | | - |
122 | if (oldItem) evaluated: oldItem yes Evaluation Count:18 | yes Evaluation Count:966 |
| 18-966 |
123 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:18 | 18 |
124 | delete tableItems.at(i); | - |
125 | | - |
126 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
127 | | - |
128 | | - |
129 | if (item) partially evaluated: item yes Evaluation Count:984 | no Evaluation Count:0 |
| 0-984 |
130 | item->d->id = i; executed: item->d->id = i; Execution Count:984 | 984 |
131 | tableItems[i] = item; | - |
132 | | - |
133 | if (view && view->isSortingEnabled() partially evaluated: view yes Evaluation Count:984 | no Evaluation Count:0 |
evaluated: view->isSortingEnabled() yes Evaluation Count:25 | yes Evaluation Count:959 |
| 0-984 |
134 | && view->horizontalHeader()->sortIndicatorSection() == column) { evaluated: view->horizontalHeader()->sortIndicatorSection() == column yes Evaluation Count:16 | yes Evaluation Count:9 |
| 9-16 |
135 | | - |
136 | Qt::SortOrder order = view->horizontalHeader()->sortIndicatorOrder(); | - |
137 | QVector<QTableWidgetItem*> colItems = columnItems(column); | - |
138 | if (row < colItems.count()) partially evaluated: row < colItems.count() yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
139 | colItems.remove(row); executed: colItems.remove(row); Execution Count:16 | 16 |
140 | int sortedRow; | - |
141 | if (item == 0) { partially evaluated: item == 0 no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
142 | | - |
143 | sortedRow = colItems.count(); | - |
144 | } else { | 0 |
145 | QVector<QTableWidgetItem*>::iterator it; | - |
146 | it = sortedInsertionIterator(colItems.begin(), colItems.end(), order, item); | - |
147 | sortedRow = qMax((int)(it - colItems.begin()), 0); | - |
148 | } executed: } Execution Count:16 | 16 |
149 | if (sortedRow != row) { evaluated: sortedRow != row yes Evaluation Count:12 | yes Evaluation Count:4 |
| 4-12 |
150 | layoutAboutToBeChanged(); | - |
151 | | - |
152 | int cc = columnCount(); | - |
153 | QVector<QTableWidgetItem*> rowItems(cc); | - |
154 | for (int j = 0; j < cc; ++j) evaluated: j < cc yes Evaluation Count:24 | yes Evaluation Count:12 |
| 12-24 |
155 | rowItems[j] = tableItems.at(tableIndex(row, j)); executed: rowItems[j] = tableItems.at(tableIndex(row, j)); Execution Count:24 | 24 |
156 | tableItems.remove(tableIndex(row, 0), cc); | - |
157 | tableItems.insert(tableIndex(sortedRow, 0), cc, 0); | - |
158 | for (int j = 0; j < cc; ++j) evaluated: j < cc yes Evaluation Count:24 | yes Evaluation Count:12 |
| 12-24 |
159 | tableItems[tableIndex(sortedRow, j)] = rowItems.at(j); executed: tableItems[tableIndex(sortedRow, j)] = rowItems.at(j); Execution Count:24 | 24 |
160 | QTableWidgetItem *header = verticalHeaderItems.at(row); | - |
161 | verticalHeaderItems.remove(row); | - |
162 | verticalHeaderItems.insert(sortedRow, header); | - |
163 | | - |
164 | QModelIndexList oldPersistentIndexes = persistentIndexList(); | - |
165 | QModelIndexList newPersistentIndexes = oldPersistentIndexes; | - |
166 | updateRowIndexes(newPersistentIndexes, row, sortedRow); | - |
167 | changePersistentIndexList(oldPersistentIndexes, | - |
168 | newPersistentIndexes); | - |
169 | | - |
170 | layoutChanged(); | - |
171 | return; executed: return; Execution Count:12 | 12 |
172 | } | - |
173 | } executed: } Execution Count:4 | 4 |
174 | QModelIndex idx = QAbstractTableModel::index(row, column); | - |
175 | dataChanged(idx, idx); | - |
176 | } executed: } Execution Count:972 | 972 |
177 | | - |
178 | QTableWidgetItem *QTableModel::takeItem(int row, int column) | - |
179 | { | - |
180 | long i = tableIndex(row, column); | - |
181 | QTableWidgetItem *itm = tableItems.value(i); | - |
182 | if (itm) { evaluated: itm yes Evaluation Count:4 | yes Evaluation Count:8 |
| 4-8 |
183 | itm->view = 0; | - |
184 | itm->d->id = -1; | - |
185 | tableItems[i] = 0; | - |
186 | QModelIndex ind = index(itm); | - |
187 | dataChanged(ind, ind); | - |
188 | } executed: } Execution Count:4 | 4 |
189 | return itm; executed: return itm; Execution Count:12 | 12 |
190 | } | - |
191 | | - |
192 | QTableWidgetItem *QTableModel::item(int row, int column) const | - |
193 | { | - |
194 | return item(index(row, column)); executed: return item(index(row, column)); Execution Count:6409 | 6409 |
195 | } | - |
196 | | - |
197 | QTableWidgetItem *QTableModel::item(const QModelIndex &index) const | - |
198 | { | - |
199 | if (!isValid(index)) evaluated: !isValid(index) yes Evaluation Count:75 | yes Evaluation Count:10474 |
| 75-10474 |
200 | return 0; executed: return 0; Execution Count:75 | 75 |
201 | return tableItems.at(tableIndex(index.row(), index.column())); executed: return tableItems.at(tableIndex(index.row(), index.column())); Execution Count:10474 | 10474 |
202 | } | - |
203 | | - |
204 | void QTableModel::removeItem(QTableWidgetItem *item) | - |
205 | { | - |
206 | int i = tableItems.indexOf(item); | - |
207 | if (i != -1) { evaluated: i != -1 yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
208 | tableItems[i] = 0; | - |
209 | QModelIndex idx = index(item); | - |
210 | dataChanged(idx, idx); | - |
211 | return; executed: return; Execution Count:3 | 3 |
212 | } | - |
213 | | - |
214 | i = verticalHeaderItems.indexOf(item); | - |
215 | | - |
216 | if (i != -1) { evaluated: i != -1 yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
217 | verticalHeaderItems[i] = 0; | - |
218 | headerDataChanged(Qt::Vertical, i, i); | - |
219 | return; executed: return; Execution Count:1 | 1 |
220 | } | - |
221 | i = horizontalHeaderItems.indexOf(item); | - |
222 | if (i != -1) { partially evaluated: i != -1 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
223 | horizontalHeaderItems[i] = 0; | - |
224 | headerDataChanged(Qt::Horizontal, i, i); | - |
225 | return; executed: return; Execution Count:1 | 1 |
226 | } | - |
227 | } | 0 |
228 | | - |
229 | void QTableModel::setHorizontalHeaderItem(int section, QTableWidgetItem *item) | - |
230 | { | - |
231 | if (section < 0 || section >= horizontalHeaderItems.count()) partially evaluated: section < 0 no Evaluation Count:0 | yes Evaluation Count:11 |
partially evaluated: section >= horizontalHeaderItems.count() no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
232 | return; | 0 |
233 | QTableWidgetItem *oldItem = horizontalHeaderItems.at(section); | - |
234 | if (item == oldItem) partially evaluated: item == oldItem no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
235 | return; | 0 |
236 | | - |
237 | if (oldItem) evaluated: oldItem yes Evaluation Count:2 | yes Evaluation Count:9 |
| 2-9 |
238 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:2 | 2 |
239 | delete oldItem; | - |
240 | | - |
241 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
242 | | - |
243 | if (item) { partially evaluated: item yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
244 | item->view = view; | - |
245 | item->itemFlags = Qt::ItemFlags(int(item->itemFlags)|ItemIsHeaderItem); | - |
246 | } executed: } Execution Count:11 | 11 |
247 | horizontalHeaderItems[section] = item; | - |
248 | headerDataChanged(Qt::Horizontal, section, section); | - |
249 | } executed: } Execution Count:11 | 11 |
250 | | - |
251 | void QTableModel::setVerticalHeaderItem(int section, QTableWidgetItem *item) | - |
252 | { | - |
253 | if (section < 0 || section >= verticalHeaderItems.count()) partially evaluated: section < 0 no Evaluation Count:0 | yes Evaluation Count:7 |
partially evaluated: section >= verticalHeaderItems.count() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
254 | return; | 0 |
255 | QTableWidgetItem *oldItem = verticalHeaderItems.at(section); | - |
256 | if (item == oldItem) partially evaluated: item == oldItem no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
257 | return; | 0 |
258 | | - |
259 | if (oldItem) evaluated: oldItem yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
260 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:2 | 2 |
261 | delete oldItem; | - |
262 | | - |
263 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
264 | | - |
265 | if (item) { partially evaluated: item yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
266 | item->view = view; | - |
267 | item->itemFlags = Qt::ItemFlags(int(item->itemFlags)|ItemIsHeaderItem); | - |
268 | } executed: } Execution Count:7 | 7 |
269 | verticalHeaderItems[section] = item; | - |
270 | headerDataChanged(Qt::Vertical, section, section); | - |
271 | } executed: } Execution Count:7 | 7 |
272 | | - |
273 | QTableWidgetItem *QTableModel::takeHorizontalHeaderItem(int section) | - |
274 | { | - |
275 | if (section < 0 || section >= horizontalHeaderItems.count()) never evaluated: section < 0 never evaluated: section >= horizontalHeaderItems.count() | 0 |
276 | return 0; never executed: return 0; | 0 |
277 | QTableWidgetItem *itm = horizontalHeaderItems.at(section); | - |
278 | if (itm) { | 0 |
279 | itm->view = 0; | - |
280 | itm->itemFlags &= ~ItemIsHeaderItem; | - |
281 | horizontalHeaderItems[section] = 0; | - |
282 | } | 0 |
283 | return itm; never executed: return itm; | 0 |
284 | } | - |
285 | | - |
286 | QTableWidgetItem *QTableModel::takeVerticalHeaderItem(int section) | - |
287 | { | - |
288 | if (section < 0 || section >= verticalHeaderItems.count()) never evaluated: section < 0 never evaluated: section >= verticalHeaderItems.count() | 0 |
289 | return 0; never executed: return 0; | 0 |
290 | QTableWidgetItem *itm = verticalHeaderItems.at(section); | - |
291 | if (itm) { | 0 |
292 | itm->view = 0; | - |
293 | itm->itemFlags &= ~ItemIsHeaderItem; | - |
294 | verticalHeaderItems[section] = 0; | - |
295 | } | 0 |
296 | return itm; never executed: return itm; | 0 |
297 | } | - |
298 | | - |
299 | QTableWidgetItem *QTableModel::horizontalHeaderItem(int section) | - |
300 | { | - |
301 | return horizontalHeaderItems.value(section); executed: return horizontalHeaderItems.value(section); Execution Count:6 | 6 |
302 | } | - |
303 | | - |
304 | QTableWidgetItem *QTableModel::verticalHeaderItem(int section) | - |
305 | { | - |
306 | return verticalHeaderItems.value(section); executed: return verticalHeaderItems.value(section); Execution Count:4 | 4 |
307 | } | - |
308 | | - |
309 | QModelIndex QTableModel::index(const QTableWidgetItem *item) const | - |
310 | { | - |
311 | if (!item) evaluated: !item yes Evaluation Count:1 | yes Evaluation Count:64 |
| 1-64 |
312 | return QModelIndex(); executed: return QModelIndex(); Execution Count:1 | 1 |
313 | int i = -1; | - |
314 | const int id = item->d->id; | - |
315 | if (id >= 0 && id < tableItems.count() && tableItems.at(id) == item) { evaluated: id >= 0 yes Evaluation Count:60 | yes Evaluation Count:4 |
partially evaluated: id < tableItems.count() yes Evaluation Count:60 | no Evaluation Count:0 |
evaluated: tableItems.at(id) == item yes Evaluation Count:56 | yes Evaluation Count:4 |
| 0-60 |
316 | i = id; | - |
317 | } else { executed: } Execution Count:56 | 56 |
318 | i = tableItems.indexOf(const_cast<QTableWidgetItem*>(item)); | - |
319 | if (i == -1) evaluated: i == -1 yes Evaluation Count:7 | yes Evaluation Count:1 |
| 1-7 |
320 | return QModelIndex(); executed: return QModelIndex(); Execution Count:7 | 7 |
321 | } executed: } Execution Count:1 | 1 |
322 | int row = i / columnCount(); | - |
323 | int col = i % columnCount(); | - |
324 | return QAbstractTableModel::index(row, col); executed: return QAbstractTableModel::index(row, col); Execution Count:57 | 57 |
325 | } | - |
326 | | - |
327 | void QTableModel::setRowCount(int rows) | - |
328 | { | - |
329 | int rc = verticalHeaderItems.count(); | - |
330 | if (rows < 0 || rc == rows) evaluated: rows < 0 yes Evaluation Count:2 | yes Evaluation Count:285 |
evaluated: rc == rows yes Evaluation Count:65 | yes Evaluation Count:220 |
| 2-285 |
331 | return; executed: return; Execution Count:67 | 67 |
332 | if (rc < rows) evaluated: rc < rows yes Evaluation Count:158 | yes Evaluation Count:62 |
| 62-158 |
333 | insertRows(qMax(rc, 0), rows - rc); executed: insertRows(qMax(rc, 0), rows - rc); Execution Count:158 | 158 |
334 | else | - |
335 | removeRows(qMax(rows, 0), rc - rows); executed: removeRows(qMax(rows, 0), rc - rows); Execution Count:62 | 62 |
336 | } | - |
337 | | - |
338 | void QTableModel::setColumnCount(int columns) | - |
339 | { | - |
340 | int cc = horizontalHeaderItems.count(); | - |
341 | if (columns < 0 || cc == columns) evaluated: columns < 0 yes Evaluation Count:2 | yes Evaluation Count:286 |
evaluated: cc == columns yes Evaluation Count:90 | yes Evaluation Count:196 |
| 2-286 |
342 | return; executed: return; Execution Count:92 | 92 |
343 | if (cc < columns) evaluated: cc < columns yes Evaluation Count:146 | yes Evaluation Count:50 |
| 50-146 |
344 | insertColumns(qMax(cc, 0), columns - cc); executed: insertColumns(qMax(cc, 0), columns - cc); Execution Count:146 | 146 |
345 | else | - |
346 | removeColumns(qMax(columns, 0), cc - columns); executed: removeColumns(qMax(columns, 0), cc - columns); Execution Count:50 | 50 |
347 | } | - |
348 | | - |
349 | int QTableModel::rowCount(const QModelIndex &parent) const | - |
350 | { | - |
351 | return parent.isValid() ? 0 : verticalHeaderItems.count(); executed: return parent.isValid() ? 0 : verticalHeaderItems.count(); Execution Count:17923 | 17923 |
352 | } | - |
353 | | - |
354 | int QTableModel::columnCount(const QModelIndex &parent) const | - |
355 | { | - |
356 | return parent.isValid() ? 0 : horizontalHeaderItems.count(); executed: return parent.isValid() ? 0 : horizontalHeaderItems.count(); Execution Count:22214 | 22214 |
357 | } | - |
358 | | - |
359 | QVariant QTableModel::data(const QModelIndex &index, int role) const | - |
360 | { | - |
361 | QTableWidgetItem *itm = item(index); | - |
362 | if (itm) evaluated: itm yes Evaluation Count:1173 | yes Evaluation Count:555 |
| 555-1173 |
363 | return itm->data(role); executed: return itm->data(role); Execution Count:1173 | 1173 |
364 | return QVariant(); executed: return QVariant(); Execution Count:555 | 555 |
365 | } | - |
366 | | - |
367 | bool QTableModel::setData(const QModelIndex &index, const QVariant &value, int role) | - |
368 | { | - |
369 | if (!index.isValid()) evaluated: !index.isValid() yes Evaluation Count:5 | yes Evaluation Count:404 |
| 5-404 |
370 | return false; executed: return false; Execution Count:5 | 5 |
371 | | - |
372 | QTableWidgetItem *itm = item(index); | - |
373 | if (itm) { evaluated: itm yes Evaluation Count:3 | yes Evaluation Count:401 |
| 3-401 |
374 | itm->setData(role, value); | - |
375 | return true; executed: return true; Execution Count:3 | 3 |
376 | } | - |
377 | | - |
378 | | - |
379 | if (!value.isValid()) partially evaluated: !value.isValid() no Evaluation Count:0 | yes Evaluation Count:401 |
| 0-401 |
380 | return false; never executed: return false; | 0 |
381 | | - |
382 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
383 | if (!view) partially evaluated: !view no Evaluation Count:0 | yes Evaluation Count:401 |
| 0-401 |
384 | return false; never executed: return false; | 0 |
385 | | - |
386 | itm = createItem(); | - |
387 | itm->setData(role, value); | - |
388 | view->setItem(index.row(), index.column(), itm); | - |
389 | return true; executed: return true; Execution Count:401 | 401 |
390 | } | - |
391 | | - |
392 | QMap<int, QVariant> QTableModel::itemData(const QModelIndex &index) const | - |
393 | { | - |
394 | QMap<int, QVariant> roles; | - |
395 | QTableWidgetItem *itm = item(index); | - |
396 | if (itm) { evaluated: itm yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
397 | for (int i = 0; i < itm->values.count(); ++i) { evaluated: i < itm->values.count() yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
398 | roles.insert(itm->values.at(i).role, | - |
399 | itm->values.at(i).value); | - |
400 | } executed: } Execution Count:6 | 6 |
401 | } executed: } Execution Count:1 | 1 |
402 | return roles; executed: return roles; Execution Count:3 | 3 |
403 | } | - |
404 | | - |
405 | | - |
406 | bool QTableModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) | - |
407 | { | - |
408 | if (!index.isValid()) evaluated: !index.isValid() yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
409 | return false; executed: return false; Execution Count:2 | 2 |
410 | | - |
411 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
412 | QTableWidgetItem *itm = item(index); | - |
413 | if (itm) { partially evaluated: itm yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
414 | itm->view = 0; | - |
415 | bool changed = false; | - |
416 | for (QMap<int, QVariant>::ConstIterator it = roles.constBegin(); it != roles.constEnd(); ++it) { evaluated: it != roles.constEnd() yes Evaluation Count:5 | yes Evaluation Count:3 |
| 3-5 |
417 | if (itm->data(it.key()) != it.value()) { evaluated: itm->data(it.key()) != it.value() yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
418 | itm->setData(it.key(), it.value()); | - |
419 | changed = true; | - |
420 | } executed: } Execution Count:3 | 3 |
421 | } executed: } Execution Count:5 | 5 |
422 | itm->view = view; | - |
423 | if (changed) evaluated: changed yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
424 | itemChanged(itm); executed: itemChanged(itm); Execution Count:2 | 2 |
425 | return true; executed: return true; Execution Count:3 | 3 |
426 | } | - |
427 | | - |
428 | if (!view) | 0 |
429 | return false; never executed: return false; | 0 |
430 | | - |
431 | itm = createItem(); | - |
432 | for (QMap<int, QVariant>::ConstIterator it = roles.constBegin(); it != roles.constEnd(); ++it) never evaluated: it != roles.constEnd() | 0 |
433 | itm->setData(it.key(), it.value()); never executed: itm->setData(it.key(), it.value()); | 0 |
434 | view->setItem(index.row(), index.column(), itm); | - |
435 | return true; never executed: return true; | 0 |
436 | } | - |
437 | | - |
438 | Qt::ItemFlags QTableModel::flags(const QModelIndex &index) const | - |
439 | { | - |
440 | if (!index.isValid()) evaluated: !index.isValid() yes Evaluation Count:2 | yes Evaluation Count:745 |
| 2-745 |
441 | return Qt::ItemIsDropEnabled; executed: return Qt::ItemIsDropEnabled; Execution Count:2 | 2 |
442 | if (QTableWidgetItem *itm = item(index)) evaluated: QTableWidgetItem *itm = item(index) yes Evaluation Count:340 | yes Evaluation Count:405 |
| 340-405 |
443 | return itm->flags(); executed: return itm->flags(); Execution Count:340 | 340 |
444 | return (Qt::ItemIsEditable | 405 |
445 | |Qt::ItemIsSelectable | 405 |
446 | |Qt::ItemIsUserCheckable | 405 |
447 | |Qt::ItemIsEnabled | 405 |
448 | |Qt::ItemIsDragEnabled | 405 |
449 | |Qt::ItemIsDropEnabled); executed: return (Qt::ItemIsEditable |Qt::ItemIsSelectable |Qt::ItemIsUserCheckable |Qt::ItemIsEnabled |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled); Execution Count:405 | 405 |
450 | } | - |
451 | | - |
452 | void QTableModel::sort(int column, Qt::SortOrder order) | - |
453 | { | - |
454 | QVector<QPair<QTableWidgetItem*, int> > sortable; | - |
455 | QVector<int> unsortable; | - |
456 | | - |
457 | sortable.reserve(rowCount()); | - |
458 | unsortable.reserve(rowCount()); | - |
459 | | - |
460 | for (int row = 0; row < rowCount(); ++row) { evaluated: row < rowCount() yes Evaluation Count:408 | yes Evaluation Count:63 |
| 63-408 |
461 | if (QTableWidgetItem *itm = item(row, column)) evaluated: QTableWidgetItem *itm = item(row, column) yes Evaluation Count:145 | yes Evaluation Count:263 |
| 145-263 |
462 | sortable.append(QPair<QTableWidgetItem*,int>(itm, row)); executed: sortable.append(QPair<QTableWidgetItem*,int>(itm, row)); Execution Count:145 | 145 |
463 | else | - |
464 | unsortable.append(row); executed: unsortable.append(row); Execution Count:263 | 263 |
465 | } | - |
466 | | - |
467 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); evaluated: order == Qt::AscendingOrder yes Evaluation Count:51 | yes Evaluation Count:12 |
| 12-51 |
468 | qStableSort(sortable.begin(), sortable.end(), compare); | - |
469 | | - |
470 | QVector<QTableWidgetItem*> sorted_table(tableItems.count()); | - |
471 | QModelIndexList from; | - |
472 | QModelIndexList to; | - |
473 | for (int i = 0; i < rowCount(); ++i) { evaluated: i < rowCount() yes Evaluation Count:408 | yes Evaluation Count:63 |
| 63-408 |
474 | int r = (i < sortable.count() evaluated: i < sortable.count() yes Evaluation Count:145 | yes Evaluation Count:263 |
| 145-263 |
475 | ? sortable.at(i).second | - |
476 | : unsortable.at(i - sortable.count())); | - |
477 | for (int c = 0; c < columnCount(); ++c) { evaluated: c < columnCount() yes Evaluation Count:5312 | yes Evaluation Count:408 |
| 408-5312 |
478 | sorted_table[tableIndex(i, c)] = item(r, c); | - |
479 | from.append(createIndex(r, c)); | - |
480 | to.append(createIndex(i, c)); | - |
481 | } executed: } Execution Count:5312 | 5312 |
482 | } executed: } Execution Count:408 | 408 |
483 | | - |
484 | layoutAboutToBeChanged(); | - |
485 | | - |
486 | tableItems = sorted_table; | - |
487 | changePersistentIndexList(from, to); | - |
488 | | - |
489 | layoutChanged(); | - |
490 | } executed: } Execution Count:63 | 63 |
491 | void QTableModel::ensureSorted(int column, Qt::SortOrder order, | - |
492 | int start, int end) | - |
493 | { | - |
494 | int count = end - start + 1; | - |
495 | QVector < QPair<QTableWidgetItem*,int> > sorting; | - |
496 | sorting.reserve(count); | - |
497 | for (int row = start; row <= end; ++row) { evaluated: row <= end yes Evaluation Count:13 | yes Evaluation Count:13 |
| 13 |
498 | QTableWidgetItem *itm = item(row, column); | - |
499 | if (itm == 0) { partially evaluated: itm == 0 no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
500 | | - |
501 | | - |
502 | break; | 0 |
503 | } | - |
504 | sorting.append(QPair<QTableWidgetItem*,int>(itm, row)); | - |
505 | } executed: } Execution Count:13 | 13 |
506 | | - |
507 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); evaluated: order == Qt::AscendingOrder yes Evaluation Count:9 | yes Evaluation Count:4 |
| 4-9 |
508 | qStableSort(sorting.begin(), sorting.end(), compare); | - |
509 | | - |
510 | QModelIndexList oldPersistentIndexes = persistentIndexList(); | - |
511 | QModelIndexList newPersistentIndexes = oldPersistentIndexes; | - |
512 | QVector<QTableWidgetItem*> newTable = tableItems; | - |
513 | QVector<QTableWidgetItem*> newVertical = verticalHeaderItems; | - |
514 | QVector<QTableWidgetItem*> colItems = columnItems(column); | - |
515 | QVector<QTableWidgetItem*>::iterator vit = colItems.begin(); | - |
516 | bool changed = false; | - |
517 | for (int i = 0; i < sorting.count(); ++i) { evaluated: i < sorting.count() yes Evaluation Count:13 | yes Evaluation Count:13 |
| 13 |
518 | int oldRow = sorting.at(i).second; | - |
519 | QTableWidgetItem *item = colItems.at(oldRow); | - |
520 | colItems.remove(oldRow); | - |
521 | vit = sortedInsertionIterator(vit, colItems.end(), order, item); | - |
522 | int newRow = qMax((int)(vit - colItems.begin()), 0); | - |
523 | if ((newRow < oldRow) && !(*item < *colItems.at(oldRow - 1)) && !(*colItems.at(oldRow - 1) < *item)) evaluated: (newRow < oldRow) yes Evaluation Count:2 | yes Evaluation Count:11 |
partially evaluated: !(*item < *colItems.at(oldRow - 1)) yes Evaluation Count:2 | no Evaluation Count:0 |
evaluated: !(*colItems.at(oldRow - 1) < *item) yes Evaluation Count:1 | yes Evaluation Count:1 |
| 0-11 |
524 | newRow = oldRow; executed: newRow = oldRow; Execution Count:1 | 1 |
525 | vit = colItems.insert(vit, item); | - |
526 | if (newRow != oldRow) { evaluated: newRow != oldRow yes Evaluation Count:5 | yes Evaluation Count:8 |
| 5-8 |
527 | changed = true; | - |
528 | | - |
529 | int cc = columnCount(); | - |
530 | QVector<QTableWidgetItem*> rowItems(cc); | - |
531 | for (int j = 0; j < cc; ++j) evaluated: j < cc yes Evaluation Count:10 | yes Evaluation Count:5 |
| 5-10 |
532 | rowItems[j] = newTable.at(tableIndex(oldRow, j)); executed: rowItems[j] = newTable.at(tableIndex(oldRow, j)); Execution Count:10 | 10 |
533 | newTable.remove(tableIndex(oldRow, 0), cc); | - |
534 | newTable.insert(tableIndex(newRow, 0), cc, 0); | - |
535 | for (int j = 0; j < cc; ++j) evaluated: j < cc yes Evaluation Count:10 | yes Evaluation Count:5 |
| 5-10 |
536 | newTable[tableIndex(newRow, j)] = rowItems.at(j); executed: newTable[tableIndex(newRow, j)] = rowItems.at(j); Execution Count:10 | 10 |
537 | QTableWidgetItem *header = newVertical.at(oldRow); | - |
538 | newVertical.remove(oldRow); | - |
539 | newVertical.insert(newRow, header); | - |
540 | | - |
541 | updateRowIndexes(newPersistentIndexes, oldRow, newRow); | - |
542 | | - |
543 | for (int j = i + 1; j < sorting.count(); ++j) { partially evaluated: j < sorting.count() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
544 | int otherRow = sorting.at(j).second; | - |
545 | if (oldRow < otherRow && newRow >= otherRow) never evaluated: oldRow < otherRow never evaluated: newRow >= otherRow | 0 |
546 | --sorting[j].second; never executed: --sorting[j].second; | 0 |
547 | else if (oldRow > otherRow && newRow <= otherRow) never evaluated: oldRow > otherRow never evaluated: newRow <= otherRow | 0 |
548 | ++sorting[j].second; never executed: ++sorting[j].second; | 0 |
549 | } | - |
550 | } executed: } Execution Count:5 | 5 |
551 | } executed: } Execution Count:13 | 13 |
552 | | - |
553 | if (changed) { evaluated: changed yes Evaluation Count:5 | yes Evaluation Count:8 |
| 5-8 |
554 | layoutAboutToBeChanged(); | - |
555 | tableItems = newTable; | - |
556 | verticalHeaderItems = newVertical; | - |
557 | changePersistentIndexList(oldPersistentIndexes, | - |
558 | newPersistentIndexes); | - |
559 | layoutChanged(); | - |
560 | } executed: } Execution Count:5 | 5 |
561 | } executed: } Execution Count:13 | 13 |
562 | | - |
563 | | - |
564 | | - |
565 | | - |
566 | | - |
567 | | - |
568 | QVector<QTableWidgetItem*> QTableModel::columnItems(int column) const | - |
569 | { | - |
570 | QVector<QTableWidgetItem*> items; | - |
571 | int rc = rowCount(); | - |
572 | items.reserve(rc); | - |
573 | for (int row = 0; row < rc; ++row) { evaluated: row < rc yes Evaluation Count:103 | yes Evaluation Count:21 |
| 21-103 |
574 | QTableWidgetItem *itm = item(row, column); | - |
575 | if (itm == 0) { evaluated: itm == 0 yes Evaluation Count:8 | yes Evaluation Count:95 |
| 8-95 |
576 | | - |
577 | | - |
578 | break; executed: break; Execution Count:8 | 8 |
579 | } | - |
580 | items.append(itm); | - |
581 | } executed: } Execution Count:95 | 95 |
582 | return items; executed: return items; Execution Count:29 | 29 |
583 | } | - |
584 | void QTableModel::updateRowIndexes(QModelIndexList &indexes, | - |
585 | int movedFromRow, int movedToRow) | - |
586 | { | - |
587 | QModelIndexList::iterator it; | - |
588 | for (it = indexes.begin(); it != indexes.end(); ++it) { evaluated: it != indexes.end() yes Evaluation Count:39 | yes Evaluation Count:17 |
| 17-39 |
589 | int oldRow = (*it).row(); | - |
590 | int newRow = oldRow; | - |
591 | if (oldRow == movedFromRow) evaluated: oldRow == movedFromRow yes Evaluation Count:10 | yes Evaluation Count:29 |
| 10-29 |
592 | newRow = movedToRow; executed: newRow = movedToRow; Execution Count:10 | 10 |
593 | else if (movedFromRow < oldRow && movedToRow >= oldRow) evaluated: movedFromRow < oldRow yes Evaluation Count:16 | yes Evaluation Count:13 |
evaluated: movedToRow >= oldRow yes Evaluation Count:12 | yes Evaluation Count:4 |
| 4-16 |
594 | newRow = oldRow - 1; executed: newRow = oldRow - 1; Execution Count:12 | 12 |
595 | else if (movedFromRow > oldRow && movedToRow <= oldRow) evaluated: movedFromRow > oldRow yes Evaluation Count:13 | yes Evaluation Count:4 |
evaluated: movedToRow <= oldRow yes Evaluation Count:9 | yes Evaluation Count:4 |
| 4-13 |
596 | newRow = oldRow + 1; executed: newRow = oldRow + 1; Execution Count:9 | 9 |
597 | if (newRow != oldRow) evaluated: newRow != oldRow yes Evaluation Count:31 | yes Evaluation Count:8 |
| 8-31 |
598 | *it = index(newRow, (*it).column(), (*it).parent()); executed: *it = index(newRow, (*it).column(), (*it).parent()); Execution Count:31 | 31 |
599 | } executed: } Execution Count:39 | 39 |
600 | } executed: } Execution Count:17 | 17 |
601 | QVector<QTableWidgetItem*>::iterator QTableModel::sortedInsertionIterator( | - |
602 | const QVector<QTableWidgetItem*>::iterator &begin, | - |
603 | const QVector<QTableWidgetItem*>::iterator &end, | - |
604 | Qt::SortOrder order, QTableWidgetItem *item) | - |
605 | { | - |
606 | if (order == Qt::AscendingOrder) evaluated: order == Qt::AscendingOrder yes Evaluation Count:15 | yes Evaluation Count:14 |
| 14-15 |
607 | return std::lower_bound(begin, end, item, QTableModelLessThan()); executed: return std::lower_bound(begin, end, item, QTableModelLessThan()); Execution Count:15 | 15 |
608 | return std::lower_bound(begin, end, item, QTableModelGreaterThan()); executed: return std::lower_bound(begin, end, item, QTableModelGreaterThan()); Execution Count:14 | 14 |
609 | } | - |
610 | | - |
611 | bool QTableModel::itemLessThan(const QPair<QTableWidgetItem*,int> &left, | - |
612 | const QPair<QTableWidgetItem*,int> &right) | - |
613 | { | - |
614 | return *(left.first) < *(right.first); executed: return *(left.first) < *(right.first); Execution Count:154 | 154 |
615 | } | - |
616 | | - |
617 | bool QTableModel::itemGreaterThan(const QPair<QTableWidgetItem*,int> &left, | - |
618 | const QPair<QTableWidgetItem*,int> &right) | - |
619 | { | - |
620 | return (*(right.first) < *(left .first)); executed: return (*(right.first) < *(left .first)); Execution Count:23 | 23 |
621 | } | - |
622 | | - |
623 | QVariant QTableModel::headerData(int section, Qt::Orientation orientation, int role) const | - |
624 | { | - |
625 | if (section < 0) partially evaluated: section < 0 no Evaluation Count:0 | yes Evaluation Count:19531 |
| 0-19531 |
626 | return QVariant(); never executed: return QVariant(); | 0 |
627 | | - |
628 | QTableWidgetItem *itm = 0; | - |
629 | if (orientation == Qt::Horizontal && section < horizontalHeaderItems.count()) evaluated: orientation == Qt::Horizontal yes Evaluation Count:13632 | yes Evaluation Count:5899 |
evaluated: section < horizontalHeaderItems.count() yes Evaluation Count:13631 | yes Evaluation Count:1 |
| 1-13632 |
630 | itm = horizontalHeaderItems.at(section); executed: itm = horizontalHeaderItems.at(section); Execution Count:13631 | 13631 |
631 | else if (orientation == Qt::Vertical && section < verticalHeaderItems.count()) evaluated: orientation == Qt::Vertical yes Evaluation Count:5899 | yes Evaluation Count:1 |
partially evaluated: section < verticalHeaderItems.count() yes Evaluation Count:5899 | no Evaluation Count:0 |
| 0-5899 |
632 | itm = verticalHeaderItems.at(section); executed: itm = verticalHeaderItems.at(section); Execution Count:5899 | 5899 |
633 | else | - |
634 | return QVariant(); executed: return QVariant(); Execution Count:1 | 1 |
635 | | - |
636 | if (itm) evaluated: itm yes Evaluation Count:121 | yes Evaluation Count:19409 |
| 121-19409 |
637 | return itm->data(role); executed: return itm->data(role); Execution Count:121 | 121 |
638 | if (role == Qt::DisplayRole) evaluated: role == Qt::DisplayRole yes Evaluation Count:4810 | yes Evaluation Count:14599 |
| 4810-14599 |
639 | return section + 1; executed: return section + 1; Execution Count:4810 | 4810 |
640 | return QVariant(); executed: return QVariant(); Execution Count:14599 | 14599 |
641 | } | - |
642 | | - |
643 | bool QTableModel::setHeaderData(int section, Qt::Orientation orientation, | - |
644 | const QVariant &value, int role) | - |
645 | { | - |
646 | if (section < 0 || evaluated: section < 0 yes Evaluation Count:6 | yes Evaluation Count:12 |
| 6-12 |
647 | (orientation == Qt::Horizontal && horizontalHeaderItems.size() <= section) || evaluated: orientation == Qt::Horizontal yes Evaluation Count:8 | yes Evaluation Count:4 |
evaluated: horizontalHeaderItems.size() <= section yes Evaluation Count:3 | yes Evaluation Count:5 |
| 3-8 |
648 | (orientation == Qt::Vertical && verticalHeaderItems.size() <= section)) evaluated: orientation == Qt::Vertical yes Evaluation Count:4 | yes Evaluation Count:5 |
partially evaluated: verticalHeaderItems.size() <= section no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-5 |
649 | return false; executed: return false; Execution Count:9 | 9 |
650 | | - |
651 | QTableWidgetItem *itm = 0; | - |
652 | if (orientation == Qt::Horizontal) evaluated: orientation == Qt::Horizontal yes Evaluation Count:5 | yes Evaluation Count:4 |
| 4-5 |
653 | itm = horizontalHeaderItems.at(section); executed: itm = horizontalHeaderItems.at(section); Execution Count:5 | 5 |
654 | else | - |
655 | itm = verticalHeaderItems.at(section); executed: itm = verticalHeaderItems.at(section); Execution Count:4 | 4 |
656 | if (itm) { partially evaluated: itm no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
657 | itm->setData(role, value); | - |
658 | return true; never executed: return true; | 0 |
659 | } | - |
660 | return false; executed: return false; Execution Count:9 | 9 |
661 | } | - |
662 | | - |
663 | bool QTableModel::isValid(const QModelIndex &index) const | - |
664 | { | - |
665 | return (index.isValid() | 10549 |
666 | && index.row() < verticalHeaderItems.count() | 10549 |
667 | && index.column() < horizontalHeaderItems.count()); executed: return (index.isValid() && index.row() < verticalHeaderItems.count() && index.column() < horizontalHeaderItems.count()); Execution Count:10549 | 10549 |
668 | } | - |
669 | | - |
670 | void QTableModel::clear() | - |
671 | { | - |
672 | for (int j = 0; j < verticalHeaderItems.count(); ++j) { evaluated: j < verticalHeaderItems.count() yes Evaluation Count:2436 | yes Evaluation Count:231 |
| 231-2436 |
673 | if (verticalHeaderItems.at(j)) { evaluated: verticalHeaderItems.at(j) yes Evaluation Count:3 | yes Evaluation Count:2433 |
| 3-2433 |
674 | verticalHeaderItems.at(j)->view = 0; | - |
675 | delete verticalHeaderItems.at(j); | - |
676 | verticalHeaderItems[j] = 0; | - |
677 | } executed: } Execution Count:3 | 3 |
678 | } executed: } Execution Count:2436 | 2436 |
679 | for (int k = 0; k < horizontalHeaderItems.count(); ++k) { evaluated: k < horizontalHeaderItems.count() yes Evaluation Count:3240 | yes Evaluation Count:231 |
| 231-3240 |
680 | if (horizontalHeaderItems.at(k)) { evaluated: horizontalHeaderItems.at(k) yes Evaluation Count:7 | yes Evaluation Count:3233 |
| 7-3233 |
681 | horizontalHeaderItems.at(k)->view = 0; | - |
682 | delete horizontalHeaderItems.at(k); | - |
683 | horizontalHeaderItems[k] = 0; | - |
684 | } executed: } Execution Count:7 | 7 |
685 | } executed: } Execution Count:3240 | 3240 |
686 | clearContents(); | - |
687 | } executed: } Execution Count:231 | 231 |
688 | | - |
689 | void QTableModel::clearContents() | - |
690 | { | - |
691 | beginResetModel(); | - |
692 | for (int i = 0; i < tableItems.count(); ++i) { evaluated: i < tableItems.count() yes Evaluation Count:141455 | yes Evaluation Count:232 |
| 232-141455 |
693 | if (tableItems.at(i)) { evaluated: tableItems.at(i) yes Evaluation Count:937 | yes Evaluation Count:140518 |
| 937-140518 |
694 | tableItems.at(i)->view = 0; | - |
695 | delete tableItems.at(i); | - |
696 | tableItems[i] = 0; | - |
697 | } executed: } Execution Count:937 | 937 |
698 | } executed: } Execution Count:141455 | 141455 |
699 | endResetModel(); | - |
700 | } executed: } Execution Count:232 | 232 |
701 | | - |
702 | void QTableModel::itemChanged(QTableWidgetItem *item) | - |
703 | { | - |
704 | if (!item) partially evaluated: !item no Evaluation Count:0 | yes Evaluation Count:29 |
| 0-29 |
705 | return; | 0 |
706 | if (item->flags() & ItemIsHeaderItem) { evaluated: item->flags() & ItemIsHeaderItem yes Evaluation Count:6 | yes Evaluation Count:23 |
| 6-23 |
707 | int row = verticalHeaderItems.indexOf(item); | - |
708 | if (row >= 0) { evaluated: row >= 0 yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
709 | headerDataChanged(Qt::Vertical, row, row); | - |
710 | } else { executed: } Execution Count:3 | 3 |
711 | int column = horizontalHeaderItems.indexOf(item); | - |
712 | if (column >= 0) partially evaluated: column >= 0 yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
713 | headerDataChanged(Qt::Horizontal, column, column); executed: headerDataChanged(Qt::Horizontal, column, column); Execution Count:3 | 3 |
714 | } executed: } Execution Count:3 | 3 |
715 | } else { | - |
716 | QModelIndex idx = index(item); | - |
717 | if (idx.isValid()) partially evaluated: idx.isValid() yes Evaluation Count:23 | no Evaluation Count:0 |
| 0-23 |
718 | dataChanged(idx, idx); executed: dataChanged(idx, idx); Execution Count:23 | 23 |
719 | } executed: } Execution Count:23 | 23 |
720 | } | - |
721 | | - |
722 | QTableWidgetItem* QTableModel::createItem() const | - |
723 | { | - |
724 | return prototype ? prototype->clone() : new QTableWidgetItem; executed: return prototype ? prototype->clone() : new QTableWidgetItem; Execution Count:407 | 407 |
725 | } | - |
726 | | - |
727 | const QTableWidgetItem *QTableModel::itemPrototype() const | - |
728 | { | - |
729 | return prototype; executed: return prototype; Execution Count:2 | 2 |
730 | } | - |
731 | | - |
732 | void QTableModel::setItemPrototype(const QTableWidgetItem *item) | - |
733 | { | - |
734 | if (prototype != item) { partially evaluated: prototype != item yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
735 | delete prototype; | - |
736 | prototype = item; | - |
737 | } executed: } Execution Count:2 | 2 |
738 | } executed: } Execution Count:2 | 2 |
739 | | - |
740 | QStringList QTableModel::mimeTypes() const | - |
741 | { | - |
742 | const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent()); | - |
743 | return (view ? view->mimeTypes() : QStringList()); executed: return (view ? view->mimeTypes() : QStringList()); Execution Count:2 | 2 |
744 | } | - |
745 | | - |
746 | QMimeData *QTableModel::internalMimeData() const | - |
747 | { | - |
748 | return QAbstractTableModel::mimeData(cachedIndexes); never executed: return QAbstractTableModel::mimeData(cachedIndexes); | 0 |
749 | } | - |
750 | | - |
751 | QMimeData *QTableModel::mimeData(const QModelIndexList &indexes) const | - |
752 | { | - |
753 | QList<QTableWidgetItem*> items; | - |
754 | for (int i = 0; i < indexes.count(); ++i) never evaluated: i < indexes.count() | 0 |
755 | items << item(indexes.at(i)); never executed: items << item(indexes.at(i)); | 0 |
756 | const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent()); | - |
757 | | - |
758 | | - |
759 | | - |
760 | cachedIndexes = indexes; | - |
761 | QMimeData *mimeData = (view ? view->mimeData(items) : 0); | 0 |
762 | cachedIndexes.clear(); | - |
763 | return mimeData; never executed: return mimeData; | 0 |
764 | } | - |
765 | | - |
766 | bool QTableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, | - |
767 | int row , int column, const QModelIndex &index) | - |
768 | { | - |
769 | if (index.isValid()) { never evaluated: index.isValid() | 0 |
770 | row = index.row(); | - |
771 | column = index.column(); | - |
772 | }else if (row == -1 || column == -1) { never evaluated: row == -1 never evaluated: column == -1 | 0 |
773 | row = rowCount(); | - |
774 | column = 0; | - |
775 | } | 0 |
776 | | - |
777 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
778 | return (view ? view->dropMimeData(row, column, data, action) : false); never executed: return (view ? view->dropMimeData(row, column, data, action) : false); | 0 |
779 | } | - |
780 | | - |
781 | Qt::DropActions QTableModel::supportedDropActions() const | - |
782 | { | - |
783 | const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent()); | - |
784 | return (view ? view->supportedDropActions() : Qt::DropActions(Qt::IgnoreAction)); executed: return (view ? view->supportedDropActions() : Qt::DropActions(Qt::IgnoreAction)); Execution Count:2 | 2 |
785 | } | - |
786 | QTableWidgetSelectionRange::QTableWidgetSelectionRange() | - |
787 | : top(-1), left(-1), bottom(-2), right(-2) | - |
788 | { | - |
789 | } executed: } Execution Count:1 | 1 |
790 | | - |
791 | | - |
792 | | - |
793 | | - |
794 | | - |
795 | | - |
796 | | - |
797 | QTableWidgetSelectionRange::QTableWidgetSelectionRange(int top, int left, int bottom, int right) | - |
798 | : top(top), left(left), bottom(bottom), right(right) | - |
799 | { | - |
800 | } executed: } Execution Count:60 | 60 |
801 | | - |
802 | | - |
803 | | - |
804 | | - |
805 | | - |
806 | QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other) | - |
807 | : top(other.top), left(other.left), bottom(other.bottom), right(other.right) | - |
808 | { | - |
809 | } executed: } Execution Count:72 | 72 |
810 | | - |
811 | | - |
812 | | - |
813 | | - |
814 | QTableWidgetSelectionRange::~QTableWidgetSelectionRange() | - |
815 | { | - |
816 | } | - |
817 | void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) | - |
818 | { | - |
819 | itemFlags = aflags; | - |
820 | if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0)) evaluated: view yes Evaluation Count:2 | yes Evaluation Count:15 |
| 2-15 |
821 | model->itemChanged(this); executed: model->itemChanged(this); Execution Count:2 | 2 |
822 | } executed: } Execution Count:17 | 17 |
823 | QTableWidgetItem::QTableWidgetItem(int type) | - |
824 | : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)), | - |
825 | itemFlags(Qt::ItemIsEditable | - |
826 | |Qt::ItemIsSelectable | - |
827 | |Qt::ItemIsUserCheckable | - |
828 | |Qt::ItemIsEnabled | - |
829 | |Qt::ItemIsDragEnabled | - |
830 | |Qt::ItemIsDropEnabled) | - |
831 | { | - |
832 | } executed: } Execution Count:451 | 451 |
833 | | - |
834 | | - |
835 | | - |
836 | | - |
837 | | - |
838 | | - |
839 | QTableWidgetItem::QTableWidgetItem(const QString &text, int type) | - |
840 | : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)), | - |
841 | itemFlags(Qt::ItemIsEditable | - |
842 | |Qt::ItemIsSelectable | - |
843 | |Qt::ItemIsUserCheckable | - |
844 | |Qt::ItemIsEnabled | - |
845 | |Qt::ItemIsDragEnabled | - |
846 | |Qt::ItemIsDropEnabled) | - |
847 | { | - |
848 | setData(Qt::DisplayRole, text); | - |
849 | } executed: } Execution Count:555 | 555 |
850 | | - |
851 | | - |
852 | | - |
853 | | - |
854 | | - |
855 | | - |
856 | QTableWidgetItem::QTableWidgetItem(const QIcon &icon, const QString &text, int type) | - |
857 | : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)), | - |
858 | itemFlags(Qt::ItemIsEditable | - |
859 | |Qt::ItemIsSelectable | - |
860 | |Qt::ItemIsUserCheckable | - |
861 | |Qt::ItemIsEnabled | - |
862 | |Qt::ItemIsDragEnabled | - |
863 | |Qt::ItemIsDropEnabled) | - |
864 | { | - |
865 | setData(Qt::DecorationRole, icon); | - |
866 | setData(Qt::DisplayRole, text); | - |
867 | } | 0 |
868 | | - |
869 | | - |
870 | | - |
871 | | - |
872 | QTableWidgetItem::~QTableWidgetItem() | - |
873 | { | - |
874 | if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0)) evaluated: view yes Evaluation Count:5 | yes Evaluation Count:1001 |
| 5-1001 |
875 | model->removeItem(this); executed: model->removeItem(this); Execution Count:5 | 5 |
876 | view = 0; | - |
877 | delete d; | - |
878 | } executed: } Execution Count:1006 | 1006 |
879 | | - |
880 | | - |
881 | | - |
882 | | - |
883 | QTableWidgetItem *QTableWidgetItem::clone() const | - |
884 | { | - |
885 | return new QTableWidgetItem(*this); never executed: return new QTableWidgetItem(*this); | 0 |
886 | } | - |
887 | | - |
888 | | - |
889 | | - |
890 | | - |
891 | | - |
892 | | - |
893 | void QTableWidgetItem::setData(int role, const QVariant &value) | - |
894 | { | - |
895 | bool found = false; | - |
896 | role = (role == Qt::EditRole ? Qt::DisplayRole : role); evaluated: role == Qt::EditRole yes Evaluation Count:404 | yes Evaluation Count:605 |
| 404-605 |
897 | for (int i = 0; i < values.count(); ++i) { evaluated: i < values.count() yes Evaluation Count:34 | yes Evaluation Count:996 |
| 34-996 |
898 | if (values.at(i).role == role) { evaluated: values.at(i).role == role yes Evaluation Count:13 | yes Evaluation Count:21 |
| 13-21 |
899 | if (values[i].value == value) partially evaluated: values[i].value == value no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
900 | return; | 0 |
901 | | - |
902 | values[i].value = value; | - |
903 | found = true; | - |
904 | break; executed: break; Execution Count:13 | 13 |
905 | } | - |
906 | } executed: } Execution Count:21 | 21 |
907 | if (!found) evaluated: !found yes Evaluation Count:996 | yes Evaluation Count:13 |
| 13-996 |
908 | values.append(QWidgetItemData(role, value)); executed: values.append(QWidgetItemData(role, value)); Execution Count:996 | 996 |
909 | if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0)) evaluated: view yes Evaluation Count:25 | yes Evaluation Count:984 |
| 25-984 |
910 | model->itemChanged(this); executed: model->itemChanged(this); Execution Count:25 | 25 |
911 | } executed: } Execution Count:1009 | 1009 |
912 | | - |
913 | | - |
914 | | - |
915 | | - |
916 | QVariant QTableWidgetItem::data(int role) const | - |
917 | { | - |
918 | role = (role == Qt::EditRole ? Qt::DisplayRole : role); evaluated: role == Qt::EditRole yes Evaluation Count:18 | yes Evaluation Count:2159 |
| 18-2159 |
919 | for (int i = 0; i < values.count(); ++i) evaluated: i < values.count() yes Evaluation Count:2153 | yes Evaluation Count:701 |
| 701-2153 |
920 | if (values.at(i).role == role) evaluated: values.at(i).role == role yes Evaluation Count:1476 | yes Evaluation Count:677 |
| 677-1476 |
921 | return values.at(i).value; executed: return values.at(i).value; Execution Count:1476 | 1476 |
922 | return QVariant(); executed: return QVariant(); Execution Count:701 | 701 |
923 | } | - |
924 | | - |
925 | | - |
926 | | - |
927 | | - |
928 | | - |
929 | bool QTableWidgetItem::operator<(const QTableWidgetItem &other) const | - |
930 | { | - |
931 | const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); | - |
932 | return QAbstractItemModelPrivate::variantLessThan(v1, v2); executed: return QAbstractItemModelPrivate::variantLessThan(v1, v2); Execution Count:224 | 224 |
933 | } | - |
934 | void QTableWidgetItem::read(QDataStream &in) | - |
935 | { | - |
936 | in >> values; | - |
937 | } executed: } Execution Count:1 | 1 |
938 | | - |
939 | | - |
940 | | - |
941 | | - |
942 | | - |
943 | | - |
944 | void QTableWidgetItem::write(QDataStream &out) const | - |
945 | { | - |
946 | out << values; | - |
947 | } executed: } Execution Count:1 | 1 |
948 | QDataStream &operator>>(QDataStream &in, QTableWidgetItem &item) | - |
949 | { | - |
950 | item.read(in); | - |
951 | return in; executed: return in; Execution Count:1 | 1 |
952 | } | - |
953 | QDataStream &operator<<(QDataStream &out, const QTableWidgetItem &item) | - |
954 | { | - |
955 | item.write(out); | - |
956 | return out; executed: return out; Execution Count:1 | 1 |
957 | } | - |
958 | QTableWidgetItem::QTableWidgetItem(const QTableWidgetItem &other) | - |
959 | : rtti(Type), values(other.values), view(0), | - |
960 | d(new QTableWidgetItemPrivate(this)), | - |
961 | itemFlags(other.itemFlags) | - |
962 | { | - |
963 | } | 0 |
964 | QTableWidgetItem &QTableWidgetItem::operator=(const QTableWidgetItem &other) | - |
965 | { | - |
966 | values = other.values; | - |
967 | itemFlags = other.itemFlags; | - |
968 | return *this; executed: return *this; Execution Count:1 | 1 |
969 | } | - |
970 | void QTableWidgetPrivate::setup() | - |
971 | { | - |
972 | QTableWidget * const q = q_func(); | - |
973 | | - |
974 | QObject::connect(q, "2""pressed(QModelIndex)", q, "1""_q_emitItemPressed(QModelIndex)"); | - |
975 | QObject::connect(q, "2""clicked(QModelIndex)", q, "1""_q_emitItemClicked(QModelIndex)"); | - |
976 | QObject::connect(q, "2""doubleClicked(QModelIndex)", | - |
977 | q, "1""_q_emitItemDoubleClicked(QModelIndex)"); | - |
978 | QObject::connect(q, "2""activated(QModelIndex)", q, "1""_q_emitItemActivated(QModelIndex)"); | - |
979 | QObject::connect(q, "2""entered(QModelIndex)", q, "1""_q_emitItemEntered(QModelIndex)"); | - |
980 | | - |
981 | QObject::connect(model, "2""dataChanged(QModelIndex,QModelIndex)", | - |
982 | q, "1""_q_emitItemChanged(QModelIndex)"); | - |
983 | | - |
984 | QObject::connect(q->selectionModel(), "2""currentChanged(QModelIndex,QModelIndex)", | - |
985 | q, "1""_q_emitCurrentItemChanged(QModelIndex,QModelIndex)"); | - |
986 | QObject::connect(q->selectionModel(), "2""selectionChanged(QItemSelection,QItemSelection)", | - |
987 | q, "2""itemSelectionChanged()"); | - |
988 | | - |
989 | QObject::connect(model, "2""dataChanged(QModelIndex,QModelIndex)", | - |
990 | q, "1""_q_dataChanged(QModelIndex,QModelIndex)"); | - |
991 | QObject::connect(model, "2""columnsRemoved(QModelIndex,int,int)", q, "1""_q_sort()"); | - |
992 | } executed: } Execution Count:146 | 146 |
993 | | - |
994 | void QTableWidgetPrivate::_q_emitItemPressed(const QModelIndex &index) | - |
995 | { | - |
996 | QTableWidget * const q = q_func(); | - |
997 | if (QTableWidgetItem *item = tableModel()->item(index)) evaluated: QTableWidgetItem *item = tableModel()->item(index) yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
998 | q->itemPressed(item); executed: q->itemPressed(item); Execution Count:1 | 1 |
999 | q->cellPressed(index.row(), index.column()); | - |
1000 | } executed: } Execution Count:3 | 3 |
1001 | | - |
1002 | void QTableWidgetPrivate::_q_emitItemClicked(const QModelIndex &index) | - |
1003 | { | - |
1004 | QTableWidget * const q = q_func(); | - |
1005 | if (QTableWidgetItem *item = tableModel()->item(index)) evaluated: QTableWidgetItem *item = tableModel()->item(index) yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1006 | q->itemClicked(item); executed: q->itemClicked(item); Execution Count:1 | 1 |
1007 | q->cellClicked(index.row(), index.column()); | - |
1008 | } executed: } Execution Count:2 | 2 |
1009 | | - |
1010 | void QTableWidgetPrivate::_q_emitItemDoubleClicked(const QModelIndex &index) | - |
1011 | { | - |
1012 | QTableWidget * const q = q_func(); | - |
1013 | if (QTableWidgetItem *item = tableModel()->item(index)) never evaluated: QTableWidgetItem *item = tableModel()->item(index) | 0 |
1014 | q->itemDoubleClicked(item); never executed: q->itemDoubleClicked(item); | 0 |
1015 | q->cellDoubleClicked(index.row(), index.column()); | - |
1016 | } | 0 |
1017 | | - |
1018 | void QTableWidgetPrivate::_q_emitItemActivated(const QModelIndex &index) | - |
1019 | { | - |
1020 | QTableWidget * const q = q_func(); | - |
1021 | if (QTableWidgetItem *item = tableModel()->item(index)) never evaluated: QTableWidgetItem *item = tableModel()->item(index) | 0 |
1022 | q->itemActivated(item); never executed: q->itemActivated(item); | 0 |
1023 | q->cellActivated(index.row(), index.column()); | - |
1024 | } | 0 |
1025 | | - |
1026 | void QTableWidgetPrivate::_q_emitItemEntered(const QModelIndex &index) | - |
1027 | { | - |
1028 | QTableWidget * const q = q_func(); | - |
1029 | if (QTableWidgetItem *item = tableModel()->item(index)) partially evaluated: QTableWidgetItem *item = tableModel()->item(index) no Evaluation Count:0 | yes Evaluation Count:46 |
| 0-46 |
1030 | q->itemEntered(item); never executed: q->itemEntered(item); | 0 |
1031 | q->cellEntered(index.row(), index.column()); | - |
1032 | } executed: } Execution Count:46 | 46 |
1033 | | - |
1034 | void QTableWidgetPrivate::_q_emitItemChanged(const QModelIndex &index) | - |
1035 | { | - |
1036 | QTableWidget * const q = q_func(); | - |
1037 | if (QTableWidgetItem *item = tableModel()->item(index)) evaluated: QTableWidgetItem *item = tableModel()->item(index) yes Evaluation Count:995 | yes Evaluation Count:7 |
| 7-995 |
1038 | q->itemChanged(item); executed: q->itemChanged(item); Execution Count:995 | 995 |
1039 | q->cellChanged(index.row(), index.column()); | - |
1040 | } executed: } Execution Count:1002 | 1002 |
1041 | | - |
1042 | void QTableWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, | - |
1043 | const QModelIndex &previous) | - |
1044 | { | - |
1045 | QTableWidget * const q = q_func(); | - |
1046 | QTableWidgetItem *currentItem = tableModel()->item(current); | - |
1047 | QTableWidgetItem *previousItem = tableModel()->item(previous); | - |
1048 | if (currentItem || previousItem) evaluated: currentItem yes Evaluation Count:7 | yes Evaluation Count:57 |
evaluated: previousItem yes Evaluation Count:1 | yes Evaluation Count:56 |
| 1-57 |
1049 | q->currentItemChanged(currentItem, previousItem); executed: q->currentItemChanged(currentItem, previousItem); Execution Count:8 | 8 |
1050 | q->currentCellChanged(current.row(), current.column(), previous.row(), previous.column()); | - |
1051 | } executed: } Execution Count:64 | 64 |
1052 | | - |
1053 | void QTableWidgetPrivate::_q_sort() | - |
1054 | { | - |
1055 | if (sortingEnabled) { partially evaluated: sortingEnabled no Evaluation Count:0 | yes Evaluation Count:69 |
| 0-69 |
1056 | int column = horizontalHeader->sortIndicatorSection(); | - |
1057 | Qt::SortOrder order = horizontalHeader->sortIndicatorOrder(); | - |
1058 | model->sort(column, order); | - |
1059 | } | 0 |
1060 | } executed: } Execution Count:69 | 69 |
1061 | | - |
1062 | void QTableWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, | - |
1063 | const QModelIndex &bottomRight) | - |
1064 | { | - |
1065 | if (sortingEnabled && topLeft.isValid() && bottomRight.isValid()) { evaluated: sortingEnabled yes Evaluation Count:23 | yes Evaluation Count:979 |
partially evaluated: topLeft.isValid() yes Evaluation Count:23 | no Evaluation Count:0 |
partially evaluated: bottomRight.isValid() yes Evaluation Count:23 | no Evaluation Count:0 |
| 0-979 |
1066 | int column = horizontalHeader->sortIndicatorSection(); | - |
1067 | if (column >= topLeft.column() && column <= bottomRight.column()) { evaluated: column >= topLeft.column() yes Evaluation Count:15 | yes Evaluation Count:8 |
evaluated: column <= bottomRight.column() yes Evaluation Count:13 | yes Evaluation Count:2 |
| 2-15 |
1068 | Qt::SortOrder order = horizontalHeader->sortIndicatorOrder(); | - |
1069 | tableModel()->ensureSorted(column, order, topLeft.row(), bottomRight.row()); | - |
1070 | } executed: } Execution Count:13 | 13 |
1071 | } executed: } Execution Count:23 | 23 |
1072 | } executed: } Execution Count:1002 | 1002 |
1073 | QTableWidget::QTableWidget(QWidget *parent) | - |
1074 | : QTableView(*new QTableWidgetPrivate, parent) | - |
1075 | { | - |
1076 | QTableWidgetPrivate * const d = d_func(); | - |
1077 | QTableView::setModel(new QTableModel(0, 0, this)); | - |
1078 | d->setup(); | - |
1079 | } executed: } Execution Count:106 | 106 |
1080 | | - |
1081 | | - |
1082 | | - |
1083 | | - |
1084 | QTableWidget::QTableWidget(int rows, int columns, QWidget *parent) | - |
1085 | : QTableView(*new QTableWidgetPrivate, parent) | - |
1086 | { | - |
1087 | QTableWidgetPrivate * const d = d_func(); | - |
1088 | QTableView::setModel(new QTableModel(rows, columns, this)); | - |
1089 | d->setup(); | - |
1090 | } executed: } Execution Count:40 | 40 |
1091 | | - |
1092 | | - |
1093 | | - |
1094 | | - |
1095 | QTableWidget::~QTableWidget() | - |
1096 | { | - |
1097 | } | - |
1098 | void QTableWidget::setRowCount(int rows) | - |
1099 | { | - |
1100 | QTableWidgetPrivate * const d = d_func(); | - |
1101 | d->tableModel()->setRowCount(rows); | - |
1102 | } executed: } Execution Count:287 | 287 |
1103 | | - |
1104 | | - |
1105 | | - |
1106 | | - |
1107 | | - |
1108 | int QTableWidget::rowCount() const | - |
1109 | { | - |
1110 | const QTableWidgetPrivate * const d = d_func(); | - |
1111 | return d->model->rowCount(); executed: return d->model->rowCount(); Execution Count:702 | 702 |
1112 | } | - |
1113 | void QTableWidget::setColumnCount(int columns) | - |
1114 | { | - |
1115 | QTableWidgetPrivate * const d = d_func(); | - |
1116 | d->tableModel()->setColumnCount(columns); | - |
1117 | } executed: } Execution Count:288 | 288 |
1118 | | - |
1119 | | - |
1120 | | - |
1121 | | - |
1122 | | - |
1123 | int QTableWidget::columnCount() const | - |
1124 | { | - |
1125 | const QTableWidgetPrivate * const d = d_func(); | - |
1126 | return d->model->columnCount(); executed: return d->model->columnCount(); Execution Count:976 | 976 |
1127 | } | - |
1128 | | - |
1129 | | - |
1130 | | - |
1131 | | - |
1132 | int QTableWidget::row(const QTableWidgetItem *item) const | - |
1133 | { | - |
1134 | const QTableWidgetPrivate * const d = d_func(); | - |
1135 | return d->tableModel()->index(item).row(); never executed: return d->tableModel()->index(item).row(); | 0 |
1136 | } | - |
1137 | | - |
1138 | | - |
1139 | | - |
1140 | | - |
1141 | int QTableWidget::column(const QTableWidgetItem *item) const | - |
1142 | { | - |
1143 | const QTableWidgetPrivate * const d = d_func(); | - |
1144 | return d->tableModel()->index(item).column(); never executed: return d->tableModel()->index(item).column(); | 0 |
1145 | } | - |
1146 | QTableWidgetItem *QTableWidget::item(int row, int column) const | - |
1147 | { | - |
1148 | const QTableWidgetPrivate * const d = d_func(); | - |
1149 | return d->tableModel()->item(row, column); executed: return d->tableModel()->item(row, column); Execution Count:573 | 573 |
1150 | } | - |
1151 | void QTableWidget::setItem(int row, int column, QTableWidgetItem *item) | - |
1152 | { | - |
1153 | QTableWidgetPrivate * const d = d_func(); | - |
1154 | if (item) { evaluated: item yes Evaluation Count:984 | yes Evaluation Count:1 |
| 1-984 |
1155 | if (item->view != 0) { partially evaluated: item->view != 0 no Evaluation Count:0 | yes Evaluation Count:984 |
| 0-984 |
1156 | QMessageLogger("itemviews/qtablewidget.cpp", 1962, __PRETTY_FUNCTION__).warning("QTableWidget: cannot insert an item that is already owned by another QTableWidget"); | - |
1157 | } else { | 0 |
1158 | item->view = this; | - |
1159 | d->tableModel()->setItem(row, column, item); | - |
1160 | } executed: } Execution Count:984 | 984 |
1161 | } else { | - |
1162 | delete takeItem(row, column); | - |
1163 | } executed: } Execution Count:1 | 1 |
1164 | } | - |
1165 | | - |
1166 | | - |
1167 | | - |
1168 | | - |
1169 | QTableWidgetItem *QTableWidget::takeItem(int row, int column) | - |
1170 | { | - |
1171 | QTableWidgetPrivate * const d = d_func(); | - |
1172 | QTableWidgetItem *item = d->tableModel()->takeItem(row, column); | - |
1173 | if (item) evaluated: item yes Evaluation Count:4 | yes Evaluation Count:8 |
| 4-8 |
1174 | item->view = 0; executed: item->view = 0; Execution Count:4 | 4 |
1175 | return item; executed: return item; Execution Count:12 | 12 |
1176 | } | - |
1177 | | - |
1178 | | - |
1179 | | - |
1180 | | - |
1181 | QTableWidgetItem *QTableWidget::verticalHeaderItem(int row) const | - |
1182 | { | - |
1183 | const QTableWidgetPrivate * const d = d_func(); | - |
1184 | return d->tableModel()->verticalHeaderItem(row); executed: return d->tableModel()->verticalHeaderItem(row); Execution Count:1 | 1 |
1185 | } | - |
1186 | | - |
1187 | | - |
1188 | | - |
1189 | | - |
1190 | void QTableWidget::setVerticalHeaderItem(int row, QTableWidgetItem *item) | - |
1191 | { | - |
1192 | QTableWidgetPrivate * const d = d_func(); | - |
1193 | if (item) { partially evaluated: item yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
1194 | item->view = this; | - |
1195 | d->tableModel()->setVerticalHeaderItem(row, item); | - |
1196 | } else { executed: } Execution Count:7 | 7 |
1197 | delete takeVerticalHeaderItem(row); | - |
1198 | } | 0 |
1199 | } | - |
1200 | | - |
1201 | | - |
1202 | | - |
1203 | | - |
1204 | | - |
1205 | QTableWidgetItem *QTableWidget::takeVerticalHeaderItem(int row) | - |
1206 | { | - |
1207 | QTableWidgetPrivate * const d = d_func(); | - |
1208 | QTableWidgetItem *itm = d->tableModel()->takeVerticalHeaderItem(row); | - |
1209 | if (itm) | 0 |
1210 | itm->view = 0; never executed: itm->view = 0; | 0 |
1211 | return itm; never executed: return itm; | 0 |
1212 | } | - |
1213 | | - |
1214 | | - |
1215 | | - |
1216 | | - |
1217 | | - |
1218 | QTableWidgetItem *QTableWidget::horizontalHeaderItem(int column) const | - |
1219 | { | - |
1220 | const QTableWidgetPrivate * const d = d_func(); | - |
1221 | return d->tableModel()->horizontalHeaderItem(column); executed: return d->tableModel()->horizontalHeaderItem(column); Execution Count:3 | 3 |
1222 | } | - |
1223 | | - |
1224 | | - |
1225 | | - |
1226 | | - |
1227 | void QTableWidget::setHorizontalHeaderItem(int column, QTableWidgetItem *item) | - |
1228 | { | - |
1229 | QTableWidgetPrivate * const d = d_func(); | - |
1230 | if (item) { partially evaluated: item yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
1231 | item->view = this; | - |
1232 | d->tableModel()->setHorizontalHeaderItem(column, item); | - |
1233 | } else { executed: } Execution Count:11 | 11 |
1234 | delete takeHorizontalHeaderItem(column); | - |
1235 | } | 0 |
1236 | } | - |
1237 | | - |
1238 | | - |
1239 | | - |
1240 | | - |
1241 | | - |
1242 | QTableWidgetItem *QTableWidget::takeHorizontalHeaderItem(int column) | - |
1243 | { | - |
1244 | QTableWidgetPrivate * const d = d_func(); | - |
1245 | QTableWidgetItem *itm = d->tableModel()->takeHorizontalHeaderItem(column); | - |
1246 | if (itm) | 0 |
1247 | itm->view = 0; never executed: itm->view = 0; | 0 |
1248 | return itm; never executed: return itm; | 0 |
1249 | } | - |
1250 | | - |
1251 | | - |
1252 | | - |
1253 | | - |
1254 | void QTableWidget::setVerticalHeaderLabels(const QStringList &labels) | - |
1255 | { | - |
1256 | QTableWidgetPrivate * const d = d_func(); | - |
1257 | QTableModel *model = d->tableModel(); | - |
1258 | QTableWidgetItem *item = 0; | - |
1259 | for (int i = 0; i < model->rowCount() && i < labels.count(); ++i) { evaluated: i < model->rowCount() yes Evaluation Count:3 | yes Evaluation Count:1 |
partially evaluated: i < labels.count() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1260 | item = model->verticalHeaderItem(i); | - |
1261 | if (!item) { partially evaluated: !item yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1262 | item = model->createItem(); | - |
1263 | setVerticalHeaderItem(i, item); | - |
1264 | } executed: } Execution Count:3 | 3 |
1265 | item->setText(labels.at(i)); | - |
1266 | } executed: } Execution Count:3 | 3 |
1267 | } executed: } Execution Count:1 | 1 |
1268 | | - |
1269 | | - |
1270 | | - |
1271 | | - |
1272 | void QTableWidget::setHorizontalHeaderLabels(const QStringList &labels) | - |
1273 | { | - |
1274 | QTableWidgetPrivate * const d = d_func(); | - |
1275 | QTableModel *model = d->tableModel(); | - |
1276 | QTableWidgetItem *item = 0; | - |
1277 | for (int i = 0; i < model->columnCount() && i < labels.count(); ++i) { evaluated: i < model->columnCount() yes Evaluation Count:3 | yes Evaluation Count:1 |
partially evaluated: i < labels.count() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1278 | item = model->horizontalHeaderItem(i); | - |
1279 | if (!item) { partially evaluated: !item yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1280 | item = model->createItem(); | - |
1281 | setHorizontalHeaderItem(i, item); | - |
1282 | } executed: } Execution Count:3 | 3 |
1283 | item->setText(labels.at(i)); | - |
1284 | } executed: } Execution Count:3 | 3 |
1285 | } executed: } Execution Count:1 | 1 |
1286 | | - |
1287 | | - |
1288 | | - |
1289 | | - |
1290 | | - |
1291 | | - |
1292 | int QTableWidget::currentRow() const | - |
1293 | { | - |
1294 | return currentIndex().row(); executed: return currentIndex().row(); Execution Count:2 | 2 |
1295 | } | - |
1296 | | - |
1297 | | - |
1298 | | - |
1299 | | - |
1300 | | - |
1301 | | - |
1302 | int QTableWidget::currentColumn() const | - |
1303 | { | - |
1304 | return currentIndex().column(); executed: return currentIndex().column(); Execution Count:2 | 2 |
1305 | } | - |
1306 | | - |
1307 | | - |
1308 | | - |
1309 | | - |
1310 | | - |
1311 | | - |
1312 | QTableWidgetItem *QTableWidget::currentItem() const | - |
1313 | { | - |
1314 | const QTableWidgetPrivate * const d = d_func(); | - |
1315 | return d->tableModel()->item(currentIndex()); executed: return d->tableModel()->item(currentIndex()); Execution Count:2 | 2 |
1316 | } | - |
1317 | void QTableWidget::setCurrentItem(QTableWidgetItem *item) | - |
1318 | { | - |
1319 | QTableWidgetPrivate * const d = d_func(); | - |
1320 | setCurrentIndex(d->tableModel()->index(item)); | - |
1321 | } executed: } Execution Count:2 | 2 |
1322 | void QTableWidget::setCurrentItem(QTableWidgetItem *item, QItemSelectionModel::SelectionFlags command) | - |
1323 | { | - |
1324 | QTableWidgetPrivate * const d = d_func(); | - |
1325 | d->selectionModel->setCurrentIndex(d->tableModel()->index(item), command); | - |
1326 | } | 0 |
1327 | void QTableWidget::setCurrentCell(int row, int column) | - |
1328 | { | - |
1329 | setCurrentIndex(model()->index(row, column, QModelIndex())); | - |
1330 | } executed: } Execution Count:2 | 2 |
1331 | void QTableWidget::setCurrentCell(int row, int column, QItemSelectionModel::SelectionFlags command) | - |
1332 | { | - |
1333 | QTableWidgetPrivate * const d = d_func(); | - |
1334 | d->selectionModel->setCurrentIndex(model()->index(row, column, QModelIndex()), command); | - |
1335 | } | 0 |
1336 | | - |
1337 | | - |
1338 | | - |
1339 | | - |
1340 | void QTableWidget::sortItems(int column, Qt::SortOrder order) | - |
1341 | { | - |
1342 | QTableWidgetPrivate * const d = d_func(); | - |
1343 | d->model->sort(column, order); | - |
1344 | horizontalHeader()->setSortIndicator(column, order); | - |
1345 | } executed: } Execution Count:31 | 31 |
1346 | | - |
1347 | | - |
1348 | | - |
1349 | | - |
1350 | void QTableWidget::setSortingEnabled(bool enable) | - |
1351 | { | - |
1352 | QTableView::setSortingEnabled(enable); | - |
1353 | } executed: } Execution Count:20 | 20 |
1354 | | - |
1355 | | - |
1356 | | - |
1357 | | - |
1358 | bool QTableWidget::isSortingEnabled() const | - |
1359 | { | - |
1360 | return QTableView::isSortingEnabled(); executed: return QTableView::isSortingEnabled(); Execution Count:984 | 984 |
1361 | } | - |
1362 | | - |
1363 | | - |
1364 | | - |
1365 | | - |
1366 | | - |
1367 | void QTableWidget::editItem(QTableWidgetItem *item) | - |
1368 | { | - |
1369 | QTableWidgetPrivate * const d = d_func(); | - |
1370 | if (!item) partially evaluated: !item no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1371 | return; | 0 |
1372 | edit(d->tableModel()->index(item)); | - |
1373 | } executed: } Execution Count:4 | 4 |
1374 | | - |
1375 | | - |
1376 | | - |
1377 | | - |
1378 | | - |
1379 | | - |
1380 | void QTableWidget::openPersistentEditor(QTableWidgetItem *item) | - |
1381 | { | - |
1382 | QTableWidgetPrivate * const d = d_func(); | - |
1383 | if (!item) partially evaluated: !item no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1384 | return; | 0 |
1385 | QModelIndex index = d->tableModel()->index(item); | - |
1386 | QAbstractItemView::openPersistentEditor(index); | - |
1387 | } executed: } Execution Count:1 | 1 |
1388 | | - |
1389 | | - |
1390 | | - |
1391 | | - |
1392 | | - |
1393 | | - |
1394 | void QTableWidget::closePersistentEditor(QTableWidgetItem *item) | - |
1395 | { | - |
1396 | QTableWidgetPrivate * const d = d_func(); | - |
1397 | if (!item) | 0 |
1398 | return; | 0 |
1399 | QModelIndex index = d->tableModel()->index(item); | - |
1400 | QAbstractItemView::closePersistentEditor(index); | - |
1401 | } | 0 |
1402 | QWidget *QTableWidget::cellWidget(int row, int column) const | - |
1403 | { | - |
1404 | QModelIndex index = model()->index(row, column, QModelIndex()); | - |
1405 | return QAbstractItemView::indexWidget(index); executed: return QAbstractItemView::indexWidget(index); Execution Count:6 | 6 |
1406 | } | - |
1407 | void QTableWidget::setCellWidget(int row, int column, QWidget *widget) | - |
1408 | { | - |
1409 | QModelIndex index = model()->index(row, column, QModelIndex()); | - |
1410 | QAbstractItemView::setIndexWidget(index, widget); | - |
1411 | } executed: } Execution Count:2 | 2 |
1412 | bool QTableWidget::isItemSelected(const QTableWidgetItem *item) const | - |
1413 | { | - |
1414 | const QTableWidgetPrivate * const d = d_func(); | - |
1415 | QModelIndex index = d->tableModel()->index(item); | - |
1416 | return selectionModel()->isSelected(index); executed: return selectionModel()->isSelected(index); Execution Count:20 | 20 |
1417 | } | - |
1418 | void QTableWidget::setItemSelected(const QTableWidgetItem *item, bool select) | - |
1419 | { | - |
1420 | QTableWidgetPrivate * const d = d_func(); | - |
1421 | QModelIndex index = d->tableModel()->index(item); | - |
1422 | selectionModel()->select(index, select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect); | - |
1423 | } executed: } Execution Count:5 | 5 |
1424 | | - |
1425 | | - |
1426 | | - |
1427 | | - |
1428 | void QTableWidget::setRangeSelected(const QTableWidgetSelectionRange &range, bool select) | - |
1429 | { | - |
1430 | if (!model()->hasIndex(range.topRow(), range.leftColumn(), rootIndex()) || evaluated: !model()->hasIndex(range.topRow(), range.leftColumn(), rootIndex()) yes Evaluation Count:1 | yes Evaluation Count:10 |
| 1-10 |
1431 | !model()->hasIndex(range.bottomRow(), range.rightColumn(), rootIndex())) partially evaluated: !model()->hasIndex(range.bottomRow(), range.rightColumn(), rootIndex()) no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1432 | return; executed: return; Execution Count:1 | 1 |
1433 | | - |
1434 | QModelIndex topLeft = model()->index(range.topRow(), range.leftColumn(), rootIndex()); | - |
1435 | QModelIndex bottomRight = model()->index(range.bottomRow(), range.rightColumn(), rootIndex()); | - |
1436 | | - |
1437 | selectionModel()->select(QItemSelection(topLeft, bottomRight), | - |
1438 | select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect); | - |
1439 | } executed: } Execution Count:10 | 10 |
1440 | | - |
1441 | | - |
1442 | | - |
1443 | | - |
1444 | | - |
1445 | | - |
1446 | | - |
1447 | QList<QTableWidgetSelectionRange> QTableWidget::selectedRanges() const | - |
1448 | { | - |
1449 | const QList<QItemSelectionRange> ranges = selectionModel()->selection(); | - |
1450 | QList<QTableWidgetSelectionRange> result; | - |
1451 | for (int i = 0; i < ranges.count(); ++i) evaluated: i < ranges.count() yes Evaluation Count:50 | yes Evaluation Count:63 |
| 50-63 |
1452 | result.append(QTableWidgetSelectionRange(ranges.at(i).top(), | 50 |
1453 | ranges.at(i).left(), | 50 |
1454 | ranges.at(i).bottom(), | 50 |
1455 | ranges.at(i).right())); executed: result.append(QTableWidgetSelectionRange(ranges.at(i).top(), ranges.at(i).left(), ranges.at(i).bottom(), ranges.at(i).right())); Execution Count:50 | 50 |
1456 | return result; executed: return result; Execution Count:63 | 63 |
1457 | } | - |
1458 | QList<QTableWidgetItem*> QTableWidget::selectedItems() const | - |
1459 | { | - |
1460 | const QTableWidgetPrivate * const d = d_func(); | - |
1461 | QModelIndexList indexes = selectionModel()->selectedIndexes(); | - |
1462 | QList<QTableWidgetItem*> items; | - |
1463 | for (int i = 0; i < indexes.count(); ++i) { evaluated: i < indexes.count() yes Evaluation Count:92 | yes Evaluation Count:25 |
| 25-92 |
1464 | QModelIndex index = indexes.at(i); | - |
1465 | if (isIndexHidden(index)) evaluated: isIndexHidden(index) yes Evaluation Count:18 | yes Evaluation Count:74 |
| 18-74 |
1466 | continue; executed: continue; Execution Count:18 | 18 |
1467 | QTableWidgetItem *item = d->tableModel()->item(index); | - |
1468 | if (item) evaluated: item yes Evaluation Count:24 | yes Evaluation Count:50 |
| 24-50 |
1469 | items.append(item); executed: items.append(item); Execution Count:24 | 24 |
1470 | } executed: } Execution Count:74 | 74 |
1471 | return items; executed: return items; Execution Count:25 | 25 |
1472 | } | - |
1473 | | - |
1474 | | - |
1475 | | - |
1476 | | - |
1477 | | - |
1478 | QList<QTableWidgetItem*> QTableWidget::findItems(const QString &text, Qt::MatchFlags flags) const | - |
1479 | { | - |
1480 | const QTableWidgetPrivate * const d = d_func(); | - |
1481 | QModelIndexList indexes; | - |
1482 | for (int column = 0; column < columnCount(); ++column) never evaluated: column < columnCount() | 0 |
1483 | indexes += d->model->match(model()->index(0, column, QModelIndex()), | 0 |
1484 | Qt::DisplayRole, text, -1, flags); never executed: indexes += d->model->match(model()->index(0, column, QModelIndex()), Qt::DisplayRole, text, -1, flags); | 0 |
1485 | QList<QTableWidgetItem*> items; | - |
1486 | for (int i = 0; i < indexes.size(); ++i) never evaluated: i < indexes.size() | 0 |
1487 | items.append(d->tableModel()->item(indexes.at(i))); never executed: items.append(d->tableModel()->item(indexes.at(i))); | 0 |
1488 | return items; never executed: return items; | 0 |
1489 | } | - |
1490 | | - |
1491 | | - |
1492 | | - |
1493 | | - |
1494 | | - |
1495 | int QTableWidget::visualRow(int logicalRow) const | - |
1496 | { | - |
1497 | return verticalHeader()->visualIndex(logicalRow); never executed: return verticalHeader()->visualIndex(logicalRow); | 0 |
1498 | } | - |
1499 | | - |
1500 | | - |
1501 | | - |
1502 | | - |
1503 | | - |
1504 | int QTableWidget::visualColumn(int logicalColumn) const | - |
1505 | { | - |
1506 | return horizontalHeader()->visualIndex(logicalColumn); never executed: return horizontalHeader()->visualIndex(logicalColumn); | 0 |
1507 | } | - |
1508 | QTableWidgetItem *QTableWidget::itemAt(const QPoint &p) const | - |
1509 | { | - |
1510 | const QTableWidgetPrivate * const d = d_func(); | - |
1511 | return d->tableModel()->item(indexAt(p)); never executed: return d->tableModel()->item(indexAt(p)); | 0 |
1512 | } | - |
1513 | | - |
1514 | | - |
1515 | | - |
1516 | | - |
1517 | QRect QTableWidget::visualItemRect(const QTableWidgetItem *item) const | - |
1518 | { | - |
1519 | const QTableWidgetPrivate * const d = d_func(); | - |
1520 | if (!item) partially evaluated: !item no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1521 | return QRect(); never executed: return QRect(); | 0 |
1522 | QModelIndex index = d->tableModel()->index(const_cast<QTableWidgetItem*>(item)); | - |
1523 | qt_noop(); | - |
1524 | return visualRect(index); executed: return visualRect(index); Execution Count:3 | 3 |
1525 | } | - |
1526 | | - |
1527 | | - |
1528 | | - |
1529 | | - |
1530 | | - |
1531 | | - |
1532 | | - |
1533 | void QTableWidget::scrollToItem(const QTableWidgetItem *item, QAbstractItemView::ScrollHint hint) | - |
1534 | { | - |
1535 | QTableWidgetPrivate * const d = d_func(); | - |
1536 | if (!item) | 0 |
1537 | return; | 0 |
1538 | QModelIndex index = d->tableModel()->index(const_cast<QTableWidgetItem*>(item)); | - |
1539 | qt_noop(); | - |
1540 | QTableView::scrollTo(index, hint); | - |
1541 | } | 0 |
1542 | | - |
1543 | | - |
1544 | | - |
1545 | | - |
1546 | | - |
1547 | | - |
1548 | const QTableWidgetItem *QTableWidget::itemPrototype() const | - |
1549 | { | - |
1550 | const QTableWidgetPrivate * const d = d_func(); | - |
1551 | return d->tableModel()->itemPrototype(); executed: return d->tableModel()->itemPrototype(); Execution Count:2 | 2 |
1552 | } | - |
1553 | void QTableWidget::setItemPrototype(const QTableWidgetItem *item) | - |
1554 | { | - |
1555 | QTableWidgetPrivate * const d = d_func(); | - |
1556 | d->tableModel()->setItemPrototype(item); | - |
1557 | } executed: } Execution Count:2 | 2 |
1558 | | - |
1559 | | - |
1560 | | - |
1561 | | - |
1562 | void QTableWidget::insertRow(int row) | - |
1563 | { | - |
1564 | QTableWidgetPrivate * const d = d_func(); | - |
1565 | d->tableModel()->insertRows(row); | - |
1566 | } executed: } Execution Count:8 | 8 |
1567 | | - |
1568 | | - |
1569 | | - |
1570 | | - |
1571 | void QTableWidget::insertColumn(int column) | - |
1572 | { | - |
1573 | QTableWidgetPrivate * const d = d_func(); | - |
1574 | d->tableModel()->insertColumns(column); | - |
1575 | } executed: } Execution Count:8 | 8 |
1576 | | - |
1577 | | - |
1578 | | - |
1579 | | - |
1580 | void QTableWidget::removeRow(int row) | - |
1581 | { | - |
1582 | QTableWidgetPrivate * const d = d_func(); | - |
1583 | d->tableModel()->removeRows(row); | - |
1584 | } executed: } Execution Count:7 | 7 |
1585 | | - |
1586 | | - |
1587 | | - |
1588 | | - |
1589 | void QTableWidget::removeColumn(int column) | - |
1590 | { | - |
1591 | QTableWidgetPrivate * const d = d_func(); | - |
1592 | d->tableModel()->removeColumns(column); | - |
1593 | } executed: } Execution Count:6 | 6 |
1594 | | - |
1595 | | - |
1596 | | - |
1597 | | - |
1598 | | - |
1599 | | - |
1600 | | - |
1601 | void QTableWidget::clear() | - |
1602 | { | - |
1603 | QTableWidgetPrivate * const d = d_func(); | - |
1604 | selectionModel()->clear(); | - |
1605 | d->tableModel()->clear(); | - |
1606 | } executed: } Execution Count:85 | 85 |
1607 | void QTableWidget::clearContents() | - |
1608 | { | - |
1609 | QTableWidgetPrivate * const d = d_func(); | - |
1610 | selectionModel()->clear(); | - |
1611 | d->tableModel()->clearContents(); | - |
1612 | } executed: } Execution Count:1 | 1 |
1613 | | - |
1614 | | - |
1615 | | - |
1616 | | - |
1617 | | - |
1618 | | - |
1619 | | - |
1620 | QStringList QTableWidget::mimeTypes() const | - |
1621 | { | - |
1622 | return d_func()->tableModel()->QAbstractTableModel::mimeTypes(); executed: return d_func()->tableModel()->QAbstractTableModel::mimeTypes(); Execution Count:2 | 2 |
1623 | } | - |
1624 | QMimeData *QTableWidget::mimeData(const QList<QTableWidgetItem*>) const | - |
1625 | { | - |
1626 | return d_func()->tableModel()->internalMimeData(); never executed: return d_func()->tableModel()->internalMimeData(); | 0 |
1627 | } | - |
1628 | bool QTableWidget::dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action) | - |
1629 | { | - |
1630 | QModelIndex idx; | - |
1631 | | - |
1632 | if (dropIndicatorPosition() == QAbstractItemView::OnItem) { never evaluated: dropIndicatorPosition() == QAbstractItemView::OnItem | 0 |
1633 | | - |
1634 | idx = model()->index(row, column); | - |
1635 | row = -1; | - |
1636 | column = -1; | - |
1637 | } | 0 |
1638 | | - |
1639 | return d_func()->tableModel()->QAbstractTableModel::dropMimeData(data, action , row, column, idx); never executed: return d_func()->tableModel()->QAbstractTableModel::dropMimeData(data, action , row, column, idx); | 0 |
1640 | } | - |
1641 | | - |
1642 | | - |
1643 | | - |
1644 | | - |
1645 | | - |
1646 | | - |
1647 | Qt::DropActions QTableWidget::supportedDropActions() const | - |
1648 | { | - |
1649 | return d_func()->tableModel()->QAbstractTableModel::supportedDropActions() | Qt::MoveAction; executed: return d_func()->tableModel()->QAbstractTableModel::supportedDropActions() | Qt::MoveAction; Execution Count:2 | 2 |
1650 | } | - |
1651 | | - |
1652 | | - |
1653 | | - |
1654 | | - |
1655 | | - |
1656 | | - |
1657 | | - |
1658 | QList<QTableWidgetItem*> QTableWidget::items(const QMimeData *data) const | - |
1659 | { | - |
1660 | const QTableWidgetMimeData *twd = qobject_cast<const QTableWidgetMimeData*>(data); | - |
1661 | if (twd) | 0 |
1662 | return twd->items; never executed: return twd->items; | 0 |
1663 | return QList<QTableWidgetItem*>(); never executed: return QList<QTableWidgetItem*>(); | 0 |
1664 | } | - |
1665 | | - |
1666 | | - |
1667 | | - |
1668 | | - |
1669 | | - |
1670 | QModelIndex QTableWidget::indexFromItem(QTableWidgetItem *item) const | - |
1671 | { | - |
1672 | const QTableWidgetPrivate * const d = d_func(); | - |
1673 | return d->tableModel()->index(item); never executed: return d->tableModel()->index(item); | 0 |
1674 | } | - |
1675 | | - |
1676 | | - |
1677 | | - |
1678 | | - |
1679 | | - |
1680 | QTableWidgetItem *QTableWidget::itemFromIndex(const QModelIndex &index) const | - |
1681 | { | - |
1682 | const QTableWidgetPrivate * const d = d_func(); | - |
1683 | return d->tableModel()->item(index); never executed: return d->tableModel()->item(index); | 0 |
1684 | } | - |
1685 | | - |
1686 | | - |
1687 | | - |
1688 | | - |
1689 | void QTableWidget::setModel(QAbstractItemModel * ) | - |
1690 | { | - |
1691 | qt_noop(); | - |
1692 | } | 0 |
1693 | | - |
1694 | | - |
1695 | bool QTableWidget::event(QEvent *e) | - |
1696 | { | - |
1697 | return QTableView::event(e); executed: return QTableView::event(e); Execution Count:1485 | 1485 |
1698 | } | - |
1699 | | - |
1700 | | - |
1701 | | - |
1702 | void QTableWidget::dropEvent(QDropEvent *event) { | - |
1703 | QTableWidgetPrivate * const d = d_func(); | - |
1704 | if (event->source() == this && (event->dropAction() == Qt::MoveAction || never evaluated: event->source() == this never evaluated: event->dropAction() == Qt::MoveAction | 0 |
1705 | dragDropMode() == QAbstractItemView::InternalMove)) { never evaluated: dragDropMode() == QAbstractItemView::InternalMove | 0 |
1706 | QModelIndex topIndex; | - |
1707 | int col = -1; | - |
1708 | int row = -1; | - |
1709 | if (d->dropOn(event, &row, &col, &topIndex)) { never evaluated: d->dropOn(event, &row, &col, &topIndex) | 0 |
1710 | QModelIndexList indexes = selectedIndexes(); | - |
1711 | int top = 2147483647; | - |
1712 | int left = 2147483647; | - |
1713 | for (int i = 0; i < indexes.count(); ++i) { never evaluated: i < indexes.count() | 0 |
1714 | top = qMin(indexes.at(i).row(), top); | - |
1715 | left = qMin(indexes.at(i).column(), left); | - |
1716 | } | 0 |
1717 | | - |
1718 | QList<QTableWidgetItem *> taken; | - |
1719 | for (int i = 0; i < indexes.count(); ++i) never evaluated: i < indexes.count() | 0 |
1720 | taken.append(takeItem(indexes.at(i).row(), indexes.at(i).column())); never executed: taken.append(takeItem(indexes.at(i).row(), indexes.at(i).column())); | 0 |
1721 | | - |
1722 | for (int i = 0; i < indexes.count(); ++i) { never evaluated: i < indexes.count() | 0 |
1723 | QModelIndex index = indexes.at(i); | - |
1724 | int r = index.row() - top + topIndex.row(); | - |
1725 | int c = index.column() - left + topIndex.column(); | - |
1726 | setItem(r, c, taken.takeFirst()); | - |
1727 | } | 0 |
1728 | | - |
1729 | event->accept(); | - |
1730 | | - |
1731 | event->setDropAction(Qt::CopyAction); | - |
1732 | } | 0 |
1733 | } | 0 |
1734 | | - |
1735 | QTableView::dropEvent(event); | - |
1736 | } | 0 |
1737 | | - |
1738 | | - |
1739 | | - |
1740 | | - |
1741 | | - |
| | |