qtablewidget.cpp

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

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