Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | class QStyledItemDelegatePrivate : public QObjectPrivate | - |
8 | { | - |
9 | inline QStyledItemDelegate* q_func() { return static_cast<QStyledItemDelegate *>(q_ptr); } inline const QStyledItemDelegate* q_func() const { return static_cast<const QStyledItemDelegate *>(q_ptr); } friend class QStyledItemDelegate; | - |
10 | | - |
11 | public: | - |
12 | QStyledItemDelegatePrivate() : factory(0) { } executed: } Execution Count:4211 | 4211 |
13 | | - |
14 | static const QWidget *widget(const QStyleOptionViewItem &option) | - |
15 | { | - |
16 | return option.widget; executed: return option.widget; Execution Count:164027 | 164027 |
17 | } | - |
18 | | - |
19 | const QItemEditorFactory *editorFactory() const | - |
20 | { | - |
21 | return factory ? factory : QItemEditorFactory::defaultFactory(); executed: return factory ? factory : QItemEditorFactory::defaultFactory(); Execution Count:86 | 86 |
22 | } | - |
23 | | - |
24 | void _q_commitDataAndCloseEditor(QWidget *editor) | - |
25 | { | - |
26 | QStyledItemDelegate * const q = q_func(); | - |
27 | q->commitData(editor); | - |
28 | q->closeEditor(editor, QAbstractItemDelegate::SubmitModelCache); | - |
29 | } executed: } Execution Count:12 | 12 |
30 | QItemEditorFactory *factory; | - |
31 | }; | - |
32 | QStyledItemDelegate::QStyledItemDelegate(QObject *parent) | - |
33 | : QAbstractItemDelegate(*new QStyledItemDelegatePrivate(), parent) | - |
34 | { | - |
35 | } executed: } Execution Count:4211 | 4211 |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | QStyledItemDelegate::~QStyledItemDelegate() | - |
41 | { | - |
42 | } | - |
43 | QString QStyledItemDelegate::displayText(const QVariant &value, const QLocale& locale) const | - |
44 | { | - |
45 | QString text; | - |
46 | switch (value.userType()) { | - |
47 | case QMetaType::Float: | - |
48 | case QVariant::Double: | - |
49 | text = locale.toString(value.toReal()); | - |
50 | break; executed: break; Execution Count:11 | 11 |
51 | case QVariant::Int: | - |
52 | case QVariant::LongLong: | - |
53 | text = locale.toString(value.toLongLong()); | - |
54 | break; executed: break; Execution Count:4094 | 4094 |
55 | case QVariant::UInt: | - |
56 | case QVariant::ULongLong: | - |
57 | text = locale.toString(value.toULongLong()); | - |
58 | break; executed: break; Execution Count:12 | 12 |
59 | case QVariant::Date: | - |
60 | text = locale.toString(value.toDate(), QLocale::ShortFormat); | - |
61 | break; executed: break; Execution Count:6 | 6 |
62 | case QVariant::Time: | - |
63 | text = locale.toString(value.toTime(), QLocale::ShortFormat); | - |
64 | break; executed: break; Execution Count:7 | 7 |
65 | case QVariant::DateTime: | - |
66 | text = locale.toString(value.toDateTime().date(), QLocale::ShortFormat); | - |
67 | text += QLatin1Char(' '); | - |
68 | text += locale.toString(value.toDateTime().time(), QLocale::ShortFormat); | - |
69 | break; executed: break; Execution Count:6 | 6 |
70 | default: | - |
71 | | - |
72 | text = value.toString(); | - |
73 | for (int i = 0; i < text.count(); ++i) { evaluated: i < text.count() yes Evaluation Count:1217894 | yes Evaluation Count:120595 |
| 120595-1217894 |
74 | if (text.at(i) == QLatin1Char('\n')) evaluated: text.at(i) == QLatin1Char('\n') yes Evaluation Count:9048 | yes Evaluation Count:1208846 |
| 9048-1208846 |
75 | text[i] = QChar::LineSeparator; executed: text[i] = QChar::LineSeparator; Execution Count:9048 | 9048 |
76 | } executed: } Execution Count:1217894 | 1217894 |
77 | break; executed: break; Execution Count:120595 | 120595 |
78 | } | - |
79 | return text; executed: return text; Execution Count:124731 | 124731 |
80 | } | - |
81 | void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option, | - |
82 | const QModelIndex &index) const | - |
83 | { | - |
84 | QVariant value = index.data(Qt::FontRole); | - |
85 | if (value.isValid() && !value.isNull()) { partially evaluated: value.isValid() no Evaluation Count:0 | yes Evaluation Count:164154 |
never evaluated: !value.isNull() | 0-164154 |
86 | option->font = qvariant_cast<QFont>(value).resolve(option->font); | - |
87 | option->fontMetrics = QFontMetrics(option->font); | - |
88 | } | 0 |
89 | | - |
90 | value = index.data(Qt::TextAlignmentRole); | - |
91 | if (value.isValid() && !value.isNull()) evaluated: value.isValid() yes Evaluation Count:1019 | yes Evaluation Count:163135 |
partially evaluated: !value.isNull() yes Evaluation Count:1019 | no Evaluation Count:0 |
| 0-163135 |
92 | option->displayAlignment = Qt::Alignment(value.toInt()); executed: option->displayAlignment = Qt::Alignment(value.toInt()); Execution Count:1019 | 1019 |
93 | | - |
94 | value = index.data(Qt::ForegroundRole); | - |
95 | if (value.canConvert<QBrush>()) evaluated: value.canConvert<QBrush>() yes Evaluation Count:53155 | yes Evaluation Count:110999 |
| 53155-110999 |
96 | option->palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value)); executed: option->palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value)); Execution Count:53155 | 53155 |
97 | | - |
98 | option->index = index; | - |
99 | value = index.data(Qt::CheckStateRole); | - |
100 | if (value.isValid() && !value.isNull()) { evaluated: value.isValid() yes Evaluation Count:90 | yes Evaluation Count:164064 |
partially evaluated: !value.isNull() yes Evaluation Count:90 | no Evaluation Count:0 |
| 0-164064 |
101 | option->features |= QStyleOptionViewItem::HasCheckIndicator; | - |
102 | option->checkState = static_cast<Qt::CheckState>(value.toInt()); | - |
103 | } executed: } Execution Count:90 | 90 |
104 | | - |
105 | value = index.data(Qt::DecorationRole); | - |
106 | if (value.isValid() && !value.isNull()) { evaluated: value.isValid() yes Evaluation Count:27582 | yes Evaluation Count:136572 |
evaluated: !value.isNull() yes Evaluation Count:27525 | yes Evaluation Count:57 |
| 57-136572 |
107 | option->features |= QStyleOptionViewItem::HasDecoration; | - |
108 | switch (value.type()) { | - |
109 | case QVariant::Icon: { | - |
110 | option->icon = qvariant_cast<QIcon>(value); | - |
111 | QIcon::Mode mode; | - |
112 | if (!(option->state & QStyle::State_Enabled)) partially evaluated: !(option->state & QStyle::State_Enabled) no Evaluation Count:0 | yes Evaluation Count:27525 |
| 0-27525 |
113 | mode = QIcon::Disabled; never executed: mode = QIcon::Disabled; | 0 |
114 | else if (option->state & QStyle::State_Selected) evaluated: option->state & QStyle::State_Selected yes Evaluation Count:21 | yes Evaluation Count:27504 |
| 21-27504 |
115 | mode = QIcon::Selected; executed: mode = QIcon::Selected; Execution Count:21 | 21 |
116 | else | - |
117 | mode = QIcon::Normal; executed: mode = QIcon::Normal; Execution Count:27504 | 27504 |
118 | QIcon::State state = option->state & QStyle::State_Open ? QIcon::On : QIcon::Off; evaluated: option->state & QStyle::State_Open yes Evaluation Count:16 | yes Evaluation Count:27509 |
| 16-27509 |
119 | option->decorationSize = option->icon.actualSize(option->decorationSize, mode, state); | - |
120 | break; executed: break; Execution Count:27525 | 27525 |
121 | } | - |
122 | case QVariant::Color: { | - |
123 | QPixmap pixmap(option->decorationSize); | - |
124 | pixmap.fill(qvariant_cast<QColor>(value)); | - |
125 | option->icon = QIcon(pixmap); | - |
126 | break; | 0 |
127 | } | - |
128 | case QVariant::Image: { | - |
129 | QImage image = qvariant_cast<QImage>(value); | - |
130 | option->icon = QIcon(QPixmap::fromImage(image)); | - |
131 | option->decorationSize = image.size(); | - |
132 | break; | 0 |
133 | } | - |
134 | case QVariant::Pixmap: { | - |
135 | QPixmap pixmap = qvariant_cast<QPixmap>(value); | - |
136 | option->icon = QIcon(pixmap); | - |
137 | option->decorationSize = pixmap.size(); | - |
138 | break; | 0 |
139 | } | - |
140 | default: | - |
141 | break; | 0 |
142 | } | - |
143 | } executed: } Execution Count:27525 | 27525 |
144 | | - |
145 | value = index.data(Qt::DisplayRole); | - |
146 | if (value.isValid() && !value.isNull()) { evaluated: value.isValid() yes Evaluation Count:124741 | yes Evaluation Count:39413 |
evaluated: !value.isNull() yes Evaluation Count:124731 | yes Evaluation Count:10 |
| 10-124741 |
147 | option->features |= QStyleOptionViewItem::HasDisplay; | - |
148 | option->text = displayText(value, option->locale); | - |
149 | } executed: } Execution Count:124731 | 124731 |
150 | | - |
151 | option->backgroundBrush = qvariant_cast<QBrush>(index.data(Qt::BackgroundRole)); | - |
152 | } executed: } Execution Count:164154 | 164154 |
153 | void QStyledItemDelegate::paint(QPainter *painter, | - |
154 | const QStyleOptionViewItem &option, const QModelIndex &index) const | - |
155 | { | - |
156 | qt_noop(); | - |
157 | | - |
158 | QStyleOptionViewItem opt = option; | - |
159 | initStyleOption(&opt, index); | - |
160 | | - |
161 | const QWidget *widget = QStyledItemDelegatePrivate::widget(option); | - |
162 | QStyle *style = widget ? widget->style() : QApplication::style(); partially evaluated: widget yes Evaluation Count:13241 | no Evaluation Count:0 |
| 0-13241 |
163 | style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget); | - |
164 | } executed: } Execution Count:13241 | 13241 |
165 | QSize QStyledItemDelegate::sizeHint(const QStyleOptionViewItem &option, | - |
166 | const QModelIndex &index) const | - |
167 | { | - |
168 | QVariant value = index.data(Qt::SizeHintRole); | - |
169 | if (value.isValid()) evaluated: value.isValid() yes Evaluation Count:10 | yes Evaluation Count:150673 |
| 10-150673 |
170 | return qvariant_cast<QSize>(value); executed: return qvariant_cast<QSize>(value); Execution Count:10 | 10 |
171 | | - |
172 | QStyleOptionViewItem opt = option; | - |
173 | initStyleOption(&opt, index); | - |
174 | const QWidget *widget = QStyledItemDelegatePrivate::widget(option); | - |
175 | QStyle *style = widget ? widget->style() : QApplication::style(); partially evaluated: widget yes Evaluation Count:150673 | no Evaluation Count:0 |
| 0-150673 |
176 | return style->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), widget); executed: return style->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), widget); Execution Count:150673 | 150673 |
177 | } | - |
178 | QWidget *QStyledItemDelegate::createEditor(QWidget *parent, | - |
179 | const QStyleOptionViewItem &, | - |
180 | const QModelIndex &index) const | - |
181 | { | - |
182 | const QStyledItemDelegatePrivate * const d = d_func(); | - |
183 | if (!index.isValid()) evaluated: !index.isValid() yes Evaluation Count:20 | yes Evaluation Count:86 |
| 20-86 |
184 | return 0; executed: return 0; Execution Count:20 | 20 |
185 | return d->editorFactory()->createEditor(index.data(Qt::EditRole).userType(), parent); executed: return d->editorFactory()->createEditor(index.data(Qt::EditRole).userType(), parent); Execution Count:86 | 86 |
186 | } | - |
187 | void QStyledItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const | - |
188 | { | - |
189 | | - |
190 | | - |
191 | | - |
192 | | - |
193 | QVariant v = index.data(Qt::EditRole); | - |
194 | QByteArray n = editor->metaObject()->userProperty().name(); | - |
195 | | - |
196 | if (!n.isEmpty()) { partially evaluated: !n.isEmpty() yes Evaluation Count:115 | no Evaluation Count:0 |
| 0-115 |
197 | if (!v.isValid()) evaluated: !v.isValid() yes Evaluation Count:18 | yes Evaluation Count:97 |
| 18-97 |
198 | v = QVariant(editor->property(n).userType(), (const void *)0); executed: v = QVariant(editor->property(n).userType(), (const void *)0); Execution Count:18 | 18 |
199 | editor->setProperty(n, v); | - |
200 | } executed: } Execution Count:115 | 115 |
201 | | - |
202 | } executed: } Execution Count:115 | 115 |
203 | void QStyledItemDelegate::setModelData(QWidget *editor, | - |
204 | QAbstractItemModel *model, | - |
205 | const QModelIndex &index) const | - |
206 | { | - |
207 | | - |
208 | | - |
209 | | - |
210 | | - |
211 | | - |
212 | const QStyledItemDelegatePrivate * const d = d_func(); | - |
213 | qt_noop(); | - |
214 | qt_noop(); | - |
215 | QByteArray n = editor->metaObject()->userProperty().name(); | - |
216 | if (n.isEmpty()) partially evaluated: n.isEmpty() no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
217 | n = d->editorFactory()->valuePropertyName( | 0 |
218 | model->data(index, Qt::EditRole).userType()); never executed: n = d->editorFactory()->valuePropertyName( model->data(index, Qt::EditRole).userType()); | 0 |
219 | if (!n.isEmpty()) partially evaluated: !n.isEmpty() yes Evaluation Count:40 | no Evaluation Count:0 |
| 0-40 |
220 | model->setData(index, editor->property(n), Qt::EditRole); executed: model->setData(index, editor->property(n), Qt::EditRole); Execution Count:40 | 40 |
221 | | - |
222 | } executed: } Execution Count:40 | 40 |
223 | | - |
224 | | - |
225 | | - |
226 | | - |
227 | | - |
228 | void QStyledItemDelegate::updateEditorGeometry(QWidget *editor, | - |
229 | const QStyleOptionViewItem &option, | - |
230 | const QModelIndex &index) const | - |
231 | { | - |
232 | if (!editor) partially evaluated: !editor no Evaluation Count:0 | yes Evaluation Count:111 |
| 0-111 |
233 | return; | 0 |
234 | qt_noop(); | - |
235 | const QWidget *widget = QStyledItemDelegatePrivate::widget(option); | - |
236 | | - |
237 | QStyleOptionViewItem opt = option; | - |
238 | initStyleOption(&opt, index); | - |
239 | | - |
240 | | - |
241 | | - |
242 | | - |
243 | if (qobject_cast<QExpandingLineEdit*>(editor) && !qobject_cast<const QTableView*>(widget)) evaluated: qobject_cast<QExpandingLineEdit*>(editor) yes Evaluation Count:86 | yes Evaluation Count:25 |
evaluated: !qobject_cast<const QTableView*>(widget) yes Evaluation Count:59 | yes Evaluation Count:27 |
| 25-86 |
244 | opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, editor); executed: opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, editor); Execution Count:59 | 59 |
245 | else | - |
246 | | - |
247 | opt.showDecorationSelected = true; executed: opt.showDecorationSelected = true; Execution Count:52 | 52 |
248 | | - |
249 | QStyle *style = widget ? widget->style() : QApplication::style(); partially evaluated: widget yes Evaluation Count:111 | no Evaluation Count:0 |
| 0-111 |
250 | QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &opt, widget); | - |
251 | if ( editor->layoutDirection() == Qt::RightToLeft) { partially evaluated: editor->layoutDirection() == Qt::RightToLeft no Evaluation Count:0 | yes Evaluation Count:111 |
| 0-111 |
252 | const int delta = qSmartMinSize(editor).width() - geom.width(); | - |
253 | if (delta > 0) { never evaluated: delta > 0 | 0 |
254 | | - |
255 | geom.adjust(-delta, 0, 0, 0); | - |
256 | } | 0 |
257 | } | 0 |
258 | | - |
259 | editor->setGeometry(geom); | - |
260 | } executed: } Execution Count:111 | 111 |
261 | | - |
262 | | - |
263 | | - |
264 | | - |
265 | | - |
266 | | - |
267 | | - |
268 | QItemEditorFactory *QStyledItemDelegate::itemEditorFactory() const | - |
269 | { | - |
270 | const QStyledItemDelegatePrivate * const d = d_func(); | - |
271 | return d->factory; never executed: return d->factory; | 0 |
272 | } | - |
273 | void QStyledItemDelegate::setItemEditorFactory(QItemEditorFactory *factory) | - |
274 | { | - |
275 | QStyledItemDelegatePrivate * const d = d_func(); | - |
276 | d->factory = factory; | - |
277 | } | 0 |
278 | bool QStyledItemDelegate::eventFilter(QObject *object, QEvent *event) | - |
279 | { | - |
280 | QWidget *editor = qobject_cast<QWidget*>(object); | - |
281 | if (!editor) partially evaluated: !editor no Evaluation Count:0 | yes Evaluation Count:952 |
| 0-952 |
282 | return false; never executed: return false; | 0 |
283 | if (event->type() == QEvent::KeyPress) { evaluated: event->type() == QEvent::KeyPress yes Evaluation Count:31 | yes Evaluation Count:921 |
| 31-921 |
284 | switch (static_cast<QKeyEvent *>(event)->key()) { | - |
285 | case Qt::Key_Tab: | - |
286 | commitData(editor); | - |
287 | closeEditor(editor, QAbstractItemDelegate::EditNextItem); | - |
288 | return true; never executed: return true; | 0 |
289 | case Qt::Key_Backtab: | - |
290 | commitData(editor); | - |
291 | closeEditor(editor, QAbstractItemDelegate::EditPreviousItem); | - |
292 | return true; never executed: return true; | 0 |
293 | case Qt::Key_Enter: | - |
294 | case Qt::Key_Return: | - |
295 | | - |
296 | if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor)) partially evaluated: qobject_cast<QTextEdit *>(editor) no Evaluation Count:0 | yes Evaluation Count:12 |
partially evaluated: qobject_cast<QPlainTextEdit *>(editor) no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
297 | return false; never executed: return false; | 0 |
298 | | - |
299 | | - |
300 | | - |
301 | | - |
302 | | - |
303 | if (QLineEdit *e = qobject_cast<QLineEdit*>(editor)) evaluated: QLineEdit *e = qobject_cast<QLineEdit*>(editor) yes Evaluation Count:11 | yes Evaluation Count:1 |
| 1-11 |
304 | if (!e->hasAcceptableInput()) partially evaluated: !e->hasAcceptableInput() no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
305 | return false; never executed: return false; | 0 |
306 | | - |
307 | QMetaObject::invokeMethod(this, "_q_commitDataAndCloseEditor", | - |
308 | Qt::QueuedConnection, QArgument<QWidget* >("QWidget*", editor)); | - |
309 | return false; executed: return false; Execution Count:12 | 12 |
310 | case Qt::Key_Escape: | - |
311 | | - |
312 | closeEditor(editor, QAbstractItemDelegate::RevertModelCache); | - |
313 | break; | 0 |
314 | default: | - |
315 | return false; executed: return false; Execution Count:19 | 19 |
316 | } | - |
317 | if (editor->parentWidget()) never evaluated: editor->parentWidget() | 0 |
318 | editor->parentWidget()->setFocus(); never executed: editor->parentWidget()->setFocus(); | 0 |
319 | return true; never executed: return true; | 0 |
320 | } else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow())) { evaluated: event->type() == QEvent::FocusOut yes Evaluation Count:29 | yes Evaluation Count:892 |
evaluated: event->type() == QEvent::Hide yes Evaluation Count:20 | yes Evaluation Count:872 |
partially evaluated: editor->isWindow() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-892 |
321 | | - |
322 | if (!editor->isActiveWindow() || (QApplication::focusWidget() != editor)) { evaluated: !editor->isActiveWindow() yes Evaluation Count:5 | yes Evaluation Count:24 |
partially evaluated: (QApplication::focusWidget() != editor) yes Evaluation Count:24 | no Evaluation Count:0 |
| 0-24 |
323 | QWidget *w = QApplication::focusWidget(); | - |
324 | while (w) { evaluated: w yes Evaluation Count:24 | yes Evaluation Count:29 |
| 24-29 |
325 | if (w == editor) partially evaluated: w == editor no Evaluation Count:0 | yes Evaluation Count:24 |
| 0-24 |
326 | return false; never executed: return false; | 0 |
327 | w = w->parentWidget(); | - |
328 | } executed: } Execution Count:24 | 24 |
329 | | - |
330 | | - |
331 | | - |
332 | QPlatformDrag *platformDrag = QGuiApplicationPrivate::instance()->platformIntegration()->drag(); | - |
333 | if (platformDrag && platformDrag->currentDrag()) { partially evaluated: platformDrag yes Evaluation Count:29 | no Evaluation Count:0 |
partially evaluated: platformDrag->currentDrag() no Evaluation Count:0 | yes Evaluation Count:29 |
| 0-29 |
334 | return false; never executed: return false; | 0 |
335 | } | - |
336 | | - |
337 | | - |
338 | commitData(editor); | - |
339 | closeEditor(editor, NoHint); | - |
340 | } executed: } Execution Count:29 | 29 |
341 | } else if (event->type() == QEvent::ShortcutOverride) { executed: } Execution Count:29 evaluated: event->type() == QEvent::ShortcutOverride yes Evaluation Count:31 | yes Evaluation Count:861 |
| 29-861 |
342 | if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) { partially evaluated: static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
343 | event->accept(); | - |
344 | return true; never executed: return true; | 0 |
345 | } | - |
346 | } executed: } Execution Count:31 | 31 |
347 | return false; executed: return false; Execution Count:921 | 921 |
348 | } | - |
349 | | - |
350 | | - |
351 | | - |
352 | | - |
353 | bool QStyledItemDelegate::editorEvent(QEvent *event, | - |
354 | QAbstractItemModel *model, | - |
355 | const QStyleOptionViewItem &option, | - |
356 | const QModelIndex &index) | - |
357 | { | - |
358 | qt_noop(); | - |
359 | qt_noop(); | - |
360 | | - |
361 | | - |
362 | Qt::ItemFlags flags = model->flags(index); | - |
363 | if (!(flags & Qt::ItemIsUserCheckable) || !(option.state & QStyle::State_Enabled) evaluated: !(flags & Qt::ItemIsUserCheckable) yes Evaluation Count:1553 | yes Evaluation Count:4327 |
partially evaluated: !(option.state & QStyle::State_Enabled) no Evaluation Count:0 | yes Evaluation Count:4327 |
| 0-4327 |
364 | || !(flags & Qt::ItemIsEnabled)) partially evaluated: !(flags & Qt::ItemIsEnabled) no Evaluation Count:0 | yes Evaluation Count:4327 |
| 0-4327 |
365 | return false; executed: return false; Execution Count:1553 | 1553 |
366 | | - |
367 | | - |
368 | QVariant value = index.data(Qt::CheckStateRole); | - |
369 | if (!value.isValid()) evaluated: !value.isValid() yes Evaluation Count:4325 | yes Evaluation Count:2 |
| 2-4325 |
370 | return false; executed: return false; Execution Count:4325 | 4325 |
371 | | - |
372 | const QWidget *widget = QStyledItemDelegatePrivate::widget(option); | - |
373 | QStyle *style = widget ? widget->style() : QApplication::style(); partially evaluated: widget yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
374 | | - |
375 | | - |
376 | if ((event->type() == QEvent::MouseButtonRelease) evaluated: (event->type() == QEvent::MouseButtonRelease) yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
377 | || (event->type() == QEvent::MouseButtonDblClick) partially evaluated: (event->type() == QEvent::MouseButtonDblClick) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
378 | || (event->type() == QEvent::MouseButtonPress)) { partially evaluated: (event->type() == QEvent::MouseButtonPress) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
379 | QStyleOptionViewItem viewOpt(option); | - |
380 | initStyleOption(&viewOpt, index); | - |
381 | QRect checkRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, widget); | - |
382 | QMouseEvent *me = static_cast<QMouseEvent*>(event); | - |
383 | if (me->button() != Qt::LeftButton || !checkRect.contains(me->pos())) partially evaluated: me->button() != Qt::LeftButton no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: !checkRect.contains(me->pos()) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
384 | return false; never executed: return false; | 0 |
385 | | - |
386 | if ((event->type() == QEvent::MouseButtonPress) evaluated: (event->type() == QEvent::MouseButtonPress) yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
387 | || (event->type() == QEvent::MouseButtonDblClick)) partially evaluated: (event->type() == QEvent::MouseButtonDblClick) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
388 | return true; executed: return true; Execution Count:1 | 1 |
389 | | - |
390 | } else if (event->type() == QEvent::KeyPress) { never evaluated: event->type() == QEvent::KeyPress executed: } Execution Count:1 | 0-1 |
391 | if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space never evaluated: static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space | 0 |
392 | && static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select) never evaluated: static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select | 0 |
393 | return false; never executed: return false; | 0 |
394 | } else { | 0 |
395 | return false; never executed: return false; | 0 |
396 | } | - |
397 | | - |
398 | Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked partially evaluated: static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
399 | ? Qt::Unchecked : Qt::Checked); | - |
400 | return model->setData(index, state, Qt::CheckStateRole); executed: return model->setData(index, state, Qt::CheckStateRole); Execution Count:1 | 1 |
401 | } | - |
402 | | - |
403 | | - |
404 | | - |
405 | | - |
| | |