Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qtablewidget.h" | - |
43 | | - |
44 | #ifndef QT_NO_TABLEWIDGET | - |
45 | #include <qitemdelegate.h> | - |
46 | #include <qpainter.h> | - |
47 | #include <private/qtablewidget_p.h> | - |
48 | | - |
49 | #include <algorithm> | - |
50 | | - |
51 | QT_BEGIN_NAMESPACE | - |
52 | | - |
53 | QTableModel::QTableModel(int rows, int columns, QTableWidget *parent) | - |
54 | : QAbstractTableModel(parent), | - |
55 | prototype(0), | - |
56 | tableItems(rows * columns, 0), | - |
57 | verticalHeaderItems(rows, 0), | - |
58 | horizontalHeaderItems(columns, 0) | - |
59 | {} executed: } Execution Count:146 | 146 |
60 | | - |
61 | QTableModel::~QTableModel() | - |
62 | { | - |
63 | clear(); executed (the execution status of this line is deduced): clear(); | - |
64 | delete prototype; executed (the execution status of this line is deduced): delete prototype; | - |
65 | } executed: } Execution Count:146 | 146 |
66 | | - |
67 | bool QTableModel::insertRows(int row, int count, const QModelIndex &) | - |
68 | { | - |
69 | 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 |
70 | return false; executed: return false; Execution Count:26 | 26 |
71 | | - |
72 | beginInsertRows(QModelIndex(), row, row + count - 1); executed (the execution status of this line is deduced): beginInsertRows(QModelIndex(), row, row + count - 1); | - |
73 | int rc = verticalHeaderItems.count(); executed (the execution status of this line is deduced): int rc = verticalHeaderItems.count(); | - |
74 | int cc = horizontalHeaderItems.count(); executed (the execution status of this line is deduced): int cc = horizontalHeaderItems.count(); | - |
75 | verticalHeaderItems.insert(row, count, 0); executed (the execution status of this line is deduced): verticalHeaderItems.insert(row, count, 0); | - |
76 | if (rc == 0) evaluated: rc == 0 yes Evaluation Count:104 | yes Evaluation Count:74 |
| 74-104 |
77 | tableItems.resize(cc * count); executed: tableItems.resize(cc * count); Execution Count:104 | 104 |
78 | else | - |
79 | tableItems.insert(tableIndex(row, 0), cc * count, 0); executed: tableItems.insert(tableIndex(row, 0), cc * count, 0); Execution Count:74 | 74 |
80 | endInsertRows(); executed (the execution status of this line is deduced): endInsertRows(); | - |
81 | return true; executed: return true; Execution Count:178 | 178 |
82 | } | - |
83 | | - |
84 | bool QTableModel::insertColumns(int column, int count, const QModelIndex &) | - |
85 | { | - |
86 | 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 |
87 | return false; executed: return false; Execution Count:26 | 26 |
88 | | - |
89 | beginInsertColumns(QModelIndex(), column, column + count - 1); executed (the execution status of this line is deduced): beginInsertColumns(QModelIndex(), column, column + count - 1); | - |
90 | int rc = verticalHeaderItems.count(); executed (the execution status of this line is deduced): int rc = verticalHeaderItems.count(); | - |
91 | int cc = horizontalHeaderItems.count(); executed (the execution status of this line is deduced): int cc = horizontalHeaderItems.count(); | - |
92 | horizontalHeaderItems.insert(column, count, 0); executed (the execution status of this line is deduced): horizontalHeaderItems.insert(column, count, 0); | - |
93 | if (cc == 0) evaluated: cc == 0 yes Evaluation Count:104 | yes Evaluation Count:62 |
| 62-104 |
94 | tableItems.resize(rc * count); executed: tableItems.resize(rc * count); Execution Count:104 | 104 |
95 | else | - |
96 | for (int row = 0; row < rc; ++row) evaluated: row < rc yes Evaluation Count:608 | yes Evaluation Count:62 |
| 62-608 |
97 | tableItems.insert(tableIndex(row, column), count, 0); executed: tableItems.insert(tableIndex(row, column), count, 0); Execution Count:608 | 608 |
98 | endInsertColumns(); executed (the execution status of this line is deduced): endInsertColumns(); | - |
99 | return true; executed: return true; Execution Count:166 | 166 |
100 | } | - |
101 | | - |
102 | bool QTableModel::removeRows(int row, int count, const QModelIndex &) | - |
103 | { | - |
104 | 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 |
105 | return false; executed: return false; Execution Count:31 | 31 |
106 | | - |
107 | beginRemoveRows(QModelIndex(), row, row + count - 1); executed (the execution status of this line is deduced): beginRemoveRows(QModelIndex(), row, row + count - 1); | - |
108 | int i = tableIndex(row, 0); executed (the execution status of this line is deduced): int i = tableIndex(row, 0); | - |
109 | int n = count * columnCount(); executed (the execution status of this line is deduced): int n = count * columnCount(); | - |
110 | QTableWidgetItem *oldItem = 0; executed (the execution status of this line is deduced): QTableWidgetItem *oldItem = 0; | - |
111 | for (int j = i; j < n + i; ++j) { evaluated: j < n + i yes Evaluation Count:2721 | yes Evaluation Count:82 |
| 82-2721 |
112 | oldItem = tableItems.at(j); executed (the execution status of this line is deduced): oldItem = tableItems.at(j); | - |
113 | if (oldItem) evaluated: oldItem yes Evaluation Count:11 | yes Evaluation Count:2710 |
| 11-2710 |
114 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:11 | 11 |
115 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
116 | } executed: } Execution Count:2721 | 2721 |
117 | tableItems.remove(qMax(i, 0), n); executed (the execution status of this line is deduced): tableItems.remove(qMax(i, 0), n); | - |
118 | for (int v = row; v < row + count; ++v) { evaluated: v < row + count yes Evaluation Count:260 | yes Evaluation Count:82 |
| 82-260 |
119 | oldItem = verticalHeaderItems.at(v); executed (the execution status of this line is deduced): oldItem = verticalHeaderItems.at(v); | - |
120 | if (oldItem) evaluated: oldItem yes Evaluation Count:1 | yes Evaluation Count:259 |
| 1-259 |
121 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:1 | 1 |
122 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
123 | } executed: } Execution Count:260 | 260 |
124 | verticalHeaderItems.remove(row, count); executed (the execution status of this line is deduced): verticalHeaderItems.remove(row, count); | - |
125 | endRemoveRows(); executed (the execution status of this line is deduced): endRemoveRows(); | - |
126 | return true; executed: return true; Execution Count:82 | 82 |
127 | } | - |
128 | | - |
129 | bool QTableModel::removeColumns(int column, int count, const QModelIndex &) | - |
130 | { | - |
131 | 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 |
132 | return false; executed: return false; Execution Count:31 | 31 |
133 | | - |
134 | beginRemoveColumns(QModelIndex(), column, column + count - 1); executed (the execution status of this line is deduced): beginRemoveColumns(QModelIndex(), column, column + count - 1); | - |
135 | QTableWidgetItem *oldItem = 0; executed (the execution status of this line is deduced): QTableWidgetItem *oldItem = 0; | - |
136 | for (int row = rowCount() - 1; row >= 0; --row) { evaluated: row >= 0 yes Evaluation Count:324 | yes Evaluation Count:69 |
| 69-324 |
137 | int i = tableIndex(row, column); executed (the execution status of this line is deduced): int i = tableIndex(row, column); | - |
138 | for (int j = i; j < i + count; ++j) { evaluated: j < i + count yes Evaluation Count:996 | yes Evaluation Count:324 |
| 324-996 |
139 | oldItem = tableItems.at(j); executed (the execution status of this line is deduced): oldItem = tableItems.at(j); | - |
140 | if (oldItem) evaluated: oldItem yes Evaluation Count:11 | yes Evaluation Count:985 |
| 11-985 |
141 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:11 | 11 |
142 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
143 | } executed: } Execution Count:996 | 996 |
144 | tableItems.remove(i, count); executed (the execution status of this line is deduced): tableItems.remove(i, count); | - |
145 | } executed: } Execution Count:324 | 324 |
146 | for (int h=column; h<column+count; ++h) { evaluated: h<column+count yes Evaluation Count:237 | yes Evaluation Count:69 |
| 69-237 |
147 | oldItem = horizontalHeaderItems.at(h); executed (the execution status of this line is deduced): oldItem = horizontalHeaderItems.at(h); | - |
148 | if (oldItem) evaluated: oldItem yes Evaluation Count:1 | yes Evaluation Count:236 |
| 1-236 |
149 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:1 | 1 |
150 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
151 | } executed: } Execution Count:237 | 237 |
152 | horizontalHeaderItems.remove(column, count); executed (the execution status of this line is deduced): horizontalHeaderItems.remove(column, count); | - |
153 | endRemoveColumns(); executed (the execution status of this line is deduced): endRemoveColumns(); | - |
154 | return true; executed: return true; Execution Count:69 | 69 |
155 | } | - |
156 | | - |
157 | void QTableModel::setItem(int row, int column, QTableWidgetItem *item) | - |
158 | { | - |
159 | int i = tableIndex(row, column); executed (the execution status of this line is deduced): int i = tableIndex(row, column); | - |
160 | 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 |
161 | return; | 0 |
162 | QTableWidgetItem *oldItem = tableItems.at(i); executed (the execution status of this line is deduced): QTableWidgetItem *oldItem = tableItems.at(i); | - |
163 | if (item == oldItem) partially evaluated: item == oldItem no Evaluation Count:0 | yes Evaluation Count:984 |
| 0-984 |
164 | return; | 0 |
165 | | - |
166 | // remove old | - |
167 | if (oldItem) evaluated: oldItem yes Evaluation Count:18 | yes Evaluation Count:966 |
| 18-966 |
168 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:18 | 18 |
169 | delete tableItems.at(i); executed (the execution status of this line is deduced): delete tableItems.at(i); | - |
170 | | - |
171 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); executed (the execution status of this line is deduced): QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
172 | | - |
173 | // set new | - |
174 | if (item) partially evaluated: item yes Evaluation Count:984 | no Evaluation Count:0 |
| 0-984 |
175 | item->d->id = i; executed: item->d->id = i; Execution Count:984 | 984 |
176 | tableItems[i] = item; executed (the execution status of this line is deduced): tableItems[i] = item; | - |
177 | | - |
178 | 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 |
179 | && view->horizontalHeader()->sortIndicatorSection() == column) { evaluated: view->horizontalHeader()->sortIndicatorSection() == column yes Evaluation Count:16 | yes Evaluation Count:9 |
| 9-16 |
180 | // sorted insertion | - |
181 | Qt::SortOrder order = view->horizontalHeader()->sortIndicatorOrder(); executed (the execution status of this line is deduced): Qt::SortOrder order = view->horizontalHeader()->sortIndicatorOrder(); | - |
182 | QVector<QTableWidgetItem*> colItems = columnItems(column); executed (the execution status of this line is deduced): QVector<QTableWidgetItem*> colItems = columnItems(column); | - |
183 | if (row < colItems.count()) partially evaluated: row < colItems.count() yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
184 | colItems.remove(row); executed: colItems.remove(row); Execution Count:16 | 16 |
185 | int sortedRow; executed (the execution status of this line is deduced): int sortedRow; | - |
186 | if (item == 0) { partially evaluated: item == 0 no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
187 | // move to after all non-0 (sortable) items | - |
188 | sortedRow = colItems.count(); never executed (the execution status of this line is deduced): sortedRow = colItems.count(); | - |
189 | } else { | 0 |
190 | QVector<QTableWidgetItem*>::iterator it; executed (the execution status of this line is deduced): QVector<QTableWidgetItem*>::iterator it; | - |
191 | it = sortedInsertionIterator(colItems.begin(), colItems.end(), order, item); executed (the execution status of this line is deduced): it = sortedInsertionIterator(colItems.begin(), colItems.end(), order, item); | - |
192 | sortedRow = qMax((int)(it - colItems.begin()), 0); executed (the execution status of this line is deduced): sortedRow = qMax((int)(it - colItems.begin()), 0); | - |
193 | } executed: } Execution Count:16 | 16 |
194 | if (sortedRow != row) { evaluated: sortedRow != row yes Evaluation Count:12 | yes Evaluation Count:4 |
| 4-12 |
195 | emit layoutAboutToBeChanged(); executed (the execution status of this line is deduced): layoutAboutToBeChanged(); | - |
196 | // move the items @ row to sortedRow | - |
197 | int cc = columnCount(); executed (the execution status of this line is deduced): int cc = columnCount(); | - |
198 | QVector<QTableWidgetItem*> rowItems(cc); executed (the execution status of this line is deduced): QVector<QTableWidgetItem*> rowItems(cc); | - |
199 | for (int j = 0; j < cc; ++j) evaluated: j < cc yes Evaluation Count:24 | yes Evaluation Count:12 |
| 12-24 |
200 | rowItems[j] = tableItems.at(tableIndex(row, j)); executed: rowItems[j] = tableItems.at(tableIndex(row, j)); Execution Count:24 | 24 |
201 | tableItems.remove(tableIndex(row, 0), cc); executed (the execution status of this line is deduced): tableItems.remove(tableIndex(row, 0), cc); | - |
202 | tableItems.insert(tableIndex(sortedRow, 0), cc, 0); executed (the execution status of this line is deduced): tableItems.insert(tableIndex(sortedRow, 0), cc, 0); | - |
203 | for (int j = 0; j < cc; ++j) evaluated: j < cc yes Evaluation Count:24 | yes Evaluation Count:12 |
| 12-24 |
204 | tableItems[tableIndex(sortedRow, j)] = rowItems.at(j); executed: tableItems[tableIndex(sortedRow, j)] = rowItems.at(j); Execution Count:24 | 24 |
205 | QTableWidgetItem *header = verticalHeaderItems.at(row); executed (the execution status of this line is deduced): QTableWidgetItem *header = verticalHeaderItems.at(row); | - |
206 | verticalHeaderItems.remove(row); executed (the execution status of this line is deduced): verticalHeaderItems.remove(row); | - |
207 | verticalHeaderItems.insert(sortedRow, header); executed (the execution status of this line is deduced): verticalHeaderItems.insert(sortedRow, header); | - |
208 | // update persistent indexes | - |
209 | QModelIndexList oldPersistentIndexes = persistentIndexList(); executed (the execution status of this line is deduced): QModelIndexList oldPersistentIndexes = persistentIndexList(); | - |
210 | QModelIndexList newPersistentIndexes = oldPersistentIndexes; executed (the execution status of this line is deduced): QModelIndexList newPersistentIndexes = oldPersistentIndexes; | - |
211 | updateRowIndexes(newPersistentIndexes, row, sortedRow); executed (the execution status of this line is deduced): updateRowIndexes(newPersistentIndexes, row, sortedRow); | - |
212 | changePersistentIndexList(oldPersistentIndexes, executed (the execution status of this line is deduced): changePersistentIndexList(oldPersistentIndexes, | - |
213 | newPersistentIndexes); executed (the execution status of this line is deduced): newPersistentIndexes); | - |
214 | | - |
215 | emit layoutChanged(); executed (the execution status of this line is deduced): layoutChanged(); | - |
216 | return; executed: return; Execution Count:12 | 12 |
217 | } | - |
218 | } executed: } Execution Count:4 | 4 |
219 | QModelIndex idx = QAbstractTableModel::index(row, column); executed (the execution status of this line is deduced): QModelIndex idx = QAbstractTableModel::index(row, column); | - |
220 | emit dataChanged(idx, idx); executed (the execution status of this line is deduced): dataChanged(idx, idx); | - |
221 | } executed: } Execution Count:972 | 972 |
222 | | - |
223 | QTableWidgetItem *QTableModel::takeItem(int row, int column) | - |
224 | { | - |
225 | long i = tableIndex(row, column); executed (the execution status of this line is deduced): long i = tableIndex(row, column); | - |
226 | QTableWidgetItem *itm = tableItems.value(i); executed (the execution status of this line is deduced): QTableWidgetItem *itm = tableItems.value(i); | - |
227 | if (itm) { evaluated: itm yes Evaluation Count:4 | yes Evaluation Count:8 |
| 4-8 |
228 | itm->view = 0; executed (the execution status of this line is deduced): itm->view = 0; | - |
229 | itm->d->id = -1; executed (the execution status of this line is deduced): itm->d->id = -1; | - |
230 | tableItems[i] = 0; executed (the execution status of this line is deduced): tableItems[i] = 0; | - |
231 | QModelIndex ind = index(itm); executed (the execution status of this line is deduced): QModelIndex ind = index(itm); | - |
232 | emit dataChanged(ind, ind); executed (the execution status of this line is deduced): dataChanged(ind, ind); | - |
233 | } executed: } Execution Count:4 | 4 |
234 | return itm; executed: return itm; Execution Count:12 | 12 |
235 | } | - |
236 | | - |
237 | QTableWidgetItem *QTableModel::item(int row, int column) const | - |
238 | { | - |
239 | return item(index(row, column)); executed: return item(index(row, column)); Execution Count:6409 | 6409 |
240 | } | - |
241 | | - |
242 | QTableWidgetItem *QTableModel::item(const QModelIndex &index) const | - |
243 | { | - |
244 | if (!isValid(index)) evaluated: !isValid(index) yes Evaluation Count:75 | yes Evaluation Count:10474 |
| 75-10474 |
245 | return 0; executed: return 0; Execution Count:75 | 75 |
246 | return tableItems.at(tableIndex(index.row(), index.column())); executed: return tableItems.at(tableIndex(index.row(), index.column())); Execution Count:10474 | 10474 |
247 | } | - |
248 | | - |
249 | void QTableModel::removeItem(QTableWidgetItem *item) | - |
250 | { | - |
251 | int i = tableItems.indexOf(item); executed (the execution status of this line is deduced): int i = tableItems.indexOf(item); | - |
252 | if (i != -1) { evaluated: i != -1 yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
253 | tableItems[i] = 0; executed (the execution status of this line is deduced): tableItems[i] = 0; | - |
254 | QModelIndex idx = index(item); executed (the execution status of this line is deduced): QModelIndex idx = index(item); | - |
255 | emit dataChanged(idx, idx); executed (the execution status of this line is deduced): dataChanged(idx, idx); | - |
256 | return; executed: return; Execution Count:3 | 3 |
257 | } | - |
258 | | - |
259 | i = verticalHeaderItems.indexOf(item); executed (the execution status of this line is deduced): i = verticalHeaderItems.indexOf(item); | - |
260 | | - |
261 | if (i != -1) { evaluated: i != -1 yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
262 | verticalHeaderItems[i] = 0; executed (the execution status of this line is deduced): verticalHeaderItems[i] = 0; | - |
263 | emit headerDataChanged(Qt::Vertical, i, i); executed (the execution status of this line is deduced): headerDataChanged(Qt::Vertical, i, i); | - |
264 | return; executed: return; Execution Count:1 | 1 |
265 | } | - |
266 | i = horizontalHeaderItems.indexOf(item); executed (the execution status of this line is deduced): i = horizontalHeaderItems.indexOf(item); | - |
267 | if (i != -1) { partially evaluated: i != -1 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
268 | horizontalHeaderItems[i] = 0; executed (the execution status of this line is deduced): horizontalHeaderItems[i] = 0; | - |
269 | emit headerDataChanged(Qt::Horizontal, i, i); executed (the execution status of this line is deduced): headerDataChanged(Qt::Horizontal, i, i); | - |
270 | return; executed: return; Execution Count:1 | 1 |
271 | } | - |
272 | } | 0 |
273 | | - |
274 | void QTableModel::setHorizontalHeaderItem(int section, QTableWidgetItem *item) | - |
275 | { | - |
276 | 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 |
277 | return; | 0 |
278 | QTableWidgetItem *oldItem = horizontalHeaderItems.at(section); executed (the execution status of this line is deduced): QTableWidgetItem *oldItem = horizontalHeaderItems.at(section); | - |
279 | if (item == oldItem) partially evaluated: item == oldItem no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
280 | return; | 0 |
281 | | - |
282 | if (oldItem) evaluated: oldItem yes Evaluation Count:2 | yes Evaluation Count:9 |
| 2-9 |
283 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:2 | 2 |
284 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
285 | | - |
286 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); executed (the execution status of this line is deduced): QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
287 | | - |
288 | if (item) { partially evaluated: item yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
289 | item->view = view; executed (the execution status of this line is deduced): item->view = view; | - |
290 | item->itemFlags = Qt::ItemFlags(int(item->itemFlags)|ItemIsHeaderItem); executed (the execution status of this line is deduced): item->itemFlags = Qt::ItemFlags(int(item->itemFlags)|ItemIsHeaderItem); | - |
291 | } executed: } Execution Count:11 | 11 |
292 | horizontalHeaderItems[section] = item; executed (the execution status of this line is deduced): horizontalHeaderItems[section] = item; | - |
293 | emit headerDataChanged(Qt::Horizontal, section, section); executed (the execution status of this line is deduced): headerDataChanged(Qt::Horizontal, section, section); | - |
294 | } executed: } Execution Count:11 | 11 |
295 | | - |
296 | void QTableModel::setVerticalHeaderItem(int section, QTableWidgetItem *item) | - |
297 | { | - |
298 | 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 |
299 | return; | 0 |
300 | QTableWidgetItem *oldItem = verticalHeaderItems.at(section); executed (the execution status of this line is deduced): QTableWidgetItem *oldItem = verticalHeaderItems.at(section); | - |
301 | if (item == oldItem) partially evaluated: item == oldItem no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
302 | return; | 0 |
303 | | - |
304 | if (oldItem) evaluated: oldItem yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
305 | oldItem->view = 0; executed: oldItem->view = 0; Execution Count:2 | 2 |
306 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
307 | | - |
308 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); executed (the execution status of this line is deduced): QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
309 | | - |
310 | if (item) { partially evaluated: item yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
311 | item->view = view; executed (the execution status of this line is deduced): item->view = view; | - |
312 | item->itemFlags = Qt::ItemFlags(int(item->itemFlags)|ItemIsHeaderItem); executed (the execution status of this line is deduced): item->itemFlags = Qt::ItemFlags(int(item->itemFlags)|ItemIsHeaderItem); | - |
313 | } executed: } Execution Count:7 | 7 |
314 | verticalHeaderItems[section] = item; executed (the execution status of this line is deduced): verticalHeaderItems[section] = item; | - |
315 | emit headerDataChanged(Qt::Vertical, section, section); executed (the execution status of this line is deduced): headerDataChanged(Qt::Vertical, section, section); | - |
316 | } executed: } Execution Count:7 | 7 |
317 | | - |
318 | QTableWidgetItem *QTableModel::takeHorizontalHeaderItem(int section) | - |
319 | { | - |
320 | if (section < 0 || section >= horizontalHeaderItems.count()) never evaluated: section < 0 never evaluated: section >= horizontalHeaderItems.count() | 0 |
321 | return 0; never executed: return 0; | 0 |
322 | QTableWidgetItem *itm = horizontalHeaderItems.at(section); never executed (the execution status of this line is deduced): QTableWidgetItem *itm = horizontalHeaderItems.at(section); | - |
323 | if (itm) { | 0 |
324 | itm->view = 0; never executed (the execution status of this line is deduced): itm->view = 0; | - |
325 | itm->itemFlags &= ~ItemIsHeaderItem; never executed (the execution status of this line is deduced): itm->itemFlags &= ~ItemIsHeaderItem; | - |
326 | horizontalHeaderItems[section] = 0; never executed (the execution status of this line is deduced): horizontalHeaderItems[section] = 0; | - |
327 | } | 0 |
328 | return itm; never executed: return itm; | 0 |
329 | } | - |
330 | | - |
331 | QTableWidgetItem *QTableModel::takeVerticalHeaderItem(int section) | - |
332 | { | - |
333 | if (section < 0 || section >= verticalHeaderItems.count()) never evaluated: section < 0 never evaluated: section >= verticalHeaderItems.count() | 0 |
334 | return 0; never executed: return 0; | 0 |
335 | QTableWidgetItem *itm = verticalHeaderItems.at(section); never executed (the execution status of this line is deduced): QTableWidgetItem *itm = verticalHeaderItems.at(section); | - |
336 | if (itm) { | 0 |
337 | itm->view = 0; never executed (the execution status of this line is deduced): itm->view = 0; | - |
338 | itm->itemFlags &= ~ItemIsHeaderItem; never executed (the execution status of this line is deduced): itm->itemFlags &= ~ItemIsHeaderItem; | - |
339 | verticalHeaderItems[section] = 0; never executed (the execution status of this line is deduced): verticalHeaderItems[section] = 0; | - |
340 | } | 0 |
341 | return itm; never executed: return itm; | 0 |
342 | } | - |
343 | | - |
344 | QTableWidgetItem *QTableModel::horizontalHeaderItem(int section) | - |
345 | { | - |
346 | return horizontalHeaderItems.value(section); executed: return horizontalHeaderItems.value(section); Execution Count:6 | 6 |
347 | } | - |
348 | | - |
349 | QTableWidgetItem *QTableModel::verticalHeaderItem(int section) | - |
350 | { | - |
351 | return verticalHeaderItems.value(section); executed: return verticalHeaderItems.value(section); Execution Count:4 | 4 |
352 | } | - |
353 | | - |
354 | QModelIndex QTableModel::index(const QTableWidgetItem *item) const | - |
355 | { | - |
356 | if (!item) evaluated: !item yes Evaluation Count:1 | yes Evaluation Count:64 |
| 1-64 |
357 | return QModelIndex(); executed: return QModelIndex(); Execution Count:1 | 1 |
358 | int i = -1; executed (the execution status of this line is deduced): int i = -1; | - |
359 | const int id = item->d->id; executed (the execution status of this line is deduced): const int id = item->d->id; | - |
360 | 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 |
361 | i = id; executed (the execution status of this line is deduced): i = id; | - |
362 | } else { // we need to search for the item executed: } Execution Count:56 | 56 |
363 | i = tableItems.indexOf(const_cast<QTableWidgetItem*>(item)); executed (the execution status of this line is deduced): i = tableItems.indexOf(const_cast<QTableWidgetItem*>(item)); | - |
364 | if (i == -1) // not found evaluated: i == -1 yes Evaluation Count:7 | yes Evaluation Count:1 |
| 1-7 |
365 | return QModelIndex(); executed: return QModelIndex(); Execution Count:7 | 7 |
366 | } executed: } Execution Count:1 | 1 |
367 | int row = i / columnCount(); executed (the execution status of this line is deduced): int row = i / columnCount(); | - |
368 | int col = i % columnCount(); executed (the execution status of this line is deduced): int col = i % columnCount(); | - |
369 | return QAbstractTableModel::index(row, col); executed: return QAbstractTableModel::index(row, col); Execution Count:57 | 57 |
370 | } | - |
371 | | - |
372 | void QTableModel::setRowCount(int rows) | - |
373 | { | - |
374 | int rc = verticalHeaderItems.count(); executed (the execution status of this line is deduced): int rc = verticalHeaderItems.count(); | - |
375 | 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 |
376 | return; executed: return; Execution Count:67 | 67 |
377 | if (rc < rows) evaluated: rc < rows yes Evaluation Count:158 | yes Evaluation Count:62 |
| 62-158 |
378 | insertRows(qMax(rc, 0), rows - rc); executed: insertRows(qMax(rc, 0), rows - rc); Execution Count:158 | 158 |
379 | else | - |
380 | removeRows(qMax(rows, 0), rc - rows); executed: removeRows(qMax(rows, 0), rc - rows); Execution Count:62 | 62 |
381 | } | - |
382 | | - |
383 | void QTableModel::setColumnCount(int columns) | - |
384 | { | - |
385 | int cc = horizontalHeaderItems.count(); executed (the execution status of this line is deduced): int cc = horizontalHeaderItems.count(); | - |
386 | 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 |
387 | return; executed: return; Execution Count:92 | 92 |
388 | if (cc < columns) evaluated: cc < columns yes Evaluation Count:146 | yes Evaluation Count:50 |
| 50-146 |
389 | insertColumns(qMax(cc, 0), columns - cc); executed: insertColumns(qMax(cc, 0), columns - cc); Execution Count:146 | 146 |
390 | else | - |
391 | removeColumns(qMax(columns, 0), cc - columns); executed: removeColumns(qMax(columns, 0), cc - columns); Execution Count:50 | 50 |
392 | } | - |
393 | | - |
394 | int QTableModel::rowCount(const QModelIndex &parent) const | - |
395 | { | - |
396 | return parent.isValid() ? 0 : verticalHeaderItems.count(); executed: return parent.isValid() ? 0 : verticalHeaderItems.count(); Execution Count:17923 | 17923 |
397 | } | - |
398 | | - |
399 | int QTableModel::columnCount(const QModelIndex &parent) const | - |
400 | { | - |
401 | return parent.isValid() ? 0 : horizontalHeaderItems.count(); executed: return parent.isValid() ? 0 : horizontalHeaderItems.count(); Execution Count:22214 | 22214 |
402 | } | - |
403 | | - |
404 | QVariant QTableModel::data(const QModelIndex &index, int role) const | - |
405 | { | - |
406 | QTableWidgetItem *itm = item(index); executed (the execution status of this line is deduced): QTableWidgetItem *itm = item(index); | - |
407 | if (itm) evaluated: itm yes Evaluation Count:1173 | yes Evaluation Count:555 |
| 555-1173 |
408 | return itm->data(role); executed: return itm->data(role); Execution Count:1173 | 1173 |
409 | return QVariant(); executed: return QVariant(); Execution Count:555 | 555 |
410 | } | - |
411 | | - |
412 | bool QTableModel::setData(const QModelIndex &index, const QVariant &value, int role) | - |
413 | { | - |
414 | if (!index.isValid()) evaluated: !index.isValid() yes Evaluation Count:5 | yes Evaluation Count:404 |
| 5-404 |
415 | return false; executed: return false; Execution Count:5 | 5 |
416 | | - |
417 | QTableWidgetItem *itm = item(index); executed (the execution status of this line is deduced): QTableWidgetItem *itm = item(index); | - |
418 | if (itm) { evaluated: itm yes Evaluation Count:3 | yes Evaluation Count:401 |
| 3-401 |
419 | itm->setData(role, value); executed (the execution status of this line is deduced): itm->setData(role, value); | - |
420 | return true; executed: return true; Execution Count:3 | 3 |
421 | } | - |
422 | | - |
423 | // don't create dummy table items for empty values | - |
424 | if (!value.isValid()) partially evaluated: !value.isValid() no Evaluation Count:0 | yes Evaluation Count:401 |
| 0-401 |
425 | return false; never executed: return false; | 0 |
426 | | - |
427 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); executed (the execution status of this line is deduced): QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
428 | if (!view) partially evaluated: !view no Evaluation Count:0 | yes Evaluation Count:401 |
| 0-401 |
429 | return false; never executed: return false; | 0 |
430 | | - |
431 | itm = createItem(); executed (the execution status of this line is deduced): itm = createItem(); | - |
432 | itm->setData(role, value); executed (the execution status of this line is deduced): itm->setData(role, value); | - |
433 | view->setItem(index.row(), index.column(), itm); executed (the execution status of this line is deduced): view->setItem(index.row(), index.column(), itm); | - |
434 | return true; executed: return true; Execution Count:401 | 401 |
435 | } | - |
436 | | - |
437 | QMap<int, QVariant> QTableModel::itemData(const QModelIndex &index) const | - |
438 | { | - |
439 | QMap<int, QVariant> roles; executed (the execution status of this line is deduced): QMap<int, QVariant> roles; | - |
440 | QTableWidgetItem *itm = item(index); executed (the execution status of this line is deduced): QTableWidgetItem *itm = item(index); | - |
441 | if (itm) { evaluated: itm yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
442 | for (int i = 0; i < itm->values.count(); ++i) { evaluated: i < itm->values.count() yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
443 | roles.insert(itm->values.at(i).role, executed (the execution status of this line is deduced): roles.insert(itm->values.at(i).role, | - |
444 | itm->values.at(i).value); executed (the execution status of this line is deduced): itm->values.at(i).value); | - |
445 | } executed: } Execution Count:6 | 6 |
446 | } executed: } Execution Count:1 | 1 |
447 | return roles; executed: return roles; Execution Count:3 | 3 |
448 | } | - |
449 | | - |
450 | // reimplemented to ensure that only one dataChanged() signal is emitted | - |
451 | bool QTableModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) | - |
452 | { | - |
453 | if (!index.isValid()) evaluated: !index.isValid() yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
454 | return false; executed: return false; Execution Count:2 | 2 |
455 | | - |
456 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); executed (the execution status of this line is deduced): QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
457 | QTableWidgetItem *itm = item(index); executed (the execution status of this line is deduced): QTableWidgetItem *itm = item(index); | - |
458 | if (itm) { partially evaluated: itm yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
459 | itm->view = 0; // prohibits item from calling itemChanged() executed (the execution status of this line is deduced): itm->view = 0; | - |
460 | bool changed = false; executed (the execution status of this line is deduced): bool changed = false; | - |
461 | 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 |
462 | if (itm->data(it.key()) != it.value()) { evaluated: itm->data(it.key()) != it.value() yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
463 | itm->setData(it.key(), it.value()); executed (the execution status of this line is deduced): itm->setData(it.key(), it.value()); | - |
464 | changed = true; executed (the execution status of this line is deduced): changed = true; | - |
465 | } executed: } Execution Count:3 | 3 |
466 | } executed: } Execution Count:5 | 5 |
467 | itm->view = view; executed (the execution status of this line is deduced): itm->view = view; | - |
468 | if (changed) evaluated: changed yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
469 | itemChanged(itm); executed: itemChanged(itm); Execution Count:2 | 2 |
470 | return true; executed: return true; Execution Count:3 | 3 |
471 | } | - |
472 | | - |
473 | if (!view) | 0 |
474 | return false; never executed: return false; | 0 |
475 | | - |
476 | itm = createItem(); never executed (the execution status of this line is deduced): itm = createItem(); | - |
477 | for (QMap<int, QVariant>::ConstIterator it = roles.constBegin(); it != roles.constEnd(); ++it) never evaluated: it != roles.constEnd() | 0 |
478 | itm->setData(it.key(), it.value()); never executed: itm->setData(it.key(), it.value()); | 0 |
479 | view->setItem(index.row(), index.column(), itm); never executed (the execution status of this line is deduced): view->setItem(index.row(), index.column(), itm); | - |
480 | return true; never executed: return true; | 0 |
481 | } | - |
482 | | - |
483 | Qt::ItemFlags QTableModel::flags(const QModelIndex &index) const | - |
484 | { | - |
485 | if (!index.isValid()) evaluated: !index.isValid() yes Evaluation Count:2 | yes Evaluation Count:745 |
| 2-745 |
486 | return Qt::ItemIsDropEnabled; executed: return Qt::ItemIsDropEnabled; Execution Count:2 | 2 |
487 | if (QTableWidgetItem *itm = item(index)) evaluated: QTableWidgetItem *itm = item(index) yes Evaluation Count:340 | yes Evaluation Count:405 |
| 340-405 |
488 | return itm->flags(); executed: return itm->flags(); Execution Count:340 | 340 |
489 | return (Qt::ItemIsEditable executed: return (Qt::ItemIsEditable |Qt::ItemIsSelectable |Qt::ItemIsUserCheckable |Qt::ItemIsEnabled |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled); Execution Count:405 | 405 |
490 | |Qt::ItemIsSelectable executed: return (Qt::ItemIsEditable |Qt::ItemIsSelectable |Qt::ItemIsUserCheckable |Qt::ItemIsEnabled |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled); Execution Count:405 | 405 |
491 | |Qt::ItemIsUserCheckable executed: return (Qt::ItemIsEditable |Qt::ItemIsSelectable |Qt::ItemIsUserCheckable |Qt::ItemIsEnabled |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled); Execution Count:405 | 405 |
492 | |Qt::ItemIsEnabled executed: return (Qt::ItemIsEditable |Qt::ItemIsSelectable |Qt::ItemIsUserCheckable |Qt::ItemIsEnabled |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled); Execution Count:405 | 405 |
493 | |Qt::ItemIsDragEnabled executed: return (Qt::ItemIsEditable |Qt::ItemIsSelectable |Qt::ItemIsUserCheckable |Qt::ItemIsEnabled |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled); Execution Count:405 | 405 |
494 | |Qt::ItemIsDropEnabled); executed: return (Qt::ItemIsEditable |Qt::ItemIsSelectable |Qt::ItemIsUserCheckable |Qt::ItemIsEnabled |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled); Execution Count:405 | 405 |
495 | } | - |
496 | | - |
497 | void QTableModel::sort(int column, Qt::SortOrder order) | - |
498 | { | - |
499 | QVector<QPair<QTableWidgetItem*, int> > sortable; executed (the execution status of this line is deduced): QVector<QPair<QTableWidgetItem*, int> > sortable; | - |
500 | QVector<int> unsortable; executed (the execution status of this line is deduced): QVector<int> unsortable; | - |
501 | | - |
502 | sortable.reserve(rowCount()); executed (the execution status of this line is deduced): sortable.reserve(rowCount()); | - |
503 | unsortable.reserve(rowCount()); executed (the execution status of this line is deduced): unsortable.reserve(rowCount()); | - |
504 | | - |
505 | for (int row = 0; row < rowCount(); ++row) { evaluated: row < rowCount() yes Evaluation Count:408 | yes Evaluation Count:63 |
| 63-408 |
506 | if (QTableWidgetItem *itm = item(row, column)) evaluated: QTableWidgetItem *itm = item(row, column) yes Evaluation Count:145 | yes Evaluation Count:263 |
| 145-263 |
507 | sortable.append(QPair<QTableWidgetItem*,int>(itm, row)); executed: sortable.append(QPair<QTableWidgetItem*,int>(itm, row)); Execution Count:145 | 145 |
508 | else | - |
509 | unsortable.append(row); executed: unsortable.append(row); Execution Count:263 | 263 |
510 | } | - |
511 | | - |
512 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); evaluated: order == Qt::AscendingOrder yes Evaluation Count:51 | yes Evaluation Count:12 |
| 12-51 |
513 | qStableSort(sortable.begin(), sortable.end(), compare); executed (the execution status of this line is deduced): qStableSort(sortable.begin(), sortable.end(), compare); | - |
514 | | - |
515 | QVector<QTableWidgetItem*> sorted_table(tableItems.count()); executed (the execution status of this line is deduced): QVector<QTableWidgetItem*> sorted_table(tableItems.count()); | - |
516 | QModelIndexList from; executed (the execution status of this line is deduced): QModelIndexList from; | - |
517 | QModelIndexList to; executed (the execution status of this line is deduced): QModelIndexList to; | - |
518 | for (int i = 0; i < rowCount(); ++i) { evaluated: i < rowCount() yes Evaluation Count:408 | yes Evaluation Count:63 |
| 63-408 |
519 | int r = (i < sortable.count() evaluated: i < sortable.count() yes Evaluation Count:145 | yes Evaluation Count:263 |
| 145-263 |
520 | ? sortable.at(i).second executed (the execution status of this line is deduced): ? sortable.at(i).second | - |
521 | : unsortable.at(i - sortable.count())); executed (the execution status of this line is deduced): : unsortable.at(i - sortable.count())); | - |
522 | for (int c = 0; c < columnCount(); ++c) { evaluated: c < columnCount() yes Evaluation Count:5312 | yes Evaluation Count:408 |
| 408-5312 |
523 | sorted_table[tableIndex(i, c)] = item(r, c); executed (the execution status of this line is deduced): sorted_table[tableIndex(i, c)] = item(r, c); | - |
524 | from.append(createIndex(r, c)); executed (the execution status of this line is deduced): from.append(createIndex(r, c)); | - |
525 | to.append(createIndex(i, c)); executed (the execution status of this line is deduced): to.append(createIndex(i, c)); | - |
526 | } executed: } Execution Count:5312 | 5312 |
527 | } executed: } Execution Count:408 | 408 |
528 | | - |
529 | emit layoutAboutToBeChanged(); executed (the execution status of this line is deduced): layoutAboutToBeChanged(); | - |
530 | | - |
531 | tableItems = sorted_table; executed (the execution status of this line is deduced): tableItems = sorted_table; | - |
532 | changePersistentIndexList(from, to); // ### slow executed (the execution status of this line is deduced): changePersistentIndexList(from, to); | - |
533 | | - |
534 | emit layoutChanged(); executed (the execution status of this line is deduced): layoutChanged(); | - |
535 | } executed: } Execution Count:63 | 63 |
536 | | - |
537 | /* | - |
538 | \internal | - |
539 | | - |
540 | Ensures that rows in the interval [start, end] are | - |
541 | sorted according to the contents of column \a column | - |
542 | and the given sort \a order. | - |
543 | */ | - |
544 | void QTableModel::ensureSorted(int column, Qt::SortOrder order, | - |
545 | int start, int end) | - |
546 | { | - |
547 | int count = end - start + 1; executed (the execution status of this line is deduced): int count = end - start + 1; | - |
548 | QVector < QPair<QTableWidgetItem*,int> > sorting; executed (the execution status of this line is deduced): QVector < QPair<QTableWidgetItem*,int> > sorting; | - |
549 | sorting.reserve(count); executed (the execution status of this line is deduced): sorting.reserve(count); | - |
550 | for (int row = start; row <= end; ++row) { evaluated: row <= end yes Evaluation Count:13 | yes Evaluation Count:13 |
| 13 |
551 | QTableWidgetItem *itm = item(row, column); executed (the execution status of this line is deduced): QTableWidgetItem *itm = item(row, column); | - |
552 | if (itm == 0) { partially evaluated: itm == 0 no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
553 | // no more sortable items (all 0-items are | - |
554 | // at the end of the table when it is sorted) | - |
555 | break; | 0 |
556 | } | - |
557 | sorting.append(QPair<QTableWidgetItem*,int>(itm, row)); executed (the execution status of this line is deduced): sorting.append(QPair<QTableWidgetItem*,int>(itm, row)); | - |
558 | } executed: } Execution Count:13 | 13 |
559 | | - |
560 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); evaluated: order == Qt::AscendingOrder yes Evaluation Count:9 | yes Evaluation Count:4 |
| 4-9 |
561 | qStableSort(sorting.begin(), sorting.end(), compare); executed (the execution status of this line is deduced): qStableSort(sorting.begin(), sorting.end(), compare); | - |
562 | | - |
563 | QModelIndexList oldPersistentIndexes = persistentIndexList(); executed (the execution status of this line is deduced): QModelIndexList oldPersistentIndexes = persistentIndexList(); | - |
564 | QModelIndexList newPersistentIndexes = oldPersistentIndexes; executed (the execution status of this line is deduced): QModelIndexList newPersistentIndexes = oldPersistentIndexes; | - |
565 | QVector<QTableWidgetItem*> newTable = tableItems; executed (the execution status of this line is deduced): QVector<QTableWidgetItem*> newTable = tableItems; | - |
566 | QVector<QTableWidgetItem*> newVertical = verticalHeaderItems; executed (the execution status of this line is deduced): QVector<QTableWidgetItem*> newVertical = verticalHeaderItems; | - |
567 | QVector<QTableWidgetItem*> colItems = columnItems(column); executed (the execution status of this line is deduced): QVector<QTableWidgetItem*> colItems = columnItems(column); | - |
568 | QVector<QTableWidgetItem*>::iterator vit = colItems.begin(); executed (the execution status of this line is deduced): QVector<QTableWidgetItem*>::iterator vit = colItems.begin(); | - |
569 | bool changed = false; executed (the execution status of this line is deduced): bool changed = false; | - |
570 | for (int i = 0; i < sorting.count(); ++i) { evaluated: i < sorting.count() yes Evaluation Count:13 | yes Evaluation Count:13 |
| 13 |
571 | int oldRow = sorting.at(i).second; executed (the execution status of this line is deduced): int oldRow = sorting.at(i).second; | - |
572 | QTableWidgetItem *item = colItems.at(oldRow); executed (the execution status of this line is deduced): QTableWidgetItem *item = colItems.at(oldRow); | - |
573 | colItems.remove(oldRow); executed (the execution status of this line is deduced): colItems.remove(oldRow); | - |
574 | vit = sortedInsertionIterator(vit, colItems.end(), order, item); executed (the execution status of this line is deduced): vit = sortedInsertionIterator(vit, colItems.end(), order, item); | - |
575 | int newRow = qMax((int)(vit - colItems.begin()), 0); executed (the execution status of this line is deduced): int newRow = qMax((int)(vit - colItems.begin()), 0); | - |
576 | 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 |
577 | newRow = oldRow; executed: newRow = oldRow; Execution Count:1 | 1 |
578 | vit = colItems.insert(vit, item); executed (the execution status of this line is deduced): vit = colItems.insert(vit, item); | - |
579 | if (newRow != oldRow) { evaluated: newRow != oldRow yes Evaluation Count:5 | yes Evaluation Count:8 |
| 5-8 |
580 | changed = true; executed (the execution status of this line is deduced): changed = true; | - |
581 | // move the items @ oldRow to newRow | - |
582 | int cc = columnCount(); executed (the execution status of this line is deduced): int cc = columnCount(); | - |
583 | QVector<QTableWidgetItem*> rowItems(cc); executed (the execution status of this line is deduced): QVector<QTableWidgetItem*> rowItems(cc); | - |
584 | for (int j = 0; j < cc; ++j) evaluated: j < cc yes Evaluation Count:10 | yes Evaluation Count:5 |
| 5-10 |
585 | rowItems[j] = newTable.at(tableIndex(oldRow, j)); executed: rowItems[j] = newTable.at(tableIndex(oldRow, j)); Execution Count:10 | 10 |
586 | newTable.remove(tableIndex(oldRow, 0), cc); executed (the execution status of this line is deduced): newTable.remove(tableIndex(oldRow, 0), cc); | - |
587 | newTable.insert(tableIndex(newRow, 0), cc, 0); executed (the execution status of this line is deduced): newTable.insert(tableIndex(newRow, 0), cc, 0); | - |
588 | for (int j = 0; j < cc; ++j) evaluated: j < cc yes Evaluation Count:10 | yes Evaluation Count:5 |
| 5-10 |
589 | newTable[tableIndex(newRow, j)] = rowItems.at(j); executed: newTable[tableIndex(newRow, j)] = rowItems.at(j); Execution Count:10 | 10 |
590 | QTableWidgetItem *header = newVertical.at(oldRow); executed (the execution status of this line is deduced): QTableWidgetItem *header = newVertical.at(oldRow); | - |
591 | newVertical.remove(oldRow); executed (the execution status of this line is deduced): newVertical.remove(oldRow); | - |
592 | newVertical.insert(newRow, header); executed (the execution status of this line is deduced): newVertical.insert(newRow, header); | - |
593 | // update persistent indexes | - |
594 | updateRowIndexes(newPersistentIndexes, oldRow, newRow); executed (the execution status of this line is deduced): updateRowIndexes(newPersistentIndexes, oldRow, newRow); | - |
595 | // the index of the remaining rows may have changed | - |
596 | for (int j = i + 1; j < sorting.count(); ++j) { partially evaluated: j < sorting.count() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
597 | int otherRow = sorting.at(j).second; never executed (the execution status of this line is deduced): int otherRow = sorting.at(j).second; | - |
598 | if (oldRow < otherRow && newRow >= otherRow) never evaluated: oldRow < otherRow never evaluated: newRow >= otherRow | 0 |
599 | --sorting[j].second; never executed: --sorting[j].second; | 0 |
600 | else if (oldRow > otherRow && newRow <= otherRow) never evaluated: oldRow > otherRow never evaluated: newRow <= otherRow | 0 |
601 | ++sorting[j].second; never executed: ++sorting[j].second; | 0 |
602 | } | - |
603 | } executed: } Execution Count:5 | 5 |
604 | } executed: } Execution Count:13 | 13 |
605 | | - |
606 | if (changed) { evaluated: changed yes Evaluation Count:5 | yes Evaluation Count:8 |
| 5-8 |
607 | emit layoutAboutToBeChanged(); executed (the execution status of this line is deduced): layoutAboutToBeChanged(); | - |
608 | tableItems = newTable; executed (the execution status of this line is deduced): tableItems = newTable; | - |
609 | verticalHeaderItems = newVertical; executed (the execution status of this line is deduced): verticalHeaderItems = newVertical; | - |
610 | changePersistentIndexList(oldPersistentIndexes, executed (the execution status of this line is deduced): changePersistentIndexList(oldPersistentIndexes, | - |
611 | newPersistentIndexes); executed (the execution status of this line is deduced): newPersistentIndexes); | - |
612 | emit layoutChanged(); executed (the execution status of this line is deduced): layoutChanged(); | - |
613 | } executed: } Execution Count:5 | 5 |
614 | } executed: } Execution Count:13 | 13 |
615 | | - |
616 | /* | - |
617 | \internal | - |
618 | | - |
619 | Returns the non-0 items in column \a column. | - |
620 | */ | - |
621 | QVector<QTableWidgetItem*> QTableModel::columnItems(int column) const | - |
622 | { | - |
623 | QVector<QTableWidgetItem*> items; executed (the execution status of this line is deduced): QVector<QTableWidgetItem*> items; | - |
624 | int rc = rowCount(); executed (the execution status of this line is deduced): int rc = rowCount(); | - |
625 | items.reserve(rc); executed (the execution status of this line is deduced): items.reserve(rc); | - |
626 | for (int row = 0; row < rc; ++row) { evaluated: row < rc yes Evaluation Count:103 | yes Evaluation Count:21 |
| 21-103 |
627 | QTableWidgetItem *itm = item(row, column); executed (the execution status of this line is deduced): QTableWidgetItem *itm = item(row, column); | - |
628 | if (itm == 0) { evaluated: itm == 0 yes Evaluation Count:8 | yes Evaluation Count:95 |
| 8-95 |
629 | // no more sortable items (all 0-items are | - |
630 | // at the end of the table when it is sorted) | - |
631 | break; executed: break; Execution Count:8 | 8 |
632 | } | - |
633 | items.append(itm); executed (the execution status of this line is deduced): items.append(itm); | - |
634 | } executed: } Execution Count:95 | 95 |
635 | return items; executed: return items; Execution Count:29 | 29 |
636 | } | - |
637 | | - |
638 | /* | - |
639 | \internal | - |
640 | | - |
641 | Adjusts the row of each index in \a indexes if necessary, given | - |
642 | that a row of items has been moved from row \a movedFrom to row | - |
643 | \a movedTo. | - |
644 | */ | - |
645 | void QTableModel::updateRowIndexes(QModelIndexList &indexes, | - |
646 | int movedFromRow, int movedToRow) | - |
647 | { | - |
648 | QModelIndexList::iterator it; executed (the execution status of this line is deduced): QModelIndexList::iterator it; | - |
649 | for (it = indexes.begin(); it != indexes.end(); ++it) { evaluated: it != indexes.end() yes Evaluation Count:39 | yes Evaluation Count:17 |
| 17-39 |
650 | int oldRow = (*it).row(); executed (the execution status of this line is deduced): int oldRow = (*it).row(); | - |
651 | int newRow = oldRow; executed (the execution status of this line is deduced): int newRow = oldRow; | - |
652 | if (oldRow == movedFromRow) evaluated: oldRow == movedFromRow yes Evaluation Count:10 | yes Evaluation Count:29 |
| 10-29 |
653 | newRow = movedToRow; executed: newRow = movedToRow; Execution Count:10 | 10 |
654 | 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 |
655 | newRow = oldRow - 1; executed: newRow = oldRow - 1; Execution Count:12 | 12 |
656 | 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 |
657 | newRow = oldRow + 1; executed: newRow = oldRow + 1; Execution Count:9 | 9 |
658 | if (newRow != oldRow) evaluated: newRow != oldRow yes Evaluation Count:31 | yes Evaluation Count:8 |
| 8-31 |
659 | *it = index(newRow, (*it).column(), (*it).parent()); executed: *it = index(newRow, (*it).column(), (*it).parent()); Execution Count:31 | 31 |
660 | } executed: } Execution Count:39 | 39 |
661 | } executed: } Execution Count:17 | 17 |
662 | | - |
663 | /* | - |
664 | \internal | - |
665 | | - |
666 | Returns an iterator to the item where \a item should be | - |
667 | inserted in the interval (\a begin, \a end) according to | - |
668 | the given sort \a order. | - |
669 | */ | - |
670 | QVector<QTableWidgetItem*>::iterator QTableModel::sortedInsertionIterator( | - |
671 | const QVector<QTableWidgetItem*>::iterator &begin, | - |
672 | const QVector<QTableWidgetItem*>::iterator &end, | - |
673 | Qt::SortOrder order, QTableWidgetItem *item) | - |
674 | { | - |
675 | if (order == Qt::AscendingOrder) evaluated: order == Qt::AscendingOrder yes Evaluation Count:15 | yes Evaluation Count:14 |
| 14-15 |
676 | return std::lower_bound(begin, end, item, QTableModelLessThan()); executed: return std::lower_bound(begin, end, item, QTableModelLessThan()); Execution Count:15 | 15 |
677 | return std::lower_bound(begin, end, item, QTableModelGreaterThan()); executed: return std::lower_bound(begin, end, item, QTableModelGreaterThan()); Execution Count:14 | 14 |
678 | } | - |
679 | | - |
680 | bool QTableModel::itemLessThan(const QPair<QTableWidgetItem*,int> &left, | - |
681 | const QPair<QTableWidgetItem*,int> &right) | - |
682 | { | - |
683 | return *(left.first) < *(right.first); executed: return *(left.first) < *(right.first); Execution Count:154 | 154 |
684 | } | - |
685 | | - |
686 | bool QTableModel::itemGreaterThan(const QPair<QTableWidgetItem*,int> &left, | - |
687 | const QPair<QTableWidgetItem*,int> &right) | - |
688 | { | - |
689 | return (*(right.first) < *(left .first)); executed: return (*(right.first) < *(left .first)); Execution Count:23 | 23 |
690 | } | - |
691 | | - |
692 | QVariant QTableModel::headerData(int section, Qt::Orientation orientation, int role) const | - |
693 | { | - |
694 | if (section < 0) partially evaluated: section < 0 no Evaluation Count:0 | yes Evaluation Count:19531 |
| 0-19531 |
695 | return QVariant(); never executed: return QVariant(); | 0 |
696 | | - |
697 | QTableWidgetItem *itm = 0; executed (the execution status of this line is deduced): QTableWidgetItem *itm = 0; | - |
698 | 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 |
699 | itm = horizontalHeaderItems.at(section); executed: itm = horizontalHeaderItems.at(section); Execution Count:13631 | 13631 |
700 | 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 |
701 | itm = verticalHeaderItems.at(section); executed: itm = verticalHeaderItems.at(section); Execution Count:5899 | 5899 |
702 | else | - |
703 | return QVariant(); // section is out of bounds executed: return QVariant(); Execution Count:1 | 1 |
704 | | - |
705 | if (itm) evaluated: itm yes Evaluation Count:121 | yes Evaluation Count:19409 |
| 121-19409 |
706 | return itm->data(role); executed: return itm->data(role); Execution Count:121 | 121 |
707 | if (role == Qt::DisplayRole) evaluated: role == Qt::DisplayRole yes Evaluation Count:4810 | yes Evaluation Count:14599 |
| 4810-14599 |
708 | return section + 1; executed: return section + 1; Execution Count:4810 | 4810 |
709 | return QVariant(); executed: return QVariant(); Execution Count:14599 | 14599 |
710 | } | - |
711 | | - |
712 | bool QTableModel::setHeaderData(int section, Qt::Orientation orientation, | - |
713 | const QVariant &value, int role) | - |
714 | { | - |
715 | if (section < 0 || evaluated: section < 0 yes Evaluation Count:6 | yes Evaluation Count:12 |
| 6-12 |
716 | (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 |
717 | (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 |
718 | return false; executed: return false; Execution Count:9 | 9 |
719 | | - |
720 | QTableWidgetItem *itm = 0; executed (the execution status of this line is deduced): QTableWidgetItem *itm = 0; | - |
721 | if (orientation == Qt::Horizontal) evaluated: orientation == Qt::Horizontal yes Evaluation Count:5 | yes Evaluation Count:4 |
| 4-5 |
722 | itm = horizontalHeaderItems.at(section); executed: itm = horizontalHeaderItems.at(section); Execution Count:5 | 5 |
723 | else | - |
724 | itm = verticalHeaderItems.at(section); executed: itm = verticalHeaderItems.at(section); Execution Count:4 | 4 |
725 | if (itm) { partially evaluated: itm no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
726 | itm->setData(role, value); never executed (the execution status of this line is deduced): itm->setData(role, value); | - |
727 | return true; never executed: return true; | 0 |
728 | } | - |
729 | return false; executed: return false; Execution Count:9 | 9 |
730 | } | - |
731 | | - |
732 | bool QTableModel::isValid(const QModelIndex &index) const | - |
733 | { | - |
734 | return (index.isValid() executed: return (index.isValid() && index.row() < verticalHeaderItems.count() && index.column() < horizontalHeaderItems.count()); Execution Count:10549 | 10549 |
735 | && index.row() < verticalHeaderItems.count() executed: return (index.isValid() && index.row() < verticalHeaderItems.count() && index.column() < horizontalHeaderItems.count()); Execution Count:10549 | 10549 |
736 | && index.column() < horizontalHeaderItems.count()); executed: return (index.isValid() && index.row() < verticalHeaderItems.count() && index.column() < horizontalHeaderItems.count()); Execution Count:10549 | 10549 |
737 | } | - |
738 | | - |
739 | void QTableModel::clear() | - |
740 | { | - |
741 | for (int j = 0; j < verticalHeaderItems.count(); ++j) { evaluated: j < verticalHeaderItems.count() yes Evaluation Count:2436 | yes Evaluation Count:231 |
| 231-2436 |
742 | if (verticalHeaderItems.at(j)) { evaluated: verticalHeaderItems.at(j) yes Evaluation Count:3 | yes Evaluation Count:2433 |
| 3-2433 |
743 | verticalHeaderItems.at(j)->view = 0; executed (the execution status of this line is deduced): verticalHeaderItems.at(j)->view = 0; | - |
744 | delete verticalHeaderItems.at(j); executed (the execution status of this line is deduced): delete verticalHeaderItems.at(j); | - |
745 | verticalHeaderItems[j] = 0; executed (the execution status of this line is deduced): verticalHeaderItems[j] = 0; | - |
746 | } executed: } Execution Count:3 | 3 |
747 | } executed: } Execution Count:2436 | 2436 |
748 | for (int k = 0; k < horizontalHeaderItems.count(); ++k) { evaluated: k < horizontalHeaderItems.count() yes Evaluation Count:3240 | yes Evaluation Count:231 |
| 231-3240 |
749 | if (horizontalHeaderItems.at(k)) { evaluated: horizontalHeaderItems.at(k) yes Evaluation Count:7 | yes Evaluation Count:3233 |
| 7-3233 |
750 | horizontalHeaderItems.at(k)->view = 0; executed (the execution status of this line is deduced): horizontalHeaderItems.at(k)->view = 0; | - |
751 | delete horizontalHeaderItems.at(k); executed (the execution status of this line is deduced): delete horizontalHeaderItems.at(k); | - |
752 | horizontalHeaderItems[k] = 0; executed (the execution status of this line is deduced): horizontalHeaderItems[k] = 0; | - |
753 | } executed: } Execution Count:7 | 7 |
754 | } executed: } Execution Count:3240 | 3240 |
755 | clearContents(); executed (the execution status of this line is deduced): clearContents(); | - |
756 | } executed: } Execution Count:231 | 231 |
757 | | - |
758 | void QTableModel::clearContents() | - |
759 | { | - |
760 | beginResetModel(); executed (the execution status of this line is deduced): beginResetModel(); | - |
761 | for (int i = 0; i < tableItems.count(); ++i) { evaluated: i < tableItems.count() yes Evaluation Count:141455 | yes Evaluation Count:232 |
| 232-141455 |
762 | if (tableItems.at(i)) { evaluated: tableItems.at(i) yes Evaluation Count:937 | yes Evaluation Count:140518 |
| 937-140518 |
763 | tableItems.at(i)->view = 0; executed (the execution status of this line is deduced): tableItems.at(i)->view = 0; | - |
764 | delete tableItems.at(i); executed (the execution status of this line is deduced): delete tableItems.at(i); | - |
765 | tableItems[i] = 0; executed (the execution status of this line is deduced): tableItems[i] = 0; | - |
766 | } executed: } Execution Count:937 | 937 |
767 | } executed: } Execution Count:141455 | 141455 |
768 | endResetModel(); executed (the execution status of this line is deduced): endResetModel(); | - |
769 | } executed: } Execution Count:232 | 232 |
770 | | - |
771 | void QTableModel::itemChanged(QTableWidgetItem *item) | - |
772 | { | - |
773 | if (!item) partially evaluated: !item no Evaluation Count:0 | yes Evaluation Count:29 |
| 0-29 |
774 | return; | 0 |
775 | if (item->flags() & ItemIsHeaderItem) { evaluated: item->flags() & ItemIsHeaderItem yes Evaluation Count:6 | yes Evaluation Count:23 |
| 6-23 |
776 | int row = verticalHeaderItems.indexOf(item); executed (the execution status of this line is deduced): int row = verticalHeaderItems.indexOf(item); | - |
777 | if (row >= 0) { evaluated: row >= 0 yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
778 | emit headerDataChanged(Qt::Vertical, row, row); executed (the execution status of this line is deduced): headerDataChanged(Qt::Vertical, row, row); | - |
779 | } else { executed: } Execution Count:3 | 3 |
780 | int column = horizontalHeaderItems.indexOf(item); executed (the execution status of this line is deduced): int column = horizontalHeaderItems.indexOf(item); | - |
781 | if (column >= 0) partially evaluated: column >= 0 yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
782 | emit headerDataChanged(Qt::Horizontal, column, column); executed: headerDataChanged(Qt::Horizontal, column, column); Execution Count:3 | 3 |
783 | } executed: } Execution Count:3 | 3 |
784 | } else { | - |
785 | QModelIndex idx = index(item); executed (the execution status of this line is deduced): QModelIndex idx = index(item); | - |
786 | if (idx.isValid()) partially evaluated: idx.isValid() yes Evaluation Count:23 | no Evaluation Count:0 |
| 0-23 |
787 | emit dataChanged(idx, idx); executed: dataChanged(idx, idx); Execution Count:23 | 23 |
788 | } executed: } Execution Count:23 | 23 |
789 | } | - |
790 | | - |
791 | QTableWidgetItem* QTableModel::createItem() const | - |
792 | { | - |
793 | return prototype ? prototype->clone() : new QTableWidgetItem; executed: return prototype ? prototype->clone() : new QTableWidgetItem; Execution Count:407 | 407 |
794 | } | - |
795 | | - |
796 | const QTableWidgetItem *QTableModel::itemPrototype() const | - |
797 | { | - |
798 | return prototype; executed: return prototype; Execution Count:2 | 2 |
799 | } | - |
800 | | - |
801 | void QTableModel::setItemPrototype(const QTableWidgetItem *item) | - |
802 | { | - |
803 | if (prototype != item) { partially evaluated: prototype != item yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
804 | delete prototype; executed (the execution status of this line is deduced): delete prototype; | - |
805 | prototype = item; executed (the execution status of this line is deduced): prototype = item; | - |
806 | } executed: } Execution Count:2 | 2 |
807 | } executed: } Execution Count:2 | 2 |
808 | | - |
809 | QStringList QTableModel::mimeTypes() const | - |
810 | { | - |
811 | const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent()); executed (the execution status of this line is deduced): const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent()); | - |
812 | return (view ? view->mimeTypes() : QStringList()); executed: return (view ? view->mimeTypes() : QStringList()); Execution Count:2 | 2 |
813 | } | - |
814 | | - |
815 | QMimeData *QTableModel::internalMimeData() const | - |
816 | { | - |
817 | return QAbstractTableModel::mimeData(cachedIndexes); never executed: return QAbstractTableModel::mimeData(cachedIndexes); | 0 |
818 | } | - |
819 | | - |
820 | QMimeData *QTableModel::mimeData(const QModelIndexList &indexes) const | - |
821 | { | - |
822 | QList<QTableWidgetItem*> items; never executed (the execution status of this line is deduced): QList<QTableWidgetItem*> items; | - |
823 | for (int i = 0; i < indexes.count(); ++i) never evaluated: i < indexes.count() | 0 |
824 | items << item(indexes.at(i)); never executed: items << item(indexes.at(i)); | 0 |
825 | const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent()); never executed (the execution status of this line is deduced): const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent()); | - |
826 | | - |
827 | // cachedIndexes is a little hack to avoid copying from QModelIndexList to | - |
828 | // QList<QTreeWidgetItem*> and back again in the view | - |
829 | cachedIndexes = indexes; never executed (the execution status of this line is deduced): cachedIndexes = indexes; | - |
830 | QMimeData *mimeData = (view ? view->mimeData(items) : 0); | 0 |
831 | cachedIndexes.clear(); never executed (the execution status of this line is deduced): cachedIndexes.clear(); | - |
832 | return mimeData; never executed: return mimeData; | 0 |
833 | } | - |
834 | | - |
835 | bool QTableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, | - |
836 | int row , int column, const QModelIndex &index) | - |
837 | { | - |
838 | if (index.isValid()) { never evaluated: index.isValid() | 0 |
839 | row = index.row(); never executed (the execution status of this line is deduced): row = index.row(); | - |
840 | column = index.column(); never executed (the execution status of this line is deduced): column = index.column(); | - |
841 | }else if (row == -1 || column == -1) { // The user dropped outside the table. never executed: } never evaluated: row == -1 never evaluated: column == -1 | 0 |
842 | row = rowCount(); never executed (the execution status of this line is deduced): row = rowCount(); | - |
843 | column = 0; never executed (the execution status of this line is deduced): column = 0; | - |
844 | } | 0 |
845 | | - |
846 | QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); never executed (the execution status of this line is deduced): QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); | - |
847 | return (view ? view->dropMimeData(row, column, data, action) : false); never executed: return (view ? view->dropMimeData(row, column, data, action) : false); | 0 |
848 | } | - |
849 | | - |
850 | Qt::DropActions QTableModel::supportedDropActions() const | - |
851 | { | - |
852 | const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent()); executed (the execution status of this line is deduced): const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent()); | - |
853 | return (view ? view->supportedDropActions() : Qt::DropActions(Qt::IgnoreAction)); executed: return (view ? view->supportedDropActions() : Qt::DropActions(Qt::IgnoreAction)); Execution Count:2 | 2 |
854 | } | - |
855 | | - |
856 | /*! | - |
857 | \class QTableWidgetSelectionRange | - |
858 | | - |
859 | \brief The QTableWidgetSelectionRange class provides a way to interact with | - |
860 | selection in a model without using model indexes and a selection model. | - |
861 | | - |
862 | \ingroup model-view | - |
863 | \inmodule QtWidgets | - |
864 | | - |
865 | The QTableWidgetSelectionRange class stores the top left and bottom | - |
866 | right rows and columns of a selection range in a table. The | - |
867 | selections in the table may consist of several selection ranges. | - |
868 | | - |
869 | \note If the item within the selection range is marked as not selectable, | - |
870 | e.g., \c{itemFlags() & Qt::ItemIsSelectable == 0} then it will not appear | - |
871 | in the selection range. | - |
872 | | - |
873 | \sa QTableWidget | - |
874 | */ | - |
875 | | - |
876 | /*! | - |
877 | Constructs an table selection range, i.e. a range | - |
878 | whose rowCount() and columnCount() are 0. | - |
879 | */ | - |
880 | QTableWidgetSelectionRange::QTableWidgetSelectionRange() | - |
881 | : top(-1), left(-1), bottom(-2), right(-2) | - |
882 | { | - |
883 | } executed: } Execution Count:1 | 1 |
884 | | - |
885 | /*! | - |
886 | Constructs the table selection range from the given \a top, \a | - |
887 | left, \a bottom and \a right table rows and columns. | - |
888 | | - |
889 | \sa topRow(), leftColumn(), bottomRow(), rightColumn() | - |
890 | */ | - |
891 | QTableWidgetSelectionRange::QTableWidgetSelectionRange(int top, int left, int bottom, int right) | - |
892 | : top(top), left(left), bottom(bottom), right(right) | - |
893 | { | - |
894 | } executed: } Execution Count:60 | 60 |
895 | | - |
896 | /*! | - |
897 | Constructs a the table selection range by copying the given \a | - |
898 | other table selection range. | - |
899 | */ | - |
900 | QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other) | - |
901 | : top(other.top), left(other.left), bottom(other.bottom), right(other.right) | - |
902 | { | - |
903 | } executed: } Execution Count:72 | 72 |
904 | | - |
905 | /*! | - |
906 | Destroys the table selection range. | - |
907 | */ | - |
908 | QTableWidgetSelectionRange::~QTableWidgetSelectionRange() | - |
909 | { | - |
910 | } | - |
911 | | - |
912 | /*! | - |
913 | \fn int QTableWidgetSelectionRange::topRow() const | - |
914 | | - |
915 | Returns the top row of the range. | - |
916 | | - |
917 | \sa bottomRow(), leftColumn(), rowCount() | - |
918 | */ | - |
919 | | - |
920 | /*! | - |
921 | \fn int QTableWidgetSelectionRange::bottomRow() const | - |
922 | | - |
923 | Returns the bottom row of the range. | - |
924 | | - |
925 | \sa topRow(), rightColumn(), rowCount() | - |
926 | */ | - |
927 | | - |
928 | /*! | - |
929 | \fn int QTableWidgetSelectionRange::leftColumn() const | - |
930 | | - |
931 | Returns the left column of the range. | - |
932 | | - |
933 | \sa rightColumn(), topRow(), columnCount() | - |
934 | */ | - |
935 | | - |
936 | /*! | - |
937 | \fn int QTableWidgetSelectionRange::rightColumn() const | - |
938 | | - |
939 | Returns the right column of the range. | - |
940 | | - |
941 | \sa leftColumn(), bottomRow(), columnCount() | - |
942 | */ | - |
943 | | - |
944 | /*! | - |
945 | \since 4.1 | - |
946 | \fn int QTableWidgetSelectionRange::rowCount() const | - |
947 | | - |
948 | Returns the number of rows in the range. | - |
949 | | - |
950 | This is equivalent to bottomRow() - topRow() + 1. | - |
951 | | - |
952 | \sa columnCount(), topRow(), bottomRow() | - |
953 | */ | - |
954 | | - |
955 | /*! | - |
956 | \since 4.1 | - |
957 | \fn int QTableWidgetSelectionRange::columnCount() const | - |
958 | | - |
959 | Returns the number of columns in the range. | - |
960 | | - |
961 | This is equivalent to rightColumn() - leftColumn() + 1. | - |
962 | | - |
963 | \sa rowCount(), leftColumn(), rightColumn() | - |
964 | */ | - |
965 | | - |
966 | /*! | - |
967 | \class QTableWidgetItem | - |
968 | \brief The QTableWidgetItem class provides an item for use with the | - |
969 | QTableWidget class. | - |
970 | | - |
971 | \ingroup model-view | - |
972 | \inmodule QtWidgets | - |
973 | | - |
974 | Table items are used to hold pieces of information for table widgets. | - |
975 | Items usually contain text, icons, or checkboxes | - |
976 | | - |
977 | The QTableWidgetItem class is a convenience class that replaces the | - |
978 | \c QTableItem class in Qt 3. It provides an item for use with | - |
979 | the QTableWidget class. | - |
980 | | - |
981 | Top-level items are constructed without a parent then inserted at the | - |
982 | position specified by a pair of row and column numbers: | - |
983 | | - |
984 | \snippet qtablewidget-using/mainwindow.cpp 3 | - |
985 | | - |
986 | Each item can have its own background brush which is set with | - |
987 | the setBackground() function. The current background brush can be | - |
988 | found with background(). | - |
989 | The text label for each item can be rendered with its own font and brush. | - |
990 | These are specified with the setFont() and setForeground() functions, | - |
991 | and read with font() and foreground(). | - |
992 | | - |
993 | By default, items are enabled, editable, selectable, checkable, and can be | - |
994 | used both as the source of a drag and drop operation and as a drop target. | - |
995 | Each item's flags can be changed by calling setFlags() with the appropriate | - |
996 | value (see \l{Qt::ItemFlags}). Checkable items can be checked and unchecked | - |
997 | with the setCheckState() function. The corresponding checkState() function | - |
998 | indicates whether the item is currently checked. | - |
999 | | - |
1000 | \section1 Subclassing | - |
1001 | | - |
1002 | When subclassing QTableWidgetItem to provide custom items, it is possible to | - |
1003 | define new types for them so that they can be distinguished from standard | - |
1004 | items. The constructors for subclasses that require this feature need to | - |
1005 | call the base class constructor with a new type value equal to or greater | - |
1006 | than \l UserType. | - |
1007 | | - |
1008 | \sa QTableWidget, {Model/View Programming}, QListWidgetItem, QTreeWidgetItem | - |
1009 | */ | - |
1010 | | - |
1011 | /*! | - |
1012 | \fn int QTableWidgetItem::row() const | - |
1013 | \since 4.2 | - |
1014 | | - |
1015 | Returns the row of the item in the table. | - |
1016 | If the item is not in a table, this function will return -1. | - |
1017 | | - |
1018 | \sa column() | - |
1019 | */ | - |
1020 | | - |
1021 | /*! | - |
1022 | \fn int QTableWidgetItem::column() const | - |
1023 | \since 4.2 | - |
1024 | | - |
1025 | Returns the column of the item in the table. | - |
1026 | If the item is not in a table, this function will return -1. | - |
1027 | | - |
1028 | \sa row() | - |
1029 | */ | - |
1030 | | - |
1031 | /*! | - |
1032 | \fn void QTableWidgetItem::setSelected(bool select) | - |
1033 | \since 4.2 | - |
1034 | | - |
1035 | Sets the selected state of the item to \a select. | - |
1036 | | - |
1037 | \sa isSelected() | - |
1038 | */ | - |
1039 | | - |
1040 | /*! | - |
1041 | \fn bool QTableWidgetItem::isSelected() const | - |
1042 | \since 4.2 | - |
1043 | | - |
1044 | Returns true if the item is selected, otherwise returns false. | - |
1045 | | - |
1046 | \sa setSelected() | - |
1047 | */ | - |
1048 | | - |
1049 | /*! | - |
1050 | \fn QSize QTableWidgetItem::sizeHint() const | - |
1051 | \since 4.1 | - |
1052 | | - |
1053 | Returns the size hint set for the table item. | - |
1054 | */ | - |
1055 | | - |
1056 | /*! | - |
1057 | \fn void QTableWidgetItem::setSizeHint(const QSize &size) | - |
1058 | \since 4.1 | - |
1059 | | - |
1060 | Sets the size hint for the table item to be \a size. | - |
1061 | If no size hint is set, the item delegate will compute the | - |
1062 | size hint based on the item data. | - |
1063 | */ | - |
1064 | | - |
1065 | /*! | - |
1066 | \fn Qt::CheckState QTableWidgetItem::checkState() const | - |
1067 | | - |
1068 | Returns the checked state of the table item. | - |
1069 | | - |
1070 | \sa flags() | - |
1071 | */ | - |
1072 | | - |
1073 | /*! | - |
1074 | \fn void QTableWidgetItem::setCheckState(Qt::CheckState state) | - |
1075 | | - |
1076 | Sets the check state of the table item to be \a state. | - |
1077 | */ | - |
1078 | | - |
1079 | /*! | - |
1080 | \fn QTableWidget *QTableWidgetItem::tableWidget() const | - |
1081 | | - |
1082 | Returns the table widget that contains the item. | - |
1083 | */ | - |
1084 | | - |
1085 | /*! | - |
1086 | \fn Qt::ItemFlags QTableWidgetItem::flags() const | - |
1087 | | - |
1088 | Returns the flags used to describe the item. These determine whether | - |
1089 | the item can be checked, edited, and selected. | - |
1090 | | - |
1091 | \sa setFlags() | - |
1092 | */ | - |
1093 | | - |
1094 | /*! | - |
1095 | \fn void QTableWidgetItem::setFlags(Qt::ItemFlags flags) | - |
1096 | | - |
1097 | Sets the flags for the item to the given \a flags. These determine whether | - |
1098 | the item can be selected or modified. | - |
1099 | | - |
1100 | \sa flags() | - |
1101 | */ | - |
1102 | void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) | - |
1103 | { | - |
1104 | itemFlags = aflags; executed (the execution status of this line is deduced): itemFlags = aflags; | - |
1105 | if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0)) evaluated: view yes Evaluation Count:2 | yes Evaluation Count:15 |
| 2-15 |
1106 | model->itemChanged(this); executed: model->itemChanged(this); Execution Count:2 | 2 |
1107 | } executed: } Execution Count:17 | 17 |
1108 | | - |
1109 | | - |
1110 | /*! | - |
1111 | \fn QString QTableWidgetItem::text() const | - |
1112 | | - |
1113 | Returns the item's text. | - |
1114 | | - |
1115 | \sa setText() | - |
1116 | */ | - |
1117 | | - |
1118 | /*! | - |
1119 | \fn void QTableWidgetItem::setText(const QString &text) | - |
1120 | | - |
1121 | Sets the item's text to the \a text specified. | - |
1122 | | - |
1123 | \sa text(), setFont(), setForeground() | - |
1124 | */ | - |
1125 | | - |
1126 | /*! | - |
1127 | \fn QIcon QTableWidgetItem::icon() const | - |
1128 | | - |
1129 | Returns the item's icon. | - |
1130 | | - |
1131 | \sa setIcon(), {QAbstractItemView::iconSize}{iconSize} | - |
1132 | */ | - |
1133 | | - |
1134 | /*! | - |
1135 | \fn void QTableWidgetItem::setIcon(const QIcon &icon) | - |
1136 | | - |
1137 | Sets the item's icon to the \a icon specified. | - |
1138 | | - |
1139 | \sa icon(), setText(), {QAbstractItemView::iconSize}{iconSize} | - |
1140 | */ | - |
1141 | | - |
1142 | /*! | - |
1143 | \fn QString QTableWidgetItem::statusTip() const | - |
1144 | | - |
1145 | Returns the item's status tip. | - |
1146 | | - |
1147 | \sa setStatusTip() | - |
1148 | */ | - |
1149 | | - |
1150 | /*! | - |
1151 | \fn void QTableWidgetItem::setStatusTip(const QString &statusTip) | - |
1152 | | - |
1153 | Sets the status tip for the table item to the text specified by | - |
1154 | \a statusTip. QTableWidget mouse tracking needs to be enabled for this | - |
1155 | feature to work. | - |
1156 | | - |
1157 | \sa statusTip(), setToolTip(), setWhatsThis() | - |
1158 | */ | - |
1159 | | - |
1160 | /*! | - |
1161 | \fn QString QTableWidgetItem::toolTip() const | - |
1162 | | - |
1163 | Returns the item's tooltip. | - |
1164 | | - |
1165 | \sa setToolTip() | - |
1166 | */ | - |
1167 | | - |
1168 | /*! | - |
1169 | \fn void QTableWidgetItem::setToolTip(const QString &toolTip) | - |
1170 | | - |
1171 | Sets the item's tooltip to the string specified by \a toolTip. | - |
1172 | | - |
1173 | \sa toolTip(), setStatusTip(), setWhatsThis() | - |
1174 | */ | - |
1175 | | - |
1176 | /*! | - |
1177 | \fn QString QTableWidgetItem::whatsThis() const | - |
1178 | | - |
1179 | Returns the item's "What's This?" help. | - |
1180 | | - |
1181 | \sa setWhatsThis() | - |
1182 | */ | - |
1183 | | - |
1184 | /*! | - |
1185 | \fn void QTableWidgetItem::setWhatsThis(const QString &whatsThis) | - |
1186 | | - |
1187 | Sets the item's "What's This?" help to the string specified by \a whatsThis. | - |
1188 | | - |
1189 | \sa whatsThis(), setStatusTip(), setToolTip() | - |
1190 | */ | - |
1191 | | - |
1192 | /*! | - |
1193 | \fn QFont QTableWidgetItem::font() const | - |
1194 | | - |
1195 | Returns the font used to render the item's text. | - |
1196 | | - |
1197 | \sa setFont() | - |
1198 | */ | - |
1199 | | - |
1200 | /*! | - |
1201 | \fn void QTableWidgetItem::setFont(const QFont &font) | - |
1202 | | - |
1203 | Sets the font used to display the item's text to the given \a font. | - |
1204 | | - |
1205 | \sa font(), setText(), setForeground() | - |
1206 | */ | - |
1207 | | - |
1208 | /*! | - |
1209 | \fn QColor QTableWidgetItem::backgroundColor() const | - |
1210 | \obsolete | - |
1211 | | - |
1212 | This function is deprecated. Use background() instead. | - |
1213 | */ | - |
1214 | | - |
1215 | /*! | - |
1216 | \fn void QTableWidgetItem::setBackgroundColor(const QColor &color) | - |
1217 | \obsolete | - |
1218 | | - |
1219 | This function is deprecated. Use setBackground() instead. | - |
1220 | */ | - |
1221 | | - |
1222 | /*! | - |
1223 | \fn QBrush QTableWidgetItem::background() const | - |
1224 | \since 4.2 | - |
1225 | | - |
1226 | Returns the brush used to render the item's background. | - |
1227 | | - |
1228 | \sa foreground() | - |
1229 | */ | - |
1230 | | - |
1231 | /*! | - |
1232 | \fn void QTableWidgetItem::setBackground(const QBrush &brush) | - |
1233 | \since 4.2 | - |
1234 | | - |
1235 | Sets the item's background brush to the specified \a brush. | - |
1236 | | - |
1237 | \sa setForeground() | - |
1238 | */ | - |
1239 | | - |
1240 | /*! | - |
1241 | \fn QColor QTableWidgetItem::textColor() const | - |
1242 | \obsolete | - |
1243 | | - |
1244 | This function is deprecated. Use foreground() instead. | - |
1245 | */ | - |
1246 | | - |
1247 | /*! | - |
1248 | \fn void QTableWidgetItem::setTextColor(const QColor &color) | - |
1249 | \obsolete | - |
1250 | | - |
1251 | This function is deprecated. Use setForeground() instead. | - |
1252 | */ | - |
1253 | | - |
1254 | /*! | - |
1255 | \fn QBrush QTableWidgetItem::foreground() const | - |
1256 | \since 4.2 | - |
1257 | | - |
1258 | Returns the brush used to render the item's foreground (e.g. text). | - |
1259 | | - |
1260 | \sa background() | - |
1261 | */ | - |
1262 | | - |
1263 | /*! | - |
1264 | \fn void QTableWidgetItem::setForeground(const QBrush &brush) | - |
1265 | \since 4.2 | - |
1266 | | - |
1267 | Sets the item's foreground brush to the specified \a brush. | - |
1268 | | - |
1269 | \sa setBackground() | - |
1270 | */ | - |
1271 | | - |
1272 | /*! | - |
1273 | \fn int QTableWidgetItem::textAlignment() const | - |
1274 | | - |
1275 | Returns the text alignment for the item's text. | - |
1276 | | - |
1277 | \sa Qt::Alignment | - |
1278 | */ | - |
1279 | | - |
1280 | /*! | - |
1281 | \fn void QTableWidgetItem::setTextAlignment(int alignment) | - |
1282 | | - |
1283 | Sets the text alignment for the item's text to the \a alignment | - |
1284 | specified. | - |
1285 | | - |
1286 | \sa Qt::Alignment | - |
1287 | */ | - |
1288 | | - |
1289 | /*! | - |
1290 | Constructs a table item of the specified \a type that does not belong | - |
1291 | to any table. | - |
1292 | | - |
1293 | \sa type() | - |
1294 | */ | - |
1295 | QTableWidgetItem::QTableWidgetItem(int type) | - |
1296 | : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)), | - |
1297 | itemFlags(Qt::ItemIsEditable | - |
1298 | |Qt::ItemIsSelectable | - |
1299 | |Qt::ItemIsUserCheckable | - |
1300 | |Qt::ItemIsEnabled | - |
1301 | |Qt::ItemIsDragEnabled | - |
1302 | |Qt::ItemIsDropEnabled) | - |
1303 | { | - |
1304 | } executed: } Execution Count:451 | 451 |
1305 | | - |
1306 | /*! | - |
1307 | Constructs a table item with the given \a text. | - |
1308 | | - |
1309 | \sa type() | - |
1310 | */ | - |
1311 | QTableWidgetItem::QTableWidgetItem(const QString &text, int type) | - |
1312 | : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)), | - |
1313 | itemFlags(Qt::ItemIsEditable | - |
1314 | |Qt::ItemIsSelectable | - |
1315 | |Qt::ItemIsUserCheckable | - |
1316 | |Qt::ItemIsEnabled | - |
1317 | |Qt::ItemIsDragEnabled | - |
1318 | |Qt::ItemIsDropEnabled) | - |
1319 | { | - |
1320 | setData(Qt::DisplayRole, text); executed (the execution status of this line is deduced): setData(Qt::DisplayRole, text); | - |
1321 | } executed: } Execution Count:555 | 555 |
1322 | | - |
1323 | /*! | - |
1324 | Constructs a table item with the given \a icon and \a text. | - |
1325 | | - |
1326 | \sa type() | - |
1327 | */ | - |
1328 | QTableWidgetItem::QTableWidgetItem(const QIcon &icon, const QString &text, int type) | - |
1329 | : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)), | - |
1330 | itemFlags(Qt::ItemIsEditable | - |
1331 | |Qt::ItemIsSelectable | - |
1332 | |Qt::ItemIsUserCheckable | - |
1333 | |Qt::ItemIsEnabled | - |
1334 | |Qt::ItemIsDragEnabled | - |
1335 | |Qt::ItemIsDropEnabled) | - |
1336 | { | - |
1337 | setData(Qt::DecorationRole, icon); never executed (the execution status of this line is deduced): setData(Qt::DecorationRole, icon); | - |
1338 | setData(Qt::DisplayRole, text); never executed (the execution status of this line is deduced): setData(Qt::DisplayRole, text); | - |
1339 | } | 0 |
1340 | | - |
1341 | /*! | - |
1342 | Destroys the table item. | - |
1343 | */ | - |
1344 | QTableWidgetItem::~QTableWidgetItem() | - |
1345 | { | - |
1346 | if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0)) evaluated: view yes Evaluation Count:5 | yes Evaluation Count:1001 |
| 5-1001 |
1347 | model->removeItem(this); executed: model->removeItem(this); Execution Count:5 | 5 |
1348 | view = 0; executed (the execution status of this line is deduced): view = 0; | - |
1349 | delete d; executed (the execution status of this line is deduced): delete d; | - |
1350 | } executed: } Execution Count:1006 | 1006 |
1351 | | - |
1352 | /*! | - |
1353 | Creates a copy of the item. | - |
1354 | */ | - |
1355 | QTableWidgetItem *QTableWidgetItem::clone() const | - |
1356 | { | - |
1357 | return new QTableWidgetItem(*this); never executed: return new QTableWidgetItem(*this); | 0 |
1358 | } | - |
1359 | | - |
1360 | /*! | - |
1361 | Sets the item's data for the given \a role to the specified \a value. | - |
1362 | | - |
1363 | \sa Qt::ItemDataRole, data() | - |
1364 | */ | - |
1365 | void QTableWidgetItem::setData(int role, const QVariant &value) | - |
1366 | { | - |
1367 | bool found = false; executed (the execution status of this line is deduced): bool found = false; | - |
1368 | role = (role == Qt::EditRole ? Qt::DisplayRole : role); evaluated: role == Qt::EditRole yes Evaluation Count:404 | yes Evaluation Count:605 |
| 404-605 |
1369 | for (int i = 0; i < values.count(); ++i) { evaluated: i < values.count() yes Evaluation Count:34 | yes Evaluation Count:996 |
| 34-996 |
1370 | if (values.at(i).role == role) { evaluated: values.at(i).role == role yes Evaluation Count:13 | yes Evaluation Count:21 |
| 13-21 |
1371 | if (values[i].value == value) partially evaluated: values[i].value == value no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
1372 | return; | 0 |
1373 | | - |
1374 | values[i].value = value; executed (the execution status of this line is deduced): values[i].value = value; | - |
1375 | found = true; executed (the execution status of this line is deduced): found = true; | - |
1376 | break; executed: break; Execution Count:13 | 13 |
1377 | } | - |
1378 | } executed: } Execution Count:21 | 21 |
1379 | if (!found) evaluated: !found yes Evaluation Count:996 | yes Evaluation Count:13 |
| 13-996 |
1380 | values.append(QWidgetItemData(role, value)); executed: values.append(QWidgetItemData(role, value)); Execution Count:996 | 996 |
1381 | if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0)) evaluated: view yes Evaluation Count:25 | yes Evaluation Count:984 |
| 25-984 |
1382 | model->itemChanged(this); executed: model->itemChanged(this); Execution Count:25 | 25 |
1383 | } executed: } Execution Count:1009 | 1009 |
1384 | | - |
1385 | /*! | - |
1386 | Returns the item's data for the given \a role. | - |
1387 | */ | - |
1388 | QVariant QTableWidgetItem::data(int role) const | - |
1389 | { | - |
1390 | role = (role == Qt::EditRole ? Qt::DisplayRole : role); evaluated: role == Qt::EditRole yes Evaluation Count:18 | yes Evaluation Count:2159 |
| 18-2159 |
1391 | for (int i = 0; i < values.count(); ++i) evaluated: i < values.count() yes Evaluation Count:2153 | yes Evaluation Count:701 |
| 701-2153 |
1392 | if (values.at(i).role == role) evaluated: values.at(i).role == role yes Evaluation Count:1476 | yes Evaluation Count:677 |
| 677-1476 |
1393 | return values.at(i).value; executed: return values.at(i).value; Execution Count:1476 | 1476 |
1394 | return QVariant(); executed: return QVariant(); Execution Count:701 | 701 |
1395 | } | - |
1396 | | - |
1397 | /*! | - |
1398 | Returns true if the item is less than the \a other item; otherwise returns | - |
1399 | false. | - |
1400 | */ | - |
1401 | bool QTableWidgetItem::operator<(const QTableWidgetItem &other) const | - |
1402 | { | - |
1403 | const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); executed (the execution status of this line is deduced): const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); | - |
1404 | return QAbstractItemModelPrivate::variantLessThan(v1, v2); executed: return QAbstractItemModelPrivate::variantLessThan(v1, v2); Execution Count:224 | 224 |
1405 | } | - |
1406 | | - |
1407 | #ifndef QT_NO_DATASTREAM | - |
1408 | | - |
1409 | /*! | - |
1410 | Reads the item from stream \a in. | - |
1411 | | - |
1412 | \sa write() | - |
1413 | */ | - |
1414 | void QTableWidgetItem::read(QDataStream &in) | - |
1415 | { | - |
1416 | in >> values; executed (the execution status of this line is deduced): in >> values; | - |
1417 | } executed: } Execution Count:1 | 1 |
1418 | | - |
1419 | /*! | - |
1420 | Writes the item to stream \a out. | - |
1421 | | - |
1422 | \sa read() | - |
1423 | */ | - |
1424 | void QTableWidgetItem::write(QDataStream &out) const | - |
1425 | { | - |
1426 | out << values; executed (the execution status of this line is deduced): out << values; | - |
1427 | } executed: } Execution Count:1 | 1 |
1428 | | - |
1429 | /*! | - |
1430 | \relates QTableWidgetItem | - |
1431 | | - |
1432 | Reads a table widget item from stream \a in into \a item. | - |
1433 | | - |
1434 | This operator uses QTableWidgetItem::read(). | - |
1435 | | - |
1436 | \sa {Serializing Qt Data Types} | - |
1437 | */ | - |
1438 | QDataStream &operator>>(QDataStream &in, QTableWidgetItem &item) | - |
1439 | { | - |
1440 | item.read(in); executed (the execution status of this line is deduced): item.read(in); | - |
1441 | return in; executed: return in; Execution Count:1 | 1 |
1442 | } | - |
1443 | | - |
1444 | /*! | - |
1445 | \relates QTableWidgetItem | - |
1446 | | - |
1447 | Writes the table widget item \a item to stream \a out. | - |
1448 | | - |
1449 | This operator uses QTableWidgetItem::write(). | - |
1450 | | - |
1451 | \sa {Serializing Qt Data Types} | - |
1452 | */ | - |
1453 | QDataStream &operator<<(QDataStream &out, const QTableWidgetItem &item) | - |
1454 | { | - |
1455 | item.write(out); executed (the execution status of this line is deduced): item.write(out); | - |
1456 | return out; executed: return out; Execution Count:1 | 1 |
1457 | } | - |
1458 | | - |
1459 | #endif // QT_NO_DATASTREAM | - |
1460 | | - |
1461 | /*! | - |
1462 | \since 4.1 | - |
1463 | | - |
1464 | Constructs a copy of \a other. Note that type() and tableWidget() | - |
1465 | are not copied. | - |
1466 | | - |
1467 | This function is useful when reimplementing clone(). | - |
1468 | | - |
1469 | \sa data(), flags() | - |
1470 | */ | - |
1471 | QTableWidgetItem::QTableWidgetItem(const QTableWidgetItem &other) | - |
1472 | : rtti(Type), values(other.values), view(0), | - |
1473 | d(new QTableWidgetItemPrivate(this)), | - |
1474 | itemFlags(other.itemFlags) | - |
1475 | { | - |
1476 | } | 0 |
1477 | | - |
1478 | /*! | - |
1479 | Assigns \a other's data and flags to this item. Note that type() | - |
1480 | and tableWidget() are not copied. | - |
1481 | | - |
1482 | This function is useful when reimplementing clone(). | - |
1483 | | - |
1484 | \sa data(), flags() | - |
1485 | */ | - |
1486 | QTableWidgetItem &QTableWidgetItem::operator=(const QTableWidgetItem &other) | - |
1487 | { | - |
1488 | values = other.values; executed (the execution status of this line is deduced): values = other.values; | - |
1489 | itemFlags = other.itemFlags; executed (the execution status of this line is deduced): itemFlags = other.itemFlags; | - |
1490 | return *this; executed: return *this; Execution Count:1 | 1 |
1491 | } | - |
1492 | | - |
1493 | /*! | - |
1494 | \class QTableWidget | - |
1495 | \brief The QTableWidget class provides an item-based table view with a default model. | - |
1496 | | - |
1497 | \ingroup model-view | - |
1498 | \inmodule QtWidgets | - |
1499 | | - |
1500 | Table widgets provide standard table display facilities for applications. | - |
1501 | The items in a QTableWidget are provided by QTableWidgetItem. | - |
1502 | | - |
1503 | If you want a table that uses your own data model you should | - |
1504 | use QTableView rather than this class. | - |
1505 | | - |
1506 | Table widgets can be constructed with the required numbers of rows and | - |
1507 | columns: | - |
1508 | | - |
1509 | \snippet qtablewidget-using/mainwindow.cpp 0 | - |
1510 | | - |
1511 | Alternatively, tables can be constructed without a given size and resized | - |
1512 | later: | - |
1513 | | - |
1514 | \snippet qtablewidget-resizing/mainwindow.cpp 0 | - |
1515 | \snippet qtablewidget-resizing/mainwindow.cpp 1 | - |
1516 | | - |
1517 | Items are created ouside the table (with no parent widget) and inserted | - |
1518 | into the table with setItem(): | - |
1519 | | - |
1520 | \snippet qtablewidget-resizing/mainwindow.cpp 2 | - |
1521 | | - |
1522 | If you want to enable sorting in your table widget, do so after you | - |
1523 | have populated it with items, otherwise sorting may interfere with | - |
1524 | the insertion order (see setItem() for details). | - |
1525 | | - |
1526 | Tables can be given both horizontal and vertical headers. The simplest way | - |
1527 | to create the headers is to supply a list of strings to the | - |
1528 | setHorizontalHeaderLabels() and setVerticalHeaderLabels() functions. These | - |
1529 | will provide simple textual headers for the table's columns and rows. | - |
1530 | More sophisticated headers can be created from existing table items | - |
1531 | that are usually constructed outside the table. For example, we can | - |
1532 | construct a table item with an icon and aligned text, and use it as the | - |
1533 | header for a particular column: | - |
1534 | | - |
1535 | \snippet qtablewidget-using/mainwindow.cpp 2 | - |
1536 | | - |
1537 | The number of rows in the table can be found with rowCount(), and the | - |
1538 | number of columns with columnCount(). The table can be cleared with the | - |
1539 | clear() function. | - |
1540 | | - |
1541 | \table 100% | - |
1542 | \row \li \inlineimage windowsvista-tableview.png Screenshot of a Windows Vista style table widget | - |
1543 | \li \inlineimage macintosh-tableview.png Screenshot of a Macintosh style table widget | - |
1544 | \li \inlineimage fusion-tableview.png Screenshot of a Fusion style table widget | - |
1545 | \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} table widget. | - |
1546 | \li A \l{Macintosh Style Widget Gallery}{Macintosh style} table widget. | - |
1547 | \li A \l{Fusion Style Widget Gallery}{Fusion style} table widget. | - |
1548 | \endtable | - |
1549 | | - |
1550 | \sa QTableWidgetItem, QTableView, {Model/View Programming} | - |
1551 | */ | - |
1552 | | - |
1553 | /*! | - |
1554 | \property QTableWidget::rowCount | - |
1555 | \brief the number of rows in the table | - |
1556 | | - |
1557 | By default, for a table constructed without row and column counts, | - |
1558 | this property contains a value of 0. | - |
1559 | */ | - |
1560 | | - |
1561 | /*! | - |
1562 | \property QTableWidget::columnCount | - |
1563 | \brief the number of columns in the table | - |
1564 | | - |
1565 | By default, for a table constructed without row and column counts, | - |
1566 | this property contains a value of 0. | - |
1567 | */ | - |
1568 | | - |
1569 | void QTableWidgetPrivate::setup() | - |
1570 | { | - |
1571 | Q_Q(QTableWidget); executed (the execution status of this line is deduced): QTableWidget * const q = q_func(); | - |
1572 | // view signals | - |
1573 | QObject::connect(q, SIGNAL(pressed(QModelIndex)), q, SLOT(_q_emitItemPressed(QModelIndex))); executed (the execution status of this line is deduced): QObject::connect(q, "2""pressed(QModelIndex)", q, "1""_q_emitItemPressed(QModelIndex)"); | - |
1574 | QObject::connect(q, SIGNAL(clicked(QModelIndex)), q, SLOT(_q_emitItemClicked(QModelIndex))); executed (the execution status of this line is deduced): QObject::connect(q, "2""clicked(QModelIndex)", q, "1""_q_emitItemClicked(QModelIndex)"); | - |
1575 | QObject::connect(q, SIGNAL(doubleClicked(QModelIndex)), executed (the execution status of this line is deduced): QObject::connect(q, "2""doubleClicked(QModelIndex)", | - |
1576 | q, SLOT(_q_emitItemDoubleClicked(QModelIndex))); executed (the execution status of this line is deduced): q, "1""_q_emitItemDoubleClicked(QModelIndex)"); | - |
1577 | QObject::connect(q, SIGNAL(activated(QModelIndex)), q, SLOT(_q_emitItemActivated(QModelIndex))); executed (the execution status of this line is deduced): QObject::connect(q, "2""activated(QModelIndex)", q, "1""_q_emitItemActivated(QModelIndex)"); | - |
1578 | QObject::connect(q, SIGNAL(entered(QModelIndex)), q, SLOT(_q_emitItemEntered(QModelIndex))); executed (the execution status of this line is deduced): QObject::connect(q, "2""entered(QModelIndex)", q, "1""_q_emitItemEntered(QModelIndex)"); | - |
1579 | // model signals | - |
1580 | QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), executed (the execution status of this line is deduced): QObject::connect(model, "2""dataChanged(QModelIndex,QModelIndex)", | - |
1581 | q, SLOT(_q_emitItemChanged(QModelIndex))); executed (the execution status of this line is deduced): q, "1""_q_emitItemChanged(QModelIndex)"); | - |
1582 | // selection signals | - |
1583 | QObject::connect(q->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), executed (the execution status of this line is deduced): QObject::connect(q->selectionModel(), "2""currentChanged(QModelIndex,QModelIndex)", | - |
1584 | q, SLOT(_q_emitCurrentItemChanged(QModelIndex,QModelIndex))); executed (the execution status of this line is deduced): q, "1""_q_emitCurrentItemChanged(QModelIndex,QModelIndex)"); | - |
1585 | QObject::connect(q->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), executed (the execution status of this line is deduced): QObject::connect(q->selectionModel(), "2""selectionChanged(QItemSelection,QItemSelection)", | - |
1586 | q, SIGNAL(itemSelectionChanged())); executed (the execution status of this line is deduced): q, "2""itemSelectionChanged()"); | - |
1587 | // sorting | - |
1588 | QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), executed (the execution status of this line is deduced): QObject::connect(model, "2""dataChanged(QModelIndex,QModelIndex)", | - |
1589 | q, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); executed (the execution status of this line is deduced): q, "1""_q_dataChanged(QModelIndex,QModelIndex)"); | - |
1590 | QObject::connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), q, SLOT(_q_sort())); executed (the execution status of this line is deduced): QObject::connect(model, "2""columnsRemoved(QModelIndex,int,int)", q, "1""_q_sort()"); | - |
1591 | } executed: } Execution Count:146 | 146 |
1592 | | - |
1593 | void QTableWidgetPrivate::_q_emitItemPressed(const QModelIndex &index) | - |
1594 | { | - |
1595 | Q_Q(QTableWidget); executed (the execution status of this line is deduced): QTableWidget * const q = q_func(); | - |
1596 | if (QTableWidgetItem *item = tableModel()->item(index)) evaluated: QTableWidgetItem *item = tableModel()->item(index) yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
1597 | emit q->itemPressed(item); executed: q->itemPressed(item); Execution Count:1 | 1 |
1598 | emit q->cellPressed(index.row(), index.column()); executed (the execution status of this line is deduced): q->cellPressed(index.row(), index.column()); | - |
1599 | } executed: } Execution Count:3 | 3 |
1600 | | - |
1601 | void QTableWidgetPrivate::_q_emitItemClicked(const QModelIndex &index) | - |
1602 | { | - |
1603 | Q_Q(QTableWidget); executed (the execution status of this line is deduced): QTableWidget * const q = q_func(); | - |
1604 | if (QTableWidgetItem *item = tableModel()->item(index)) evaluated: QTableWidgetItem *item = tableModel()->item(index) yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1605 | emit q->itemClicked(item); executed: q->itemClicked(item); Execution Count:1 | 1 |
1606 | emit q->cellClicked(index.row(), index.column()); executed (the execution status of this line is deduced): q->cellClicked(index.row(), index.column()); | - |
1607 | } executed: } Execution Count:2 | 2 |
1608 | | - |
1609 | void QTableWidgetPrivate::_q_emitItemDoubleClicked(const QModelIndex &index) | - |
1610 | { | - |
1611 | Q_Q(QTableWidget); never executed (the execution status of this line is deduced): QTableWidget * const q = q_func(); | - |
1612 | if (QTableWidgetItem *item = tableModel()->item(index)) never evaluated: QTableWidgetItem *item = tableModel()->item(index) | 0 |
1613 | emit q->itemDoubleClicked(item); never executed: q->itemDoubleClicked(item); | 0 |
1614 | emit q->cellDoubleClicked(index.row(), index.column()); never executed (the execution status of this line is deduced): q->cellDoubleClicked(index.row(), index.column()); | - |
1615 | } | 0 |
1616 | | - |
1617 | void QTableWidgetPrivate::_q_emitItemActivated(const QModelIndex &index) | - |
1618 | { | - |
1619 | Q_Q(QTableWidget); never executed (the execution status of this line is deduced): QTableWidget * const q = q_func(); | - |
1620 | if (QTableWidgetItem *item = tableModel()->item(index)) never evaluated: QTableWidgetItem *item = tableModel()->item(index) | 0 |
1621 | emit q->itemActivated(item); never executed: q->itemActivated(item); | 0 |
1622 | emit q->cellActivated(index.row(), index.column()); never executed (the execution status of this line is deduced): q->cellActivated(index.row(), index.column()); | - |
1623 | } | 0 |
1624 | | - |
1625 | void QTableWidgetPrivate::_q_emitItemEntered(const QModelIndex &index) | - |
1626 | { | - |
1627 | Q_Q(QTableWidget); executed (the execution status of this line is deduced): QTableWidget * const q = q_func(); | - |
1628 | if (QTableWidgetItem *item = tableModel()->item(index)) partially evaluated: QTableWidgetItem *item = tableModel()->item(index) no Evaluation Count:0 | yes Evaluation Count:46 |
| 0-46 |
1629 | emit q->itemEntered(item); never executed: q->itemEntered(item); | 0 |
1630 | emit q->cellEntered(index.row(), index.column()); executed (the execution status of this line is deduced): q->cellEntered(index.row(), index.column()); | - |
1631 | } executed: } Execution Count:46 | 46 |
1632 | | - |
1633 | void QTableWidgetPrivate::_q_emitItemChanged(const QModelIndex &index) | - |
1634 | { | - |
1635 | Q_Q(QTableWidget); executed (the execution status of this line is deduced): QTableWidget * const q = q_func(); | - |
1636 | if (QTableWidgetItem *item = tableModel()->item(index)) evaluated: QTableWidgetItem *item = tableModel()->item(index) yes Evaluation Count:995 | yes Evaluation Count:7 |
| 7-995 |
1637 | emit q->itemChanged(item); executed: q->itemChanged(item); Execution Count:995 | 995 |
1638 | emit q->cellChanged(index.row(), index.column()); executed (the execution status of this line is deduced): q->cellChanged(index.row(), index.column()); | - |
1639 | } executed: } Execution Count:1002 | 1002 |
1640 | | - |
1641 | void QTableWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, | - |
1642 | const QModelIndex &previous) | - |
1643 | { | - |
1644 | Q_Q(QTableWidget); executed (the execution status of this line is deduced): QTableWidget * const q = q_func(); | - |
1645 | QTableWidgetItem *currentItem = tableModel()->item(current); executed (the execution status of this line is deduced): QTableWidgetItem *currentItem = tableModel()->item(current); | - |
1646 | QTableWidgetItem *previousItem = tableModel()->item(previous); executed (the execution status of this line is deduced): QTableWidgetItem *previousItem = tableModel()->item(previous); | - |
1647 | 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 |
1648 | emit q->currentItemChanged(currentItem, previousItem); executed: q->currentItemChanged(currentItem, previousItem); Execution Count:8 | 8 |
1649 | emit q->currentCellChanged(current.row(), current.column(), previous.row(), previous.column()); executed (the execution status of this line is deduced): q->currentCellChanged(current.row(), current.column(), previous.row(), previous.column()); | - |
1650 | } executed: } Execution Count:64 | 64 |
1651 | | - |
1652 | void QTableWidgetPrivate::_q_sort() | - |
1653 | { | - |
1654 | if (sortingEnabled) { partially evaluated: sortingEnabled no Evaluation Count:0 | yes Evaluation Count:69 |
| 0-69 |
1655 | int column = horizontalHeader->sortIndicatorSection(); never executed (the execution status of this line is deduced): int column = horizontalHeader->sortIndicatorSection(); | - |
1656 | Qt::SortOrder order = horizontalHeader->sortIndicatorOrder(); never executed (the execution status of this line is deduced): Qt::SortOrder order = horizontalHeader->sortIndicatorOrder(); | - |
1657 | model->sort(column, order); never executed (the execution status of this line is deduced): model->sort(column, order); | - |
1658 | } | 0 |
1659 | } executed: } Execution Count:69 | 69 |
1660 | | - |
1661 | void QTableWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, | - |
1662 | const QModelIndex &bottomRight) | - |
1663 | { | - |
1664 | 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 |
1665 | int column = horizontalHeader->sortIndicatorSection(); executed (the execution status of this line is deduced): int column = horizontalHeader->sortIndicatorSection(); | - |
1666 | 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 |
1667 | Qt::SortOrder order = horizontalHeader->sortIndicatorOrder(); executed (the execution status of this line is deduced): Qt::SortOrder order = horizontalHeader->sortIndicatorOrder(); | - |
1668 | tableModel()->ensureSorted(column, order, topLeft.row(), bottomRight.row()); executed (the execution status of this line is deduced): tableModel()->ensureSorted(column, order, topLeft.row(), bottomRight.row()); | - |
1669 | } executed: } Execution Count:13 | 13 |
1670 | } executed: } Execution Count:23 | 23 |
1671 | } executed: } Execution Count:1002 | 1002 |
1672 | | - |
1673 | /*! | - |
1674 | \fn void QTableWidget::itemPressed(QTableWidgetItem *item) | - |
1675 | | - |
1676 | This signal is emitted whenever an item in the table is pressed. | - |
1677 | The \a item specified is the item that was pressed. | - |
1678 | */ | - |
1679 | | - |
1680 | /*! | - |
1681 | \fn void QTableWidget::itemClicked(QTableWidgetItem *item) | - |
1682 | | - |
1683 | This signal is emitted whenever an item in the table is clicked. | - |
1684 | The \a item specified is the item that was clicked. | - |
1685 | */ | - |
1686 | | - |
1687 | /*! | - |
1688 | \fn void QTableWidget::itemDoubleClicked(QTableWidgetItem *item) | - |
1689 | | - |
1690 | This signal is emitted whenever an item in the table is double | - |
1691 | clicked. The \a item specified is the item that was double clicked. | - |
1692 | */ | - |
1693 | | - |
1694 | /*! | - |
1695 | \fn void QTableWidget::itemActivated(QTableWidgetItem *item) | - |
1696 | | - |
1697 | This signal is emitted when the specified \a item has been activated | - |
1698 | */ | - |
1699 | | - |
1700 | /*! | - |
1701 | \fn void QTableWidget::itemEntered(QTableWidgetItem *item) | - |
1702 | | - |
1703 | This signal is emitted when the mouse cursor enters an item. The | - |
1704 | \a item is the item entered. | - |
1705 | | - |
1706 | This signal is only emitted when mouseTracking is turned on, or when a | - |
1707 | mouse button is pressed while moving into an item. | - |
1708 | */ | - |
1709 | | - |
1710 | /*! | - |
1711 | \fn void QTableWidget::itemChanged(QTableWidgetItem *item) | - |
1712 | | - |
1713 | This signal is emitted whenever the data of \a item has changed. | - |
1714 | */ | - |
1715 | | - |
1716 | /*! | - |
1717 | \fn void QTableWidget::currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous) | - |
1718 | | - |
1719 | This signal is emitted whenever the current item changes. The \a | - |
1720 | previous item is the item that previously had the focus, \a | - |
1721 | current is the new current item. | - |
1722 | */ | - |
1723 | | - |
1724 | /*! | - |
1725 | \fn void QTableWidget::itemSelectionChanged() | - |
1726 | | - |
1727 | This signal is emitted whenever the selection changes. | - |
1728 | | - |
1729 | \sa selectedItems(), QTableWidgetItem::isSelected() | - |
1730 | */ | - |
1731 | | - |
1732 | | - |
1733 | /*! | - |
1734 | \since 4.1 | - |
1735 | \fn void QTableWidget::cellPressed(int row, int column) | - |
1736 | | - |
1737 | This signal is emitted whenever a cell in the table is pressed. | - |
1738 | The \a row and \a column specified is the cell that was pressed. | - |
1739 | */ | - |
1740 | | - |
1741 | /*! | - |
1742 | \since 4.1 | - |
1743 | \fn void QTableWidget::cellClicked(int row, int column) | - |
1744 | | - |
1745 | This signal is emitted whenever a cell in the table is clicked. | - |
1746 | The \a row and \a column specified is the cell that was clicked. | - |
1747 | */ | - |
1748 | | - |
1749 | /*! | - |
1750 | \since 4.1 | - |
1751 | \fn void QTableWidget::cellDoubleClicked(int row, int column) | - |
1752 | | - |
1753 | This signal is emitted whenever a cell in the table is double | - |
1754 | clicked. The \a row and \a column specified is the cell that was | - |
1755 | double clicked. | - |
1756 | */ | - |
1757 | | - |
1758 | /*! | - |
1759 | \since 4.1 | - |
1760 | \fn void QTableWidget::cellActivated(int row, int column) | - |
1761 | | - |
1762 | This signal is emitted when the cell specified by \a row and \a column | - |
1763 | has been activated | - |
1764 | */ | - |
1765 | | - |
1766 | /*! | - |
1767 | \since 4.1 | - |
1768 | \fn void QTableWidget::cellEntered(int row, int column) | - |
1769 | | - |
1770 | This signal is emitted when the mouse cursor enters a cell. The | - |
1771 | cell is specified by \a row and \a column. | - |
1772 | | - |
1773 | This signal is only emitted when mouseTracking is turned on, or when a | - |
1774 | mouse button is pressed while moving into an item. | - |
1775 | */ | - |
1776 | | - |
1777 | /*! | - |
1778 | \since 4.1 | - |
1779 | \fn void QTableWidget::cellChanged(int row, int column) | - |
1780 | | - |
1781 | This signal is emitted whenever the data of the item in the cell | - |
1782 | specified by \a row and \a column has changed. | - |
1783 | */ | - |
1784 | | - |
1785 | /*! | - |
1786 | \since 4.1 | - |
1787 | \fn void QTableWidget::currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) | - |
1788 | | - |
1789 | This signal is emitted whenever the current cell changes. The cell | - |
1790 | specified by \a previousRow and \a previousColumn is the cell that | - |
1791 | previously had the focus, the cell specified by \a currentRow and \a | - |
1792 | currentColumn is the new current cell. | - |
1793 | */ | - |
1794 | | - |
1795 | /*! | - |
1796 | \since 4.3 | - |
1797 | \fn void QTableWidget::removeCellWidget(int row, int column) | - |
1798 | | - |
1799 | Removes the widget set on the cell indicated by \a row and \a column. | - |
1800 | */ | - |
1801 | | - |
1802 | /*! | - |
1803 | \fn QTableWidgetItem *QTableWidget::itemAt(int ax, int ay) const | - |
1804 | | - |
1805 | Returns the item at the position equivalent to QPoint(\a{ax}, \a{ay}) in | - |
1806 | the table widget's coordinate system, or returns 0 if the specified point | - |
1807 | is not covered by an item in the table widget. | - |
1808 | | - |
1809 | \sa item() | - |
1810 | */ | - |
1811 | | - |
1812 | /*! | - |
1813 | \enum QTableWidgetItem::ItemType | - |
1814 | | - |
1815 | This enum describes the types that are used to describe table widget items. | - |
1816 | | - |
1817 | \value Type The default type for table widget items. | - |
1818 | \value UserType The minimum value for custom types. Values below UserType are | - |
1819 | reserved by Qt. | - |
1820 | | - |
1821 | You can define new user types in QTableWidgetItem subclasses to ensure that | - |
1822 | custom items are treated specially. | - |
1823 | | - |
1824 | \sa type() | - |
1825 | */ | - |
1826 | | - |
1827 | /*! | - |
1828 | \fn int QTableWidgetItem::type() const | - |
1829 | | - |
1830 | Returns the type passed to the QTableWidgetItem constructor. | - |
1831 | */ | - |
1832 | | - |
1833 | /*! | - |
1834 | Creates a new table view with the given \a parent. | - |
1835 | */ | - |
1836 | QTableWidget::QTableWidget(QWidget *parent) | - |
1837 | : QTableView(*new QTableWidgetPrivate, parent) | - |
1838 | { | - |
1839 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
1840 | QTableView::setModel(new QTableModel(0, 0, this)); executed (the execution status of this line is deduced): QTableView::setModel(new QTableModel(0, 0, this)); | - |
1841 | d->setup(); executed (the execution status of this line is deduced): d->setup(); | - |
1842 | } executed: } Execution Count:106 | 106 |
1843 | | - |
1844 | /*! | - |
1845 | Creates a new table view with the given \a rows and \a columns, and with the given \a parent. | - |
1846 | */ | - |
1847 | QTableWidget::QTableWidget(int rows, int columns, QWidget *parent) | - |
1848 | : QTableView(*new QTableWidgetPrivate, parent) | - |
1849 | { | - |
1850 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
1851 | QTableView::setModel(new QTableModel(rows, columns, this)); executed (the execution status of this line is deduced): QTableView::setModel(new QTableModel(rows, columns, this)); | - |
1852 | d->setup(); executed (the execution status of this line is deduced): d->setup(); | - |
1853 | } executed: } Execution Count:40 | 40 |
1854 | | - |
1855 | /*! | - |
1856 | Destroys this QTableWidget. | - |
1857 | */ | - |
1858 | QTableWidget::~QTableWidget() | - |
1859 | { | - |
1860 | } | - |
1861 | | - |
1862 | /*! | - |
1863 | Sets the number of rows in this table's model to \a rows. If | - |
1864 | this is less than rowCount(), the data in the unwanted rows | - |
1865 | is discarded. | - |
1866 | | - |
1867 | \sa setColumnCount() | - |
1868 | */ | - |
1869 | void QTableWidget::setRowCount(int rows) | - |
1870 | { | - |
1871 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
1872 | d->tableModel()->setRowCount(rows); executed (the execution status of this line is deduced): d->tableModel()->setRowCount(rows); | - |
1873 | } executed: } Execution Count:287 | 287 |
1874 | | - |
1875 | /*! | - |
1876 | Returns the number of rows. | - |
1877 | */ | - |
1878 | | - |
1879 | int QTableWidget::rowCount() const | - |
1880 | { | - |
1881 | Q_D(const QTableWidget); executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
1882 | return d->model->rowCount(); executed: return d->model->rowCount(); Execution Count:702 | 702 |
1883 | } | - |
1884 | | - |
1885 | /*! | - |
1886 | Sets the number of columns in this table's model to \a columns. If | - |
1887 | this is less than columnCount(), the data in the unwanted columns | - |
1888 | is discarded. | - |
1889 | | - |
1890 | \sa setRowCount() | - |
1891 | */ | - |
1892 | void QTableWidget::setColumnCount(int columns) | - |
1893 | { | - |
1894 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
1895 | d->tableModel()->setColumnCount(columns); executed (the execution status of this line is deduced): d->tableModel()->setColumnCount(columns); | - |
1896 | } executed: } Execution Count:288 | 288 |
1897 | | - |
1898 | /*! | - |
1899 | Returns the number of columns. | - |
1900 | */ | - |
1901 | | - |
1902 | int QTableWidget::columnCount() const | - |
1903 | { | - |
1904 | Q_D(const QTableWidget); executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
1905 | return d->model->columnCount(); executed: return d->model->columnCount(); Execution Count:976 | 976 |
1906 | } | - |
1907 | | - |
1908 | /*! | - |
1909 | Returns the row for the \a item. | - |
1910 | */ | - |
1911 | int QTableWidget::row(const QTableWidgetItem *item) const | - |
1912 | { | - |
1913 | Q_D(const QTableWidget); never executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
1914 | return d->tableModel()->index(item).row(); never executed: return d->tableModel()->index(item).row(); | 0 |
1915 | } | - |
1916 | | - |
1917 | /*! | - |
1918 | Returns the column for the \a item. | - |
1919 | */ | - |
1920 | int QTableWidget::column(const QTableWidgetItem *item) const | - |
1921 | { | - |
1922 | Q_D(const QTableWidget); never executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
1923 | return d->tableModel()->index(item).column(); never executed: return d->tableModel()->index(item).column(); | 0 |
1924 | } | - |
1925 | | - |
1926 | | - |
1927 | /*! | - |
1928 | Returns the item for the given \a row and \a column if one has been set; otherwise | - |
1929 | returns 0. | - |
1930 | | - |
1931 | \sa setItem() | - |
1932 | */ | - |
1933 | QTableWidgetItem *QTableWidget::item(int row, int column) const | - |
1934 | { | - |
1935 | Q_D(const QTableWidget); executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
1936 | return d->tableModel()->item(row, column); executed: return d->tableModel()->item(row, column); Execution Count:573 | 573 |
1937 | } | - |
1938 | | - |
1939 | /*! | - |
1940 | Sets the item for the given \a row and \a column to \a item. | - |
1941 | | - |
1942 | The table takes ownership of the item. | - |
1943 | | - |
1944 | Note that if sorting is enabled (see | - |
1945 | \l{QTableView::sortingEnabled} {sortingEnabled}) and \a column is | - |
1946 | the current sort column, the \a row will be moved to the sorted | - |
1947 | position determined by \a item. | - |
1948 | | - |
1949 | If you want to set several items of a particular row (say, by | - |
1950 | calling setItem() in a loop), you may want to turn off sorting | - |
1951 | before doing so, and turn it back on afterwards; this will allow | - |
1952 | you to use the same \a row argument for all items in the same row | - |
1953 | (i.e. setItem() will not move the row). | - |
1954 | | - |
1955 | \sa item(), takeItem() | - |
1956 | */ | - |
1957 | void QTableWidget::setItem(int row, int column, QTableWidgetItem *item) | - |
1958 | { | - |
1959 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
1960 | if (item) { evaluated: item yes Evaluation Count:984 | yes Evaluation Count:1 |
| 1-984 |
1961 | if (item->view != 0) { partially evaluated: item->view != 0 no Evaluation Count:0 | yes Evaluation Count:984 |
| 0-984 |
1962 | qWarning("QTableWidget: cannot insert an item that is already owned by another QTableWidget"); never executed (the execution status of this line is deduced): QMessageLogger("itemviews/qtablewidget.cpp", 1962, __PRETTY_FUNCTION__).warning("QTableWidget: cannot insert an item that is already owned by another QTableWidget"); | - |
1963 | } else { | 0 |
1964 | item->view = this; executed (the execution status of this line is deduced): item->view = this; | - |
1965 | d->tableModel()->setItem(row, column, item); executed (the execution status of this line is deduced): d->tableModel()->setItem(row, column, item); | - |
1966 | } executed: } Execution Count:984 | 984 |
1967 | } else { | - |
1968 | delete takeItem(row, column); executed (the execution status of this line is deduced): delete takeItem(row, column); | - |
1969 | } executed: } Execution Count:1 | 1 |
1970 | } | - |
1971 | | - |
1972 | /*! | - |
1973 | Removes the item at \a row and \a column from the table without deleting it. | - |
1974 | */ | - |
1975 | QTableWidgetItem *QTableWidget::takeItem(int row, int column) | - |
1976 | { | - |
1977 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
1978 | QTableWidgetItem *item = d->tableModel()->takeItem(row, column); executed (the execution status of this line is deduced): QTableWidgetItem *item = d->tableModel()->takeItem(row, column); | - |
1979 | if (item) evaluated: item yes Evaluation Count:4 | yes Evaluation Count:8 |
| 4-8 |
1980 | item->view = 0; executed: item->view = 0; Execution Count:4 | 4 |
1981 | return item; executed: return item; Execution Count:12 | 12 |
1982 | } | - |
1983 | | - |
1984 | /*! | - |
1985 | Returns the vertical header item for row \a row. | - |
1986 | */ | - |
1987 | QTableWidgetItem *QTableWidget::verticalHeaderItem(int row) const | - |
1988 | { | - |
1989 | Q_D(const QTableWidget); executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
1990 | return d->tableModel()->verticalHeaderItem(row); executed: return d->tableModel()->verticalHeaderItem(row); Execution Count:1 | 1 |
1991 | } | - |
1992 | | - |
1993 | /*! | - |
1994 | Sets the vertical header item for row \a row to \a item. | - |
1995 | */ | - |
1996 | void QTableWidget::setVerticalHeaderItem(int row, QTableWidgetItem *item) | - |
1997 | { | - |
1998 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
1999 | if (item) { partially evaluated: item yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
2000 | item->view = this; executed (the execution status of this line is deduced): item->view = this; | - |
2001 | d->tableModel()->setVerticalHeaderItem(row, item); executed (the execution status of this line is deduced): d->tableModel()->setVerticalHeaderItem(row, item); | - |
2002 | } else { executed: } Execution Count:7 | 7 |
2003 | delete takeVerticalHeaderItem(row); never executed (the execution status of this line is deduced): delete takeVerticalHeaderItem(row); | - |
2004 | } | 0 |
2005 | } | - |
2006 | | - |
2007 | /*! | - |
2008 | \since 4.1 | - |
2009 | Removes the vertical header item at \a row from the header without deleting it. | - |
2010 | */ | - |
2011 | QTableWidgetItem *QTableWidget::takeVerticalHeaderItem(int row) | - |
2012 | { | - |
2013 | Q_D(QTableWidget); never executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2014 | QTableWidgetItem *itm = d->tableModel()->takeVerticalHeaderItem(row); never executed (the execution status of this line is deduced): QTableWidgetItem *itm = d->tableModel()->takeVerticalHeaderItem(row); | - |
2015 | if (itm) | 0 |
2016 | itm->view = 0; never executed: itm->view = 0; | 0 |
2017 | return itm; never executed: return itm; | 0 |
2018 | } | - |
2019 | | - |
2020 | /*! | - |
2021 | Returns the horizontal header item for column, \a column, if one has been | - |
2022 | set; otherwise returns 0. | - |
2023 | */ | - |
2024 | QTableWidgetItem *QTableWidget::horizontalHeaderItem(int column) const | - |
2025 | { | - |
2026 | Q_D(const QTableWidget); executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
2027 | return d->tableModel()->horizontalHeaderItem(column); executed: return d->tableModel()->horizontalHeaderItem(column); Execution Count:3 | 3 |
2028 | } | - |
2029 | | - |
2030 | /*! | - |
2031 | Sets the horizontal header item for column \a column to \a item. | - |
2032 | */ | - |
2033 | void QTableWidget::setHorizontalHeaderItem(int column, QTableWidgetItem *item) | - |
2034 | { | - |
2035 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2036 | if (item) { partially evaluated: item yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
2037 | item->view = this; executed (the execution status of this line is deduced): item->view = this; | - |
2038 | d->tableModel()->setHorizontalHeaderItem(column, item); executed (the execution status of this line is deduced): d->tableModel()->setHorizontalHeaderItem(column, item); | - |
2039 | } else { executed: } Execution Count:11 | 11 |
2040 | delete takeHorizontalHeaderItem(column); never executed (the execution status of this line is deduced): delete takeHorizontalHeaderItem(column); | - |
2041 | } | 0 |
2042 | } | - |
2043 | | - |
2044 | /*! | - |
2045 | \since 4.1 | - |
2046 | Removes the horizontal header item at \a column from the header without deleting it. | - |
2047 | */ | - |
2048 | QTableWidgetItem *QTableWidget::takeHorizontalHeaderItem(int column) | - |
2049 | { | - |
2050 | Q_D(QTableWidget); never executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2051 | QTableWidgetItem *itm = d->tableModel()->takeHorizontalHeaderItem(column); never executed (the execution status of this line is deduced): QTableWidgetItem *itm = d->tableModel()->takeHorizontalHeaderItem(column); | - |
2052 | if (itm) | 0 |
2053 | itm->view = 0; never executed: itm->view = 0; | 0 |
2054 | return itm; never executed: return itm; | 0 |
2055 | } | - |
2056 | | - |
2057 | /*! | - |
2058 | Sets the vertical header labels using \a labels. | - |
2059 | */ | - |
2060 | void QTableWidget::setVerticalHeaderLabels(const QStringList &labels) | - |
2061 | { | - |
2062 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2063 | QTableModel *model = d->tableModel(); executed (the execution status of this line is deduced): QTableModel *model = d->tableModel(); | - |
2064 | QTableWidgetItem *item = 0; executed (the execution status of this line is deduced): QTableWidgetItem *item = 0; | - |
2065 | 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 |
2066 | item = model->verticalHeaderItem(i); executed (the execution status of this line is deduced): item = model->verticalHeaderItem(i); | - |
2067 | if (!item) { partially evaluated: !item yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2068 | item = model->createItem(); executed (the execution status of this line is deduced): item = model->createItem(); | - |
2069 | setVerticalHeaderItem(i, item); executed (the execution status of this line is deduced): setVerticalHeaderItem(i, item); | - |
2070 | } executed: } Execution Count:3 | 3 |
2071 | item->setText(labels.at(i)); executed (the execution status of this line is deduced): item->setText(labels.at(i)); | - |
2072 | } executed: } Execution Count:3 | 3 |
2073 | } executed: } Execution Count:1 | 1 |
2074 | | - |
2075 | /*! | - |
2076 | Sets the horizontal header labels using \a labels. | - |
2077 | */ | - |
2078 | void QTableWidget::setHorizontalHeaderLabels(const QStringList &labels) | - |
2079 | { | - |
2080 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2081 | QTableModel *model = d->tableModel(); executed (the execution status of this line is deduced): QTableModel *model = d->tableModel(); | - |
2082 | QTableWidgetItem *item = 0; executed (the execution status of this line is deduced): QTableWidgetItem *item = 0; | - |
2083 | 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 |
2084 | item = model->horizontalHeaderItem(i); executed (the execution status of this line is deduced): item = model->horizontalHeaderItem(i); | - |
2085 | if (!item) { partially evaluated: !item yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2086 | item = model->createItem(); executed (the execution status of this line is deduced): item = model->createItem(); | - |
2087 | setHorizontalHeaderItem(i, item); executed (the execution status of this line is deduced): setHorizontalHeaderItem(i, item); | - |
2088 | } executed: } Execution Count:3 | 3 |
2089 | item->setText(labels.at(i)); executed (the execution status of this line is deduced): item->setText(labels.at(i)); | - |
2090 | } executed: } Execution Count:3 | 3 |
2091 | } executed: } Execution Count:1 | 1 |
2092 | | - |
2093 | /*! | - |
2094 | Returns the row of the current item. | - |
2095 | | - |
2096 | \sa currentColumn(), setCurrentCell() | - |
2097 | */ | - |
2098 | int QTableWidget::currentRow() const | - |
2099 | { | - |
2100 | return currentIndex().row(); executed: return currentIndex().row(); Execution Count:2 | 2 |
2101 | } | - |
2102 | | - |
2103 | /*! | - |
2104 | Returns the column of the current item. | - |
2105 | | - |
2106 | \sa currentRow(), setCurrentCell() | - |
2107 | */ | - |
2108 | int QTableWidget::currentColumn() const | - |
2109 | { | - |
2110 | return currentIndex().column(); executed: return currentIndex().column(); Execution Count:2 | 2 |
2111 | } | - |
2112 | | - |
2113 | /*! | - |
2114 | Returns the current item. | - |
2115 | | - |
2116 | \sa setCurrentItem() | - |
2117 | */ | - |
2118 | QTableWidgetItem *QTableWidget::currentItem() const | - |
2119 | { | - |
2120 | Q_D(const QTableWidget); executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
2121 | return d->tableModel()->item(currentIndex()); executed: return d->tableModel()->item(currentIndex()); Execution Count:2 | 2 |
2122 | } | - |
2123 | | - |
2124 | /*! | - |
2125 | Sets the current item to \a item. | - |
2126 | | - |
2127 | Unless the selection mode is \l{QAbstractItemView::}{NoSelection}, | - |
2128 | the item is also be selected. | - |
2129 | | - |
2130 | \sa currentItem(), setCurrentCell() | - |
2131 | */ | - |
2132 | void QTableWidget::setCurrentItem(QTableWidgetItem *item) | - |
2133 | { | - |
2134 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2135 | setCurrentIndex(d->tableModel()->index(item)); executed (the execution status of this line is deduced): setCurrentIndex(d->tableModel()->index(item)); | - |
2136 | } executed: } Execution Count:2 | 2 |
2137 | | - |
2138 | /*! | - |
2139 | \since 4.4 | - |
2140 | | - |
2141 | Sets the current item to be \a item, using the given \a command. | - |
2142 | | - |
2143 | \sa currentItem(), setCurrentCell() | - |
2144 | */ | - |
2145 | void QTableWidget::setCurrentItem(QTableWidgetItem *item, QItemSelectionModel::SelectionFlags command) | - |
2146 | { | - |
2147 | Q_D(QTableWidget); never executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2148 | d->selectionModel->setCurrentIndex(d->tableModel()->index(item), command); never executed (the execution status of this line is deduced): d->selectionModel->setCurrentIndex(d->tableModel()->index(item), command); | - |
2149 | } | 0 |
2150 | | - |
2151 | /*! | - |
2152 | \since 4.1 | - |
2153 | | - |
2154 | Sets the current cell to be the cell at position (\a row, \a | - |
2155 | column). | - |
2156 | | - |
2157 | Depending on the current \l{QAbstractItemView::SelectionMode}{selection mode}, | - |
2158 | the cell may also be selected. | - |
2159 | | - |
2160 | \sa setCurrentItem(), currentRow(), currentColumn() | - |
2161 | */ | - |
2162 | void QTableWidget::setCurrentCell(int row, int column) | - |
2163 | { | - |
2164 | setCurrentIndex(model()->index(row, column, QModelIndex())); executed (the execution status of this line is deduced): setCurrentIndex(model()->index(row, column, QModelIndex())); | - |
2165 | } executed: } Execution Count:2 | 2 |
2166 | | - |
2167 | /*! | - |
2168 | \since 4.4 | - |
2169 | | - |
2170 | Sets the current cell to be the cell at position (\a row, \a | - |
2171 | column), using the given \a command. | - |
2172 | | - |
2173 | \sa setCurrentItem(), currentRow(), currentColumn() | - |
2174 | */ | - |
2175 | void QTableWidget::setCurrentCell(int row, int column, QItemSelectionModel::SelectionFlags command) | - |
2176 | { | - |
2177 | Q_D(QTableWidget); never executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2178 | d->selectionModel->setCurrentIndex(model()->index(row, column, QModelIndex()), command); never executed (the execution status of this line is deduced): d->selectionModel->setCurrentIndex(model()->index(row, column, QModelIndex()), command); | - |
2179 | } | 0 |
2180 | | - |
2181 | /*! | - |
2182 | Sorts all the rows in the table widget based on \a column and \a order. | - |
2183 | */ | - |
2184 | void QTableWidget::sortItems(int column, Qt::SortOrder order) | - |
2185 | { | - |
2186 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2187 | d->model->sort(column, order); executed (the execution status of this line is deduced): d->model->sort(column, order); | - |
2188 | horizontalHeader()->setSortIndicator(column, order); executed (the execution status of this line is deduced): horizontalHeader()->setSortIndicator(column, order); | - |
2189 | } executed: } Execution Count:31 | 31 |
2190 | | - |
2191 | /*! | - |
2192 | \internal | - |
2193 | */ | - |
2194 | void QTableWidget::setSortingEnabled(bool enable) | - |
2195 | { | - |
2196 | QTableView::setSortingEnabled(enable); executed (the execution status of this line is deduced): QTableView::setSortingEnabled(enable); | - |
2197 | } executed: } Execution Count:20 | 20 |
2198 | | - |
2199 | /*! | - |
2200 | \internal | - |
2201 | */ | - |
2202 | bool QTableWidget::isSortingEnabled() const | - |
2203 | { | - |
2204 | return QTableView::isSortingEnabled(); executed: return QTableView::isSortingEnabled(); Execution Count:984 | 984 |
2205 | } | - |
2206 | | - |
2207 | /*! | - |
2208 | Starts editing the \a item if it is editable. | - |
2209 | */ | - |
2210 | | - |
2211 | void QTableWidget::editItem(QTableWidgetItem *item) | - |
2212 | { | - |
2213 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2214 | if (!item) partially evaluated: !item no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
2215 | return; | 0 |
2216 | edit(d->tableModel()->index(item)); executed (the execution status of this line is deduced): edit(d->tableModel()->index(item)); | - |
2217 | } executed: } Execution Count:4 | 4 |
2218 | | - |
2219 | /*! | - |
2220 | Opens an editor for the give \a item. The editor remains open after editing. | - |
2221 | | - |
2222 | \sa closePersistentEditor() | - |
2223 | */ | - |
2224 | void QTableWidget::openPersistentEditor(QTableWidgetItem *item) | - |
2225 | { | - |
2226 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2227 | if (!item) partially evaluated: !item no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
2228 | return; | 0 |
2229 | QModelIndex index = d->tableModel()->index(item); executed (the execution status of this line is deduced): QModelIndex index = d->tableModel()->index(item); | - |
2230 | QAbstractItemView::openPersistentEditor(index); executed (the execution status of this line is deduced): QAbstractItemView::openPersistentEditor(index); | - |
2231 | } executed: } Execution Count:1 | 1 |
2232 | | - |
2233 | /*! | - |
2234 | Closes the persistent editor for \a item. | - |
2235 | | - |
2236 | \sa openPersistentEditor() | - |
2237 | */ | - |
2238 | void QTableWidget::closePersistentEditor(QTableWidgetItem *item) | - |
2239 | { | - |
2240 | Q_D(QTableWidget); never executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2241 | if (!item) | 0 |
2242 | return; | 0 |
2243 | QModelIndex index = d->tableModel()->index(item); never executed (the execution status of this line is deduced): QModelIndex index = d->tableModel()->index(item); | - |
2244 | QAbstractItemView::closePersistentEditor(index); never executed (the execution status of this line is deduced): QAbstractItemView::closePersistentEditor(index); | - |
2245 | } | 0 |
2246 | | - |
2247 | /*! | - |
2248 | \since 4.1 | - |
2249 | | - |
2250 | Returns the widget displayed in the cell in the given \a row and \a column. | - |
2251 | | - |
2252 | \note The table takes ownership of the widget. | - |
2253 | | - |
2254 | \sa setCellWidget() | - |
2255 | */ | - |
2256 | QWidget *QTableWidget::cellWidget(int row, int column) const | - |
2257 | { | - |
2258 | QModelIndex index = model()->index(row, column, QModelIndex()); executed (the execution status of this line is deduced): QModelIndex index = model()->index(row, column, QModelIndex()); | - |
2259 | return QAbstractItemView::indexWidget(index); executed: return QAbstractItemView::indexWidget(index); Execution Count:6 | 6 |
2260 | } | - |
2261 | | - |
2262 | /*! | - |
2263 | \since 4.1 | - |
2264 | | - |
2265 | Sets the given \a widget to be displayed in the cell in the given \a row | - |
2266 | and \a column, passing the ownership of the widget to the table. | - |
2267 | | - |
2268 | If cell widget A is replaced with cell widget B, cell widget A will be | - |
2269 | deleted. For example, in the code snippet below, the QLineEdit object will | - |
2270 | be deleted. | - |
2271 | | - |
2272 | \snippet code/src_gui_itemviews_qtablewidget.cpp 0 | - |
2273 | | - |
2274 | \sa cellWidget() | - |
2275 | */ | - |
2276 | void QTableWidget::setCellWidget(int row, int column, QWidget *widget) | - |
2277 | { | - |
2278 | QModelIndex index = model()->index(row, column, QModelIndex()); executed (the execution status of this line is deduced): QModelIndex index = model()->index(row, column, QModelIndex()); | - |
2279 | QAbstractItemView::setIndexWidget(index, widget); executed (the execution status of this line is deduced): QAbstractItemView::setIndexWidget(index, widget); | - |
2280 | } executed: } Execution Count:2 | 2 |
2281 | | - |
2282 | /*! | - |
2283 | Returns true if the \a item is selected, otherwise returns false. | - |
2284 | | - |
2285 | \obsolete | - |
2286 | | - |
2287 | This function is deprecated. Use \l{QTableWidgetItem::isSelected()} instead. | - |
2288 | */ | - |
2289 | | - |
2290 | bool QTableWidget::isItemSelected(const QTableWidgetItem *item) const | - |
2291 | { | - |
2292 | Q_D(const QTableWidget); executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
2293 | QModelIndex index = d->tableModel()->index(item); executed (the execution status of this line is deduced): QModelIndex index = d->tableModel()->index(item); | - |
2294 | return selectionModel()->isSelected(index); executed: return selectionModel()->isSelected(index); Execution Count:20 | 20 |
2295 | } | - |
2296 | | - |
2297 | /*! | - |
2298 | Selects or deselects \a item depending on \a select. | - |
2299 | | - |
2300 | \obsolete | - |
2301 | | - |
2302 | This function is deprecated. Use \l{QTableWidgetItem::setSelected()} instead. | - |
2303 | */ | - |
2304 | void QTableWidget::setItemSelected(const QTableWidgetItem *item, bool select) | - |
2305 | { | - |
2306 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2307 | QModelIndex index = d->tableModel()->index(item); executed (the execution status of this line is deduced): QModelIndex index = d->tableModel()->index(item); | - |
2308 | selectionModel()->select(index, select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect); executed (the execution status of this line is deduced): selectionModel()->select(index, select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect); | - |
2309 | } executed: } Execution Count:5 | 5 |
2310 | | - |
2311 | /*! | - |
2312 | Selects or deselects the \a range depending on \a select. | - |
2313 | */ | - |
2314 | void QTableWidget::setRangeSelected(const QTableWidgetSelectionRange &range, bool select) | - |
2315 | { | - |
2316 | 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 |
2317 | !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 |
2318 | return; executed: return; Execution Count:1 | 1 |
2319 | | - |
2320 | QModelIndex topLeft = model()->index(range.topRow(), range.leftColumn(), rootIndex()); executed (the execution status of this line is deduced): QModelIndex topLeft = model()->index(range.topRow(), range.leftColumn(), rootIndex()); | - |
2321 | QModelIndex bottomRight = model()->index(range.bottomRow(), range.rightColumn(), rootIndex()); executed (the execution status of this line is deduced): QModelIndex bottomRight = model()->index(range.bottomRow(), range.rightColumn(), rootIndex()); | - |
2322 | | - |
2323 | selectionModel()->select(QItemSelection(topLeft, bottomRight), executed (the execution status of this line is deduced): selectionModel()->select(QItemSelection(topLeft, bottomRight), | - |
2324 | select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect); executed (the execution status of this line is deduced): select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect); | - |
2325 | } executed: } Execution Count:10 | 10 |
2326 | | - |
2327 | /*! | - |
2328 | Returns a list of all selected ranges. | - |
2329 | | - |
2330 | \sa QTableWidgetSelectionRange | - |
2331 | */ | - |
2332 | | - |
2333 | QList<QTableWidgetSelectionRange> QTableWidget::selectedRanges() const | - |
2334 | { | - |
2335 | const QList<QItemSelectionRange> ranges = selectionModel()->selection(); executed (the execution status of this line is deduced): const QList<QItemSelectionRange> ranges = selectionModel()->selection(); | - |
2336 | QList<QTableWidgetSelectionRange> result; executed (the execution status of this line is deduced): QList<QTableWidgetSelectionRange> result; | - |
2337 | for (int i = 0; i < ranges.count(); ++i) evaluated: i < ranges.count() yes Evaluation Count:50 | yes Evaluation Count:63 |
| 50-63 |
2338 | result.append(QTableWidgetSelectionRange(ranges.at(i).top(), executed: result.append(QTableWidgetSelectionRange(ranges.at(i).top(), ranges.at(i).left(), ranges.at(i).bottom(), ranges.at(i).right())); Execution Count:50 | 50 |
2339 | ranges.at(i).left(), executed: result.append(QTableWidgetSelectionRange(ranges.at(i).top(), ranges.at(i).left(), ranges.at(i).bottom(), ranges.at(i).right())); Execution Count:50 | 50 |
2340 | ranges.at(i).bottom(), executed: result.append(QTableWidgetSelectionRange(ranges.at(i).top(), ranges.at(i).left(), ranges.at(i).bottom(), ranges.at(i).right())); Execution Count:50 | 50 |
2341 | 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 |
2342 | return result; executed: return result; Execution Count:63 | 63 |
2343 | } | - |
2344 | | - |
2345 | /*! | - |
2346 | Returns a list of all selected items. | - |
2347 | | - |
2348 | This function returns a list of pointers to the contents of the | - |
2349 | selected cells. Use the selectedIndexes() function to retrieve the | - |
2350 | complete selection \e including empty cells. | - |
2351 | | - |
2352 | \sa selectedIndexes() | - |
2353 | */ | - |
2354 | | - |
2355 | QList<QTableWidgetItem*> QTableWidget::selectedItems() const | - |
2356 | { | - |
2357 | Q_D(const QTableWidget); executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
2358 | QModelIndexList indexes = selectionModel()->selectedIndexes(); executed (the execution status of this line is deduced): QModelIndexList indexes = selectionModel()->selectedIndexes(); | - |
2359 | QList<QTableWidgetItem*> items; executed (the execution status of this line is deduced): QList<QTableWidgetItem*> items; | - |
2360 | for (int i = 0; i < indexes.count(); ++i) { evaluated: i < indexes.count() yes Evaluation Count:92 | yes Evaluation Count:25 |
| 25-92 |
2361 | QModelIndex index = indexes.at(i); executed (the execution status of this line is deduced): QModelIndex index = indexes.at(i); | - |
2362 | if (isIndexHidden(index)) evaluated: isIndexHidden(index) yes Evaluation Count:18 | yes Evaluation Count:74 |
| 18-74 |
2363 | continue; executed: continue; Execution Count:18 | 18 |
2364 | QTableWidgetItem *item = d->tableModel()->item(index); executed (the execution status of this line is deduced): QTableWidgetItem *item = d->tableModel()->item(index); | - |
2365 | if (item) evaluated: item yes Evaluation Count:24 | yes Evaluation Count:50 |
| 24-50 |
2366 | items.append(item); executed: items.append(item); Execution Count:24 | 24 |
2367 | } executed: } Execution Count:74 | 74 |
2368 | return items; executed: return items; Execution Count:25 | 25 |
2369 | } | - |
2370 | | - |
2371 | /*! | - |
2372 | Finds items that matches the \a text using the given \a flags. | - |
2373 | */ | - |
2374 | | - |
2375 | QList<QTableWidgetItem*> QTableWidget::findItems(const QString &text, Qt::MatchFlags flags) const | - |
2376 | { | - |
2377 | Q_D(const QTableWidget); never executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
2378 | QModelIndexList indexes; never executed (the execution status of this line is deduced): QModelIndexList indexes; | - |
2379 | for (int column = 0; column < columnCount(); ++column) never evaluated: column < columnCount() | 0 |
2380 | 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 |
2381 | Qt::DisplayRole, text, -1, flags); never executed: indexes += d->model->match(model()->index(0, column, QModelIndex()), Qt::DisplayRole, text, -1, flags); | 0 |
2382 | QList<QTableWidgetItem*> items; never executed (the execution status of this line is deduced): QList<QTableWidgetItem*> items; | - |
2383 | for (int i = 0; i < indexes.size(); ++i) never evaluated: i < indexes.size() | 0 |
2384 | items.append(d->tableModel()->item(indexes.at(i))); never executed: items.append(d->tableModel()->item(indexes.at(i))); | 0 |
2385 | return items; never executed: return items; | 0 |
2386 | } | - |
2387 | | - |
2388 | /*! | - |
2389 | Returns the visual row of the given \a logicalRow. | - |
2390 | */ | - |
2391 | | - |
2392 | int QTableWidget::visualRow(int logicalRow) const | - |
2393 | { | - |
2394 | return verticalHeader()->visualIndex(logicalRow); never executed: return verticalHeader()->visualIndex(logicalRow); | 0 |
2395 | } | - |
2396 | | - |
2397 | /*! | - |
2398 | Returns the visual column of the given \a logicalColumn. | - |
2399 | */ | - |
2400 | | - |
2401 | int QTableWidget::visualColumn(int logicalColumn) const | - |
2402 | { | - |
2403 | return horizontalHeader()->visualIndex(logicalColumn); never executed: return horizontalHeader()->visualIndex(logicalColumn); | 0 |
2404 | } | - |
2405 | | - |
2406 | /*! | - |
2407 | \fn QTableWidgetItem *QTableWidget::itemAt(const QPoint &point) const | - |
2408 | | - |
2409 | Returns a pointer to the item at the given \a point, or returns 0 if | - |
2410 | \a point is not covered by an item in the table widget. | - |
2411 | | - |
2412 | \sa item() | - |
2413 | */ | - |
2414 | | - |
2415 | QTableWidgetItem *QTableWidget::itemAt(const QPoint &p) const | - |
2416 | { | - |
2417 | Q_D(const QTableWidget); never executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
2418 | return d->tableModel()->item(indexAt(p)); never executed: return d->tableModel()->item(indexAt(p)); | 0 |
2419 | } | - |
2420 | | - |
2421 | /*! | - |
2422 | Returns the rectangle on the viewport occupied by the item at \a item. | - |
2423 | */ | - |
2424 | QRect QTableWidget::visualItemRect(const QTableWidgetItem *item) const | - |
2425 | { | - |
2426 | Q_D(const QTableWidget); executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
2427 | if (!item) partially evaluated: !item no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
2428 | return QRect(); never executed: return QRect(); | 0 |
2429 | QModelIndex index = d->tableModel()->index(const_cast<QTableWidgetItem*>(item)); executed (the execution status of this line is deduced): QModelIndex index = d->tableModel()->index(const_cast<QTableWidgetItem*>(item)); | - |
2430 | Q_ASSERT(index.isValid()); executed (the execution status of this line is deduced): qt_noop(); | - |
2431 | return visualRect(index); executed: return visualRect(index); Execution Count:3 | 3 |
2432 | } | - |
2433 | | - |
2434 | /*! | - |
2435 | Scrolls the view if necessary to ensure that the \a item is visible. | - |
2436 | The \a hint parameter specifies more precisely where the | - |
2437 | \a item should be located after the operation. | - |
2438 | */ | - |
2439 | | - |
2440 | void QTableWidget::scrollToItem(const QTableWidgetItem *item, QAbstractItemView::ScrollHint hint) | - |
2441 | { | - |
2442 | Q_D(QTableWidget); never executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2443 | if (!item) | 0 |
2444 | return; | 0 |
2445 | QModelIndex index = d->tableModel()->index(const_cast<QTableWidgetItem*>(item)); never executed (the execution status of this line is deduced): QModelIndex index = d->tableModel()->index(const_cast<QTableWidgetItem*>(item)); | - |
2446 | Q_ASSERT(index.isValid()); never executed (the execution status of this line is deduced): qt_noop(); | - |
2447 | QTableView::scrollTo(index, hint); never executed (the execution status of this line is deduced): QTableView::scrollTo(index, hint); | - |
2448 | } | 0 |
2449 | | - |
2450 | /*! | - |
2451 | Returns the item prototype used by the table. | - |
2452 | | - |
2453 | \sa setItemPrototype() | - |
2454 | */ | - |
2455 | const QTableWidgetItem *QTableWidget::itemPrototype() const | - |
2456 | { | - |
2457 | Q_D(const QTableWidget); executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
2458 | return d->tableModel()->itemPrototype(); executed: return d->tableModel()->itemPrototype(); Execution Count:2 | 2 |
2459 | } | - |
2460 | | - |
2461 | /*! | - |
2462 | Sets the item prototype for the table to the specified \a item. | - |
2463 | | - |
2464 | The table widget will use the item prototype clone function when it needs | - |
2465 | to create a new table item. For example when the user is editing | - |
2466 | in an empty cell. This is useful when you have a QTableWidgetItem | - |
2467 | subclass and want to make sure that QTableWidget creates instances of | - |
2468 | your subclass. | - |
2469 | | - |
2470 | The table takes ownership of the prototype. | - |
2471 | | - |
2472 | \sa itemPrototype() | - |
2473 | */ | - |
2474 | void QTableWidget::setItemPrototype(const QTableWidgetItem *item) | - |
2475 | { | - |
2476 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2477 | d->tableModel()->setItemPrototype(item); executed (the execution status of this line is deduced): d->tableModel()->setItemPrototype(item); | - |
2478 | } executed: } Execution Count:2 | 2 |
2479 | | - |
2480 | /*! | - |
2481 | Inserts an empty row into the table at \a row. | - |
2482 | */ | - |
2483 | void QTableWidget::insertRow(int row) | - |
2484 | { | - |
2485 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2486 | d->tableModel()->insertRows(row); executed (the execution status of this line is deduced): d->tableModel()->insertRows(row); | - |
2487 | } executed: } Execution Count:8 | 8 |
2488 | | - |
2489 | /*! | - |
2490 | Inserts an empty column into the table at \a column. | - |
2491 | */ | - |
2492 | void QTableWidget::insertColumn(int column) | - |
2493 | { | - |
2494 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2495 | d->tableModel()->insertColumns(column); executed (the execution status of this line is deduced): d->tableModel()->insertColumns(column); | - |
2496 | } executed: } Execution Count:8 | 8 |
2497 | | - |
2498 | /*! | - |
2499 | Removes the row \a row and all its items from the table. | - |
2500 | */ | - |
2501 | void QTableWidget::removeRow(int row) | - |
2502 | { | - |
2503 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2504 | d->tableModel()->removeRows(row); executed (the execution status of this line is deduced): d->tableModel()->removeRows(row); | - |
2505 | } executed: } Execution Count:7 | 7 |
2506 | | - |
2507 | /*! | - |
2508 | Removes the column \a column and all its items from the table. | - |
2509 | */ | - |
2510 | void QTableWidget::removeColumn(int column) | - |
2511 | { | - |
2512 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2513 | d->tableModel()->removeColumns(column); executed (the execution status of this line is deduced): d->tableModel()->removeColumns(column); | - |
2514 | } executed: } Execution Count:6 | 6 |
2515 | | - |
2516 | /*! | - |
2517 | Removes all items in the view. | - |
2518 | This will also remove all selections. | - |
2519 | The table dimensions stay the same. | - |
2520 | */ | - |
2521 | | - |
2522 | void QTableWidget::clear() | - |
2523 | { | - |
2524 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2525 | selectionModel()->clear(); executed (the execution status of this line is deduced): selectionModel()->clear(); | - |
2526 | d->tableModel()->clear(); executed (the execution status of this line is deduced): d->tableModel()->clear(); | - |
2527 | } executed: } Execution Count:85 | 85 |
2528 | | - |
2529 | /*! | - |
2530 | \since 4.2 | - |
2531 | | - |
2532 | Removes all items not in the headers from the view. | - |
2533 | This will also remove all selections. | - |
2534 | The table dimensions stay the same. | - |
2535 | */ | - |
2536 | void QTableWidget::clearContents() | - |
2537 | { | - |
2538 | Q_D(QTableWidget); executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2539 | selectionModel()->clear(); executed (the execution status of this line is deduced): selectionModel()->clear(); | - |
2540 | d->tableModel()->clearContents(); executed (the execution status of this line is deduced): d->tableModel()->clearContents(); | - |
2541 | } executed: } Execution Count:1 | 1 |
2542 | | - |
2543 | /*! | - |
2544 | Returns a list of MIME types that can be used to describe a list of | - |
2545 | tablewidget items. | - |
2546 | | - |
2547 | \sa mimeData() | - |
2548 | */ | - |
2549 | QStringList QTableWidget::mimeTypes() const | - |
2550 | { | - |
2551 | return d_func()->tableModel()->QAbstractTableModel::mimeTypes(); executed: return d_func()->tableModel()->QAbstractTableModel::mimeTypes(); Execution Count:2 | 2 |
2552 | } | - |
2553 | | - |
2554 | /*! | - |
2555 | Returns an object that contains a serialized description of the specified | - |
2556 | \a items. The format used to describe the items is obtained from the | - |
2557 | mimeTypes() function. | - |
2558 | | - |
2559 | If the list of items is empty, 0 is returned rather than a serialized | - |
2560 | empty list. | - |
2561 | */ | - |
2562 | QMimeData *QTableWidget::mimeData(const QList<QTableWidgetItem*>) const | - |
2563 | { | - |
2564 | return d_func()->tableModel()->internalMimeData(); never executed: return d_func()->tableModel()->internalMimeData(); | 0 |
2565 | } | - |
2566 | | - |
2567 | /*! | - |
2568 | Handles the \a data supplied by a drag and drop operation that ended with | - |
2569 | the given \a action in the given \a row and \a column. | - |
2570 | Returns true if the data and action can be handled by the model; | - |
2571 | otherwise returns false. | - |
2572 | | - |
2573 | \sa supportedDropActions() | - |
2574 | */ | - |
2575 | bool QTableWidget::dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action) | - |
2576 | { | - |
2577 | QModelIndex idx; never executed (the execution status of this line is deduced): QModelIndex idx; | - |
2578 | #ifndef QT_NO_DRAGANDDROP | - |
2579 | if (dropIndicatorPosition() == QAbstractItemView::OnItem) { never evaluated: dropIndicatorPosition() == QAbstractItemView::OnItem | 0 |
2580 | // QAbstractTableModel::dropMimeData will overwrite on the index if row == -1 and column == -1 | - |
2581 | idx = model()->index(row, column); never executed (the execution status of this line is deduced): idx = model()->index(row, column); | - |
2582 | row = -1; never executed (the execution status of this line is deduced): row = -1; | - |
2583 | column = -1; never executed (the execution status of this line is deduced): column = -1; | - |
2584 | } | 0 |
2585 | #endif | - |
2586 | 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 |
2587 | } | - |
2588 | | - |
2589 | /*! | - |
2590 | Returns the drop actions supported by this view. | - |
2591 | | - |
2592 | \sa Qt::DropActions | - |
2593 | */ | - |
2594 | Qt::DropActions QTableWidget::supportedDropActions() const | - |
2595 | { | - |
2596 | return d_func()->tableModel()->QAbstractTableModel::supportedDropActions() | Qt::MoveAction; executed: return d_func()->tableModel()->QAbstractTableModel::supportedDropActions() | Qt::MoveAction; Execution Count:2 | 2 |
2597 | } | - |
2598 | | - |
2599 | /*! | - |
2600 | Returns a list of pointers to the items contained in the \a data object. | - |
2601 | If the object was not created by a QTreeWidget in the same process, the list | - |
2602 | is empty. | - |
2603 | | - |
2604 | */ | - |
2605 | QList<QTableWidgetItem*> QTableWidget::items(const QMimeData *data) const | - |
2606 | { | - |
2607 | const QTableWidgetMimeData *twd = qobject_cast<const QTableWidgetMimeData*>(data); never executed (the execution status of this line is deduced): const QTableWidgetMimeData *twd = qobject_cast<const QTableWidgetMimeData*>(data); | - |
2608 | if (twd) | 0 |
2609 | return twd->items; never executed: return twd->items; | 0 |
2610 | return QList<QTableWidgetItem*>(); never executed: return QList<QTableWidgetItem*>(); | 0 |
2611 | } | - |
2612 | | - |
2613 | /*! | - |
2614 | Returns the QModelIndex assocated with the given \a item. | - |
2615 | */ | - |
2616 | | - |
2617 | QModelIndex QTableWidget::indexFromItem(QTableWidgetItem *item) const | - |
2618 | { | - |
2619 | Q_D(const QTableWidget); never executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
2620 | return d->tableModel()->index(item); never executed: return d->tableModel()->index(item); | 0 |
2621 | } | - |
2622 | | - |
2623 | /*! | - |
2624 | Returns a pointer to the QTableWidgetItem assocated with the given \a index. | - |
2625 | */ | - |
2626 | | - |
2627 | QTableWidgetItem *QTableWidget::itemFromIndex(const QModelIndex &index) const | - |
2628 | { | - |
2629 | Q_D(const QTableWidget); never executed (the execution status of this line is deduced): const QTableWidgetPrivate * const d = d_func(); | - |
2630 | return d->tableModel()->item(index); never executed: return d->tableModel()->item(index); | 0 |
2631 | } | - |
2632 | | - |
2633 | /*! | - |
2634 | \internal | - |
2635 | */ | - |
2636 | void QTableWidget::setModel(QAbstractItemModel * /*model*/) | - |
2637 | { | - |
2638 | Q_ASSERT(!"QTableWidget::setModel() - Changing the model of the QTableWidget is not allowed."); never executed (the execution status of this line is deduced): qt_noop(); | - |
2639 | } | 0 |
2640 | | - |
2641 | /*! \reimp */ | - |
2642 | bool QTableWidget::event(QEvent *e) | - |
2643 | { | - |
2644 | return QTableView::event(e); executed: return QTableView::event(e); Execution Count:1485 | 1485 |
2645 | } | - |
2646 | | - |
2647 | #ifndef QT_NO_DRAGANDDROP | - |
2648 | /*! \reimp */ | - |
2649 | void QTableWidget::dropEvent(QDropEvent *event) { | - |
2650 | Q_D(QTableWidget); never executed (the execution status of this line is deduced): QTableWidgetPrivate * const d = d_func(); | - |
2651 | if (event->source() == this && (event->dropAction() == Qt::MoveAction || never evaluated: event->source() == this never evaluated: event->dropAction() == Qt::MoveAction | 0 |
2652 | dragDropMode() == QAbstractItemView::InternalMove)) { never evaluated: dragDropMode() == QAbstractItemView::InternalMove | 0 |
2653 | QModelIndex topIndex; never executed (the execution status of this line is deduced): QModelIndex topIndex; | - |
2654 | int col = -1; never executed (the execution status of this line is deduced): int col = -1; | - |
2655 | int row = -1; never executed (the execution status of this line is deduced): int row = -1; | - |
2656 | if (d->dropOn(event, &row, &col, &topIndex)) { never evaluated: d->dropOn(event, &row, &col, &topIndex) | 0 |
2657 | QModelIndexList indexes = selectedIndexes(); never executed (the execution status of this line is deduced): QModelIndexList indexes = selectedIndexes(); | - |
2658 | int top = INT_MAX; never executed (the execution status of this line is deduced): int top = 2147483647; | - |
2659 | int left = INT_MAX; never executed (the execution status of this line is deduced): int left = 2147483647; | - |
2660 | for (int i = 0; i < indexes.count(); ++i) { never evaluated: i < indexes.count() | 0 |
2661 | top = qMin(indexes.at(i).row(), top); never executed (the execution status of this line is deduced): top = qMin(indexes.at(i).row(), top); | - |
2662 | left = qMin(indexes.at(i).column(), left); never executed (the execution status of this line is deduced): left = qMin(indexes.at(i).column(), left); | - |
2663 | } | 0 |
2664 | | - |
2665 | QList<QTableWidgetItem *> taken; never executed (the execution status of this line is deduced): QList<QTableWidgetItem *> taken; | - |
2666 | for (int i = 0; i < indexes.count(); ++i) never evaluated: i < indexes.count() | 0 |
2667 | 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 |
2668 | | - |
2669 | for (int i = 0; i < indexes.count(); ++i) { never evaluated: i < indexes.count() | 0 |
2670 | QModelIndex index = indexes.at(i); never executed (the execution status of this line is deduced): QModelIndex index = indexes.at(i); | - |
2671 | int r = index.row() - top + topIndex.row(); never executed (the execution status of this line is deduced): int r = index.row() - top + topIndex.row(); | - |
2672 | int c = index.column() - left + topIndex.column(); never executed (the execution status of this line is deduced): int c = index.column() - left + topIndex.column(); | - |
2673 | setItem(r, c, taken.takeFirst()); never executed (the execution status of this line is deduced): setItem(r, c, taken.takeFirst()); | - |
2674 | } | 0 |
2675 | | - |
2676 | event->accept(); never executed (the execution status of this line is deduced): event->accept(); | - |
2677 | // Don't want QAbstractItemView to delete it because it was "moved" we already did it | - |
2678 | event->setDropAction(Qt::CopyAction); never executed (the execution status of this line is deduced): event->setDropAction(Qt::CopyAction); | - |
2679 | } | 0 |
2680 | } | 0 |
2681 | | - |
2682 | QTableView::dropEvent(event); never executed (the execution status of this line is deduced): QTableView::dropEvent(event); | - |
2683 | } | 0 |
2684 | #endif | - |
2685 | | - |
2686 | QT_END_NAMESPACE | - |
2687 | | - |
2688 | #include "moc_qtablewidget.cpp" | - |
2689 | | - |
2690 | #endif // QT_NO_TABLEWIDGET | - |
2691 | | - |
| | |