qitemdelegate.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/itemviews/qitemdelegate.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12class QItemDelegatePrivate : public QAbstractItemDelegatePrivate-
13{-
14 inline QItemDelegate* q_func() { return static_cast<QItemDelegate *>(q_ptr); } inline const QItemDelegate* q_func() const { return static_cast<const QItemDelegate *>(q_ptr); } friend class QItemDelegate;-
15-
16public:-
17 QItemDelegatePrivate() : f(0), clipPainting(true) {}
never executed: end of block
0
18-
19 inline const QItemEditorFactory *editorFactory() const-
20 { return
never executed: return f ? f : QItemEditorFactory::defaultFactory();
f ? f : QItemEditorFactory::defaultFactory();
never executed: return f ? f : QItemEditorFactory::defaultFactory();
}
0
21-
22 inline QIcon::Mode iconMode(QStyle::State state) const-
23 {-
24 if (!(state & QStyle::State_Enabled)
!(state & QSty...State_Enabled)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return QIcon::Disabled;
QIcon::Disabled;
never executed: return QIcon::Disabled;
0
25 if (state & QStyle::State_Selected
state & QStyle::State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return QIcon::Selected;
QIcon::Selected;
never executed: return QIcon::Selected;
0
26 return
never executed: return QIcon::Normal;
QIcon::Normal;
never executed: return QIcon::Normal;
0
27 }-
28-
29 inline QIcon::State iconState(QStyle::State state) const-
30 { return
never executed: return state & QStyle::State_Open ? QIcon::On : QIcon::Off;
state & QStyle::State_Open ? QIcon::On : QIcon::Off;
never executed: return state & QStyle::State_Open ? QIcon::On : QIcon::Off;
}
0
31-
32 inline static QString replaceNewLine(QString text)-
33 {-
34 const QChar nl = QLatin1Char('\n');-
35 for (int i = 0; i < text.count()
i < text.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
36 if (text.at(i) == nl
text.at(i) == nlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
37 text[i] = QChar::LineSeparator;
never executed: text[i] = QChar::LineSeparator;
0
38 return
never executed: return text;
text;
never executed: return text;
0
39 }-
40-
41 QString valueToText(const QVariant &value, const QStyleOptionViewItem &option) const;-
42-
43 QItemEditorFactory *f;-
44 bool clipPainting;-
45-
46 QRect textLayoutBounds(const QStyleOptionViewItem &options) const;-
47 QSizeF doTextLayout(int lineWidth) const;-
48 mutable QTextLayout textLayout;-
49 mutable QTextOption textOption;-
50-
51 const QWidget *widget(const QStyleOptionViewItem &option) const-
52 {-
53 return
never executed: return option.widget;
option.widget;
never executed: return option.widget;
0
54 }-
55-
56-
57 mutable struct Icon {-
58 QIcon icon;-
59 QIcon::Mode mode;-
60 QIcon::State state;-
61 } tmp;-
62};-
63-
64QRect QItemDelegatePrivate::textLayoutBounds(const QStyleOptionViewItem &option) const-
65{-
66 QRect rect = option.rect;-
67 const bool wrapText = option.features & QStyleOptionViewItem::WrapText;-
68 switch (option.decorationPosition) {-
69 case
never executed: case QStyleOptionViewItem::Left:
QStyleOptionViewItem::Left:
never executed: case QStyleOptionViewItem::Left:
0
70 case
never executed: case QStyleOptionViewItem::Right:
QStyleOptionViewItem::Right:
never executed: case QStyleOptionViewItem::Right:
0
71 rect.setWidth(wrapText && rect.isValid() ? rect.width() : ((2147483647/256)));-
72 break;
never executed: break;
0
73 case
never executed: case QStyleOptionViewItem::Top:
QStyleOptionViewItem::Top:
never executed: case QStyleOptionViewItem::Top:
0
74 case
never executed: case QStyleOptionViewItem::Bottom:
QStyleOptionViewItem::Bottom:
never executed: case QStyleOptionViewItem::Bottom:
0
75 rect.setWidth(wrapText ? option.decorationSize.width() : ((2147483647/256)));-
76 break;
never executed: break;
0
77 }-
78-
79 return
never executed: return rect;
rect;
never executed: return rect;
0
80}-
81-
82QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const-
83{-
84 qreal height = 0;-
85 qreal widthUsed = 0;-
86 textLayout.beginLayout();-
87 while (true) {-
88 QTextLine line = textLayout.createLine();-
89 if (!line.isValid()
!line.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
90 break;
never executed: break;
0
91 line.setLineWidth(lineWidth);-
92 line.setPosition(QPointF(0, height));-
93 height += line.height();-
94 widthUsed = qMax(widthUsed, line.naturalTextWidth());-
95 }
never executed: end of block
0
96 textLayout.endLayout();-
97 return
never executed: return QSizeF(widthUsed, height);
QSizeF(widthUsed, height);
never executed: return QSizeF(widthUsed, height);
0
98}-
99QItemDelegate::QItemDelegate(QObject *parent)-
100 : QAbstractItemDelegate(*new QItemDelegatePrivate(), parent)-
101{-
102-
103}
never executed: end of block
0
104-
105-
106-
107-
108-
109QItemDelegate::~QItemDelegate()-
110{-
111}-
112bool QItemDelegate::hasClipping() const-
113{-
114 const QItemDelegatePrivate * const d = d_func();-
115 return
never executed: return d->clipPainting;
d->clipPainting;
never executed: return d->clipPainting;
0
116}-
117-
118void QItemDelegate::setClipping(bool clip)-
119{-
120 QItemDelegatePrivate * const d = d_func();-
121 d->clipPainting = clip;-
122}
never executed: end of block
0
123-
124QString QItemDelegatePrivate::valueToText(const QVariant &value, const QStyleOptionViewItem &option) const-
125{-
126 return
never executed: return textForRole(Qt::DisplayRole, value, option.locale, 10);
textForRole(Qt::DisplayRole, value, option.locale, 10);
never executed: return textForRole(Qt::DisplayRole, value, option.locale, 10);
0
127}-
128void QItemDelegate::paint(QPainter *painter,-
129 const QStyleOptionViewItem &option,-
130 const QModelIndex &index) const-
131{-
132 const QItemDelegatePrivate * const d = d_func();-
133 ((!(index.isValid())) ? qt_assert("index.isValid()",__FILE__,368) : qt_noop());-
134-
135 QStyleOptionViewItem opt = setOptions(index, option);-
136-
137-
138 painter->save();-
139 if (d->clipPainting
d->clipPaintingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
140 painter->setClipRect(opt.rect);
never executed: painter->setClipRect(opt.rect);
0
141-
142-
143-
144 QVariant value;-
145-
146 QPixmap pixmap;-
147 QRect decorationRect;-
148 value = index.data(Qt::DecorationRole);-
149 if (value.isValid()
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
150-
151 pixmap = decoration(opt, value);-
152 if (value.type() == QVariant::Icon
value.type() == QVariant::IconDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
153 d->tmp.icon = qvariant_cast<QIcon>(value);-
154 d->tmp.mode = d->iconMode(option.state);-
155 d->tmp.state = d->iconState(option.state);-
156 const QSize size = d->tmp.icon.actualSize(option.decorationSize,-
157 d->tmp.mode, d->tmp.state);-
158 decorationRect = QRect(QPoint(0, 0), size);-
159 }
never executed: end of block
else {
0
160 d->tmp.icon = QIcon();-
161 decorationRect = QRect(QPoint(0, 0), pixmap.size());-
162 }
never executed: end of block
0
163 } else {-
164 d->tmp.icon = QIcon();-
165 decorationRect = QRect();-
166 }
never executed: end of block
0
167-
168 QString text;-
169 QRect displayRect;-
170 value = index.data(Qt::DisplayRole);-
171 if (value.isValid()
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& !value.isNull()
!value.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
172 text = d->valueToText(value, opt);-
173 displayRect = textRectangle(painter, d->textLayoutBounds(opt), opt.font, text);-
174 }
never executed: end of block
0
175-
176 QRect checkRect;-
177 Qt::CheckState checkState = Qt::Unchecked;-
178 value = index.data(Qt::CheckStateRole);-
179 if (value.isValid()
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
180 checkState = static_cast<Qt::CheckState>(value.toInt());-
181 checkRect = doCheck(opt, opt.rect, value);-
182 }
never executed: end of block
0
183-
184-
185-
186 doLayout(opt, &checkRect, &decorationRect, &displayRect, false);-
187-
188-
189-
190 drawBackground(painter, opt, index);-
191 drawCheck(painter, opt, checkRect, checkState);-
192 drawDecoration(painter, opt, decorationRect, pixmap);-
193 drawDisplay(painter, opt, displayRect, text);-
194 drawFocus(painter, opt, displayRect);-
195-
196-
197 painter->restore();-
198}
never executed: end of block
0
199QSize QItemDelegate::sizeHint(const QStyleOptionViewItem &option,-
200 const QModelIndex &index) const-
201{-
202 QVariant value = index.data(Qt::SizeHintRole);-
203 if (value.isValid()
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
204 return
never executed: return qvariant_cast<QSize>(value);
qvariant_cast<QSize>(value);
never executed: return qvariant_cast<QSize>(value);
0
205 QRect decorationRect = rect(option, index, Qt::DecorationRole);-
206 QRect displayRect = rect(option, index, Qt::DisplayRole);-
207 QRect checkRect = rect(option, index, Qt::CheckStateRole);-
208-
209 doLayout(option, &checkRect, &decorationRect, &displayRect, true);-
210-
211 return
never executed: return (decorationRect|displayRect|checkRect).size();
(decorationRect|displayRect|checkRect).size();
never executed: return (decorationRect|displayRect|checkRect).size();
0
212}-
213QWidget *QItemDelegate::createEditor(QWidget *parent,-
214 const QStyleOptionViewItem &,-
215 const QModelIndex &index) const-
216{-
217 const QItemDelegatePrivate * const d = d_func();-
218 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
219 return
never executed: return 0;
0;
never executed: return 0;
0
220 const QItemEditorFactory *factory = d->f;-
221 if (factory == 0
factory == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
222 factory = QItemEditorFactory::defaultFactory();
never executed: factory = QItemEditorFactory::defaultFactory();
0
223 QWidget *w = factory->createEditor(index.data(Qt::EditRole).userType(), parent);-
224 if (w
wDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
225 w->setFocusPolicy(Qt::WheelFocus);
never executed: w->setFocusPolicy(Qt::WheelFocus);
0
226 return
never executed: return w;
w;
never executed: return w;
0
227}-
228void QItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const-
229{-
230-
231-
232-
233-
234 QVariant v = index.data(Qt::EditRole);-
235 QByteArray n = editor->metaObject()->userProperty().name();-
236-
237 if (!n.isEmpty()
!n.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
238 if (!v.isValid()
!v.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
239 v = QVariant(editor->property(n).userType(), (const void *)0);
never executed: v = QVariant(editor->property(n).userType(), (const void *)0);
0
240 editor->setProperty(n, v);-
241 }
never executed: end of block
0
242-
243}
never executed: end of block
0
244void QItemDelegate::setModelData(QWidget *editor,-
245 QAbstractItemModel *model,-
246 const QModelIndex &index) const-
247{-
248-
249-
250-
251-
252-
253 const QItemDelegatePrivate * const d = d_func();-
254 ((!(model)) ? qt_assert("model",__FILE__,532) : qt_noop());-
255 ((!(editor)) ? qt_assert("editor",__FILE__,533) : qt_noop());-
256 QByteArray n = editor->metaObject()->userProperty().name();-
257 if (n.isEmpty()
n.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
258 n = d->editorFactory()->valuePropertyName(
never executed: n = d->editorFactory()->valuePropertyName( model->data(index, Qt::EditRole).userType());
0
259 model->data(index, Qt::EditRole).userType());
never executed: n = d->editorFactory()->valuePropertyName( model->data(index, Qt::EditRole).userType());
0
260 if (!n.isEmpty()
!n.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
261 model->setData(index, editor->property(n), Qt::EditRole);
never executed: model->setData(index, editor->property(n), Qt::EditRole);
0
262-
263}
never executed: end of block
0
264-
265-
266-
267-
268-
269-
270void QItemDelegate::updateEditorGeometry(QWidget *editor,-
271 const QStyleOptionViewItem &option,-
272 const QModelIndex &index) const-
273{-
274 if (!editor
!editorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
275 return;
never executed: return;
0
276 ((!(index.isValid())) ? qt_assert("index.isValid()",__FILE__,554) : qt_noop());-
277 QPixmap pixmap = decoration(option, index.data(Qt::DecorationRole));-
278 QString text = QItemDelegatePrivate::replaceNewLine(index.data(Qt::DisplayRole).toString());-
279 QRect pixmapRect = QRect(QPoint(0, 0), option.decorationSize).intersected(pixmap.rect());-
280 QRect textRect = textRectangle(0, option.rect, option.font, text);-
281 QRect checkRect = doCheck(option, textRect, index.data(Qt::CheckStateRole));-
282 QStyleOptionViewItem opt = option;-
283 opt.showDecorationSelected = true;-
284 doLayout(opt, &checkRect, &pixmapRect, &textRect, false);-
285 editor->setGeometry(textRect);-
286}
never executed: end of block
0
287-
288-
289-
290-
291-
292-
293-
294QItemEditorFactory *QItemDelegate::itemEditorFactory() const-
295{-
296 const QItemDelegatePrivate * const d = d_func();-
297 return
never executed: return d->f;
d->f;
never executed: return d->f;
0
298}-
299void QItemDelegate::setItemEditorFactory(QItemEditorFactory *factory)-
300{-
301 QItemDelegatePrivate * const d = d_func();-
302 d->f = factory;-
303}
never executed: end of block
0
304-
305-
306-
307-
308-
309-
310void QItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &option,-
311 const QRect &rect, const QString &text) const-
312{-
313 const QItemDelegatePrivate * const d = d_func();-
314-
315 QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
option.state &...:State_EnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
316 ? QPalette::Normal : QPalette::Disabled;-
317 if (cg == QPalette::Normal
cg == QPalette::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
&& !(option.state & QStyle::State_Active)
!(option.state...:State_Active)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
318 cg = QPalette::Inactive;
never executed: cg = QPalette::Inactive;
0
319 if (option.state & QStyle::State_Selected
option.state &...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
320 painter->fillRect(rect, option.palette.brush(cg, QPalette::Highlight));-
321 painter->setPen(option.palette.color(cg, QPalette::HighlightedText));-
322 }
never executed: end of block
else {
0
323 painter->setPen(option.palette.color(cg, QPalette::Text));-
324 }
never executed: end of block
0
325-
326 if (text.isEmpty()
text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
327 return;
never executed: return;
0
328-
329 if (option.state & QStyle::State_Editing
option.state &...:State_EditingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
330 painter->save();-
331 painter->setPen(option.palette.color(cg, QPalette::Text));-
332 painter->drawRect(rect.adjusted(0, 0, -1, -1));-
333 painter->restore();-
334 }
never executed: end of block
0
335-
336 const QStyleOptionViewItem opt = option;-
337-
338 const QWidget *widget = d->widget(option);-
339 QStyle *style = widget
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
? widget->style() : QApplication::style();
0
340 const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1;-
341 QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0);-
342 const bool wrapText = opt.features & QStyleOptionViewItem::WrapText;-
343 d->textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap);-
344 d->textOption.setTextDirection(option.direction);-
345 d->textOption.setAlignment(QStyle::visualAlignment(option.direction, option.displayAlignment));-
346 d->textLayout.setTextOption(d->textOption);-
347 d->textLayout.setFont(option.font);-
348 d->textLayout.setText(QItemDelegatePrivate::replaceNewLine(text));-
349-
350 QSizeF textLayoutSize = d->doTextLayout(textRect.width());-
351-
352 if (textRect.width() < textLayoutSize.width()
textRect.width...utSize.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
353 || textRect.height() < textLayoutSize.height()
textRect.heigh...tSize.height()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
354 QString elided;-
355 int start = 0;-
356 int end = text.indexOf(QChar::LineSeparator, start);-
357 if (end == -1
end == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
358 elided += option.fontMetrics.elidedText(text, option.textElideMode, textRect.width());-
359 }
never executed: end of block
else {
0
360 while (end != -1
end != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
361 elided += option.fontMetrics.elidedText(text.mid(start, end - start),-
362 option.textElideMode, textRect.width());-
363 elided += QChar::LineSeparator;-
364 start = end + 1;-
365 end = text.indexOf(QChar::LineSeparator, start);-
366 }
never executed: end of block
0
367-
368 elided += option.fontMetrics.elidedText(text.mid(start),-
369 option.textElideMode, textRect.width());-
370 }
never executed: end of block
0
371 d->textLayout.setText(elided);-
372 textLayoutSize = d->doTextLayout(textRect.width());-
373 }
never executed: end of block
0
374-
375 const QSize layoutSize(textRect.width(), int(textLayoutSize.height()));-
376 const QRect layoutRect = QStyle::alignedRect(option.direction, option.displayAlignment,-
377 layoutSize, textRect);-
378-
379 if (!hasClipping()
!hasClipping()Description
TRUEnever evaluated
FALSEnever evaluated
&& (textRect.width() < textLayoutSize.width()
textRect.width...utSize.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
380 || textRect.height() < textLayoutSize.height()
textRect.heigh...tSize.height()Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
381 painter->save();-
382 painter->setClipRect(layoutRect);-
383 d->textLayout.draw(painter, layoutRect.topLeft(), QVector<QTextLayout::FormatRange>(), layoutRect);-
384 painter->restore();-
385 }
never executed: end of block
else {
0
386 d->textLayout.draw(painter, layoutRect.topLeft(), QVector<QTextLayout::FormatRange>(), layoutRect);-
387 }
never executed: end of block
0
388}-
389-
390-
391-
392-
393-
394void QItemDelegate::drawDecoration(QPainter *painter, const QStyleOptionViewItem &option,-
395 const QRect &rect, const QPixmap &pixmap) const-
396{-
397 const QItemDelegatePrivate * const d = d_func();-
398-
399 if (!d->tmp.icon.isNull()
!d->tmp.icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
400 d->tmp.icon.paint(painter, rect, option.decorationAlignment,-
401 d->tmp.mode, d->tmp.state);-
402 return;
never executed: return;
0
403 }-
404-
405 if (pixmap.isNull()
pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
|| !rect.isValid()
!rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
406 return;
never executed: return;
0
407 QPoint p = QStyle::alignedRect(option.direction, option.decorationAlignment,-
408 pixmap.size(), rect).topLeft();-
409 if (option.state & QStyle::State_Selected
option.state &...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
410 QPixmap *pm = selected(pixmap, option.palette, option.state & QStyle::State_Enabled);-
411 painter->drawPixmap(p, *pm);-
412 }
never executed: end of block
else {
0
413 painter->drawPixmap(p, pixmap);-
414 }
never executed: end of block
0
415}-
416-
417-
418-
419-
420-
421-
422void QItemDelegate::drawFocus(QPainter *painter,-
423 const QStyleOptionViewItem &option,-
424 const QRect &rect) const-
425{-
426 const QItemDelegatePrivate * const d = d_func();-
427 if ((
(option.state ...HasFocus) == 0Description
TRUEnever evaluated
FALSEnever evaluated
option.state & QStyle::State_HasFocus) == 0
(option.state ...HasFocus) == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| !rect.isValid()
!rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
428 return;
never executed: return;
0
429 QStyleOptionFocusRect o;-
430 o.QStyleOption::operator=(option);-
431 o.rect = rect;-
432 o.state |= QStyle::State_KeyboardFocusChange;-
433 o.state |= QStyle::State_Item;-
434 QPalette::ColorGroup cg = (
(option.state ...State_Enabled)Description
TRUEnever evaluated
FALSEnever evaluated
option.state & QStyle::State_Enabled)
(option.state ...State_Enabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
435 ? QPalette::Normal : QPalette::Disabled;-
436 o.backgroundColor = option.palette.color(cg, (option.state & QStyle::State_Selected)-
437 ? QPalette::Highlight : QPalette::Window);-
438 const QWidget *widget = d->widget(option);-
439 QStyle *style = widget
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
? widget->style() : QApplication::style();
0
440 style->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter, widget);-
441}
never executed: end of block
0
442-
443-
444-
445-
446-
447-
448-
449void QItemDelegate::drawCheck(QPainter *painter,-
450 const QStyleOptionViewItem &option,-
451 const QRect &rect, Qt::CheckState state) const-
452{-
453 const QItemDelegatePrivate * const d = d_func();-
454 if (!rect.isValid()
!rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
455 return;
never executed: return;
0
456-
457 QStyleOptionViewItem opt(option);-
458 opt.rect = rect;-
459 opt.state = opt.state & ~QStyle::State_HasFocus;-
460-
461 switch (state) {-
462 case
never executed: case Qt::Unchecked:
Qt::Unchecked:
never executed: case Qt::Unchecked:
0
463 opt.state |= QStyle::State_Off;-
464 break;
never executed: break;
0
465 case
never executed: case Qt::PartiallyChecked:
Qt::PartiallyChecked:
never executed: case Qt::PartiallyChecked:
0
466 opt.state |= QStyle::State_NoChange;-
467 break;
never executed: break;
0
468 case
never executed: case Qt::Checked:
Qt::Checked:
never executed: case Qt::Checked:
0
469 opt.state |= QStyle::State_On;-
470 break;
never executed: break;
0
471 }-
472-
473 const QWidget *widget = d->widget(option);-
474 QStyle *style = widget
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
? widget->style() : QApplication::style();
0
475 style->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &opt, painter, widget);-
476}
never executed: end of block
0
477void QItemDelegate::drawBackground(QPainter *painter,-
478 const QStyleOptionViewItem &option,-
479 const QModelIndex &index) const-
480{-
481 if (option.showDecorationSelected
option.showDecorationSelectedDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(option.state ...tate_Selected)Description
TRUEnever evaluated
FALSEnever evaluated
option.state & QStyle::State_Selected)
(option.state ...tate_Selected)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
482 QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
option.state &...:State_EnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
483 ? QPalette::Normal : QPalette::Disabled;-
484 if (cg == QPalette::Normal
cg == QPalette::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
&& !(option.state & QStyle::State_Active)
!(option.state...:State_Active)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
485 cg = QPalette::Inactive;
never executed: cg = QPalette::Inactive;
0
486-
487 painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));-
488 }
never executed: end of block
else {
0
489 QVariant value = index.data(Qt::BackgroundRole);-
490 if (value.canConvert<QBrush>()
value.canConvert<QBrush>()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
491 QPointF oldBO = painter->brushOrigin();-
492 painter->setBrushOrigin(option.rect.topLeft());-
493 painter->fillRect(option.rect, qvariant_cast<QBrush>(value));-
494 painter->setBrushOrigin(oldBO);-
495 }
never executed: end of block
0
496 }
never executed: end of block
0
497}-
498void QItemDelegate::doLayout(const QStyleOptionViewItem &option,-
499 QRect *checkRect, QRect *pixmapRect, QRect *textRect,-
500 bool hint) const-
501{-
502 ((!(checkRect && pixmapRect && textRect)) ? qt_assert("checkRect && pixmapRect && textRect",__FILE__,804) : qt_noop());-
503 const QItemDelegatePrivate * const d = d_func();-
504 const QWidget *widget = d->widget(option);-
505 QStyle *style = widget
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
? widget->style() : QApplication::style();
0
506 const bool hasCheck = checkRect->isValid();-
507 const bool hasPixmap = pixmapRect->isValid();-
508 const bool hasText = textRect->isValid();-
509 const int textMargin = hasText
hasTextDescription
TRUEnever evaluated
FALSEnever evaluated
? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
0
510 const int pixmapMargin = hasPixmap
hasPixmapDescription
TRUEnever evaluated
FALSEnever evaluated
? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
0
511 const int checkMargin = hasCheck
hasCheckDescription
TRUEnever evaluated
FALSEnever evaluated
? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
0
512 int x = option.rect.left();-
513 int y = option.rect.top();-
514 int w, h;-
515-
516 textRect->adjust(-textMargin, 0, textMargin, 0);-
517 if (textRect->height() == 0
textRect->height() == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& (!hasPixmap
!hasPixmapDescription
TRUEnever evaluated
FALSEnever evaluated
|| !hint
!hintDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
518-
519 textRect->setHeight(option.fontMetrics.height());-
520 }
never executed: end of block
0
521-
522 QSize pm(0, 0);-
523 if (hasPixmap
hasPixmapDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
524 pm = pixmapRect->size();-
525 pm.rwidth() += 2 * pixmapMargin;-
526 }
never executed: end of block
0
527 if (hint
hintDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
528 h = qMax(checkRect->height(), qMax(textRect->height(), pm.height()));-
529 if (option.decorationPosition == QStyleOptionViewItem::Left
option.decorat...ViewItem::LeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
530 || option.decorationPosition == QStyleOptionViewItem::Right
option.decorat...iewItem::RightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
531 w = textRect->width() + pm.width();-
532 }
never executed: end of block
else {
0
533 w = qMax(textRect->width(), pm.width());-
534 }
never executed: end of block
0
535 } else {-
536 w = option.rect.width();-
537 h = option.rect.height();-
538 }
never executed: end of block
0
539-
540 int cw = 0;-
541 QRect check;-
542 if (hasCheck
hasCheckDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
543 cw = checkRect->width() + 2 * checkMargin;-
544 if (hint
hintDescription
TRUEnever evaluated
FALSEnever evaluated
) w += cw;
never executed: w += cw;
0
545 if (option.direction == Qt::RightToLeft
option.directi...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
546 check.setRect(x + w - cw, y, cw, h);-
547 }
never executed: end of block
else {
0
548 check.setRect(x + checkMargin, y, cw, h);-
549 }
never executed: end of block
0
550 }-
551-
552-
553-
554 QRect display;-
555 QRect decoration;-
556 switch (option.decorationPosition) {-
557 case
never executed: case QStyleOptionViewItem::Top:
QStyleOptionViewItem::Top:
never executed: case QStyleOptionViewItem::Top:
{
0
558 if (hasPixmap
hasPixmapDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
559 pm.setHeight(pm.height() + pixmapMargin);
never executed: pm.setHeight(pm.height() + pixmapMargin);
0
560 h = hint
hintDescription
TRUEnever evaluated
FALSEnever evaluated
? textRect->height() : h - pm.height();
0
561-
562 if (option.direction == Qt::RightToLeft
option.directi...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
563 decoration.setRect(x, y, w - cw, pm.height());-
564 display.setRect(x, y + pm.height(), w - cw, h);-
565 }
never executed: end of block
else {
0
566 decoration.setRect(x + cw, y, w - cw, pm.height());-
567 display.setRect(x + cw, y + pm.height(), w - cw, h);-
568 }
never executed: end of block
0
569 break;
never executed: break;
}
0
570 case
never executed: case QStyleOptionViewItem::Bottom:
QStyleOptionViewItem::Bottom:
never executed: case QStyleOptionViewItem::Bottom:
{
0
571 if (hasText
hasTextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
572 textRect->setHeight(textRect->height() + textMargin);
never executed: textRect->setHeight(textRect->height() + textMargin);
0
573 h = hint
hintDescription
TRUEnever evaluated
FALSEnever evaluated
? textRect->height() + pm.height() : h;
0
574-
575 if (option.direction == Qt::RightToLeft
option.directi...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
576 display.setRect(x, y, w - cw, textRect->height());-
577 decoration.setRect(x, y + textRect->height(), w - cw, h - textRect->height());-
578 }
never executed: end of block
else {
0
579 display.setRect(x + cw, y, w - cw, textRect->height());-
580 decoration.setRect(x + cw, y + textRect->height(), w - cw, h - textRect->height());-
581 }
never executed: end of block
0
582 break;
never executed: break;
}
0
583 case
never executed: case QStyleOptionViewItem::Left:
QStyleOptionViewItem::Left:
never executed: case QStyleOptionViewItem::Left:
{
0
584 if (option.direction == Qt::LeftToRight
option.directi...t::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
585 decoration.setRect(x + cw, y, pm.width(), h);-
586 display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h);-
587 }
never executed: end of block
else {
0
588 display.setRect(x, y, w - pm.width() - cw, h);-
589 decoration.setRect(display.right() + 1, y, pm.width(), h);-
590 }
never executed: end of block
0
591 break;
never executed: break;
}
0
592 case
never executed: case QStyleOptionViewItem::Right:
QStyleOptionViewItem::Right:
never executed: case QStyleOptionViewItem::Right:
{
0
593 if (option.direction == Qt::LeftToRight
option.directi...t::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
594 display.setRect(x + cw, y, w - pm.width() - cw, h);-
595 decoration.setRect(display.right() + 1, y, pm.width(), h);-
596 }
never executed: end of block
else {
0
597 decoration.setRect(x, y, pm.width(), h);-
598 display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h);-
599 }
never executed: end of block
0
600 break;
never executed: break;
}
0
601 default
never executed: default:
:
never executed: default:
0
602 QMessageLogger(__FILE__, 904, __PRETTY_FUNCTION__).warning("doLayout: decoration position is invalid");-
603 decoration = *pixmapRect;-
604 break;
never executed: break;
0
605 }-
606-
607 if (!hint
!hintDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
608 *checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,-
609 checkRect->size(), check);-
610 *pixmapRect = QStyle::alignedRect(option.direction, option.decorationAlignment,-
611 pixmapRect->size(), decoration);-
612-
613 if (option.showDecorationSelected
option.showDecorationSelectedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
614 *
never executed: *textRect = display;
textRect = display;
never executed: *textRect = display;
0
615 else-
616 *
never executed: *textRect = QStyle::alignedRect(option.direction, option.displayAlignment, textRect->size().boundedTo(display.size()), display);
textRect = QStyle::alignedRect(option.direction, option.displayAlignment,
never executed: *textRect = QStyle::alignedRect(option.direction, option.displayAlignment, textRect->size().boundedTo(display.size()), display);
0
617 textRect->size().boundedTo(display.size()), display);
never executed: *textRect = QStyle::alignedRect(option.direction, option.displayAlignment, textRect->size().boundedTo(display.size()), display);
0
618 } else {-
619 *checkRect = check;-
620 *pixmapRect = decoration;-
621 *textRect = display;-
622 }
never executed: end of block
0
623}-
624QPixmap QItemDelegate::decoration(const QStyleOptionViewItem &option, const QVariant &variant) const-
625{-
626 const QItemDelegatePrivate * const d = d_func();-
627 switch (variant.type()) {-
628 case
never executed: case QVariant::Icon:
QVariant::Icon:
never executed: case QVariant::Icon:
{
0
629 QIcon::Mode mode = d->iconMode(option.state);-
630 QIcon::State state = d->iconState(option.state);-
631 return
never executed: return qvariant_cast<QIcon>(variant).pixmap(option.decorationSize, mode, state);
qvariant_cast<QIcon>(variant).pixmap(option.decorationSize, mode, state);
never executed: return qvariant_cast<QIcon>(variant).pixmap(option.decorationSize, mode, state);
}
0
632 case
never executed: case QVariant::Color:
QVariant::Color:
never executed: case QVariant::Color:
{
0
633 static QPixmap pixmap(option.decorationSize);-
634 pixmap.fill(qvariant_cast<QColor>(variant));-
635 return
never executed: return pixmap;
pixmap;
never executed: return pixmap;
}
0
636 default
never executed: default:
:
never executed: default:
0
637 break;
never executed: break;
0
638 }-
639-
640 return
never executed: return qvariant_cast<QPixmap>(variant);
qvariant_cast<QPixmap>(variant);
never executed: return qvariant_cast<QPixmap>(variant);
0
641}-
642-
643-
644static QString qPixmapSerial(quint64 i, bool enabled)-
645{-
646 ushort arr[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', ushort('0' + enabled) };-
647 ushort *ptr = &arr[16];-
648-
649 while (i > 0
i > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
650-
651-
652 *(--ptr) = '0' + i % 16;-
653 i >>= 4;-
654 }
never executed: end of block
0
655-
656 return
never executed: return QString((const QChar *)ptr, int(&arr[sizeof(arr) / sizeof(ushort)] - ptr));
QString((const QChar *)ptr, int(&arr[sizeof(arr) / sizeof(ushort)] - ptr));
never executed: return QString((const QChar *)ptr, int(&arr[sizeof(arr) / sizeof(ushort)] - ptr));
0
657}-
658-
659-
660-
661-
662-
663-
664-
665QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const-
666{-
667 QString key = qPixmapSerial(pixmap.cacheKey(), enabled);-
668 QPixmap *pm = QPixmapCache::find(key);-
669 if (!pm
!pmDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
670 QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);-
671-
672 QColor color = palette.color(enabled ? QPalette::Normal : QPalette::Disabled,-
673 QPalette::Highlight);-
674 color.setAlphaF((qreal)0.3);-
675-
676 QPainter painter(&img);-
677 painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);-
678 painter.fillRect(0, 0, img.width(), img.height(), color);-
679 painter.end();-
680-
681 QPixmap selected = QPixmap(QPixmap::fromImage(img));-
682 int n = (img.byteCount() >> 10) + 1;-
683 if (QPixmapCache::cacheLimit() < n
QPixmapCache::cacheLimit() < nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
684 QPixmapCache::setCacheLimit(n);
never executed: QPixmapCache::setCacheLimit(n);
0
685-
686 QPixmapCache::insert(key, selected);-
687 pm = QPixmapCache::find(key);-
688 }
never executed: end of block
0
689 return
never executed: return pm;
pm;
never executed: return pm;
0
690}-
691-
692-
693-
694-
695-
696QRect QItemDelegate::rect(const QStyleOptionViewItem &option,-
697 const QModelIndex &index, int role) const-
698{-
699 const QItemDelegatePrivate * const d = d_func();-
700 QVariant value = index.data(role);-
701 if (role == Qt::CheckStateRole
role == Qt::CheckStateRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
702 return
never executed: return doCheck(option, option.rect, value);
doCheck(option, option.rect, value);
never executed: return doCheck(option, option.rect, value);
0
703 if (value.isValid()
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& !value.isNull()
!value.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
704 switch (value.type()) {-
705 case
never executed: case QVariant::Invalid:
QVariant::Invalid:
never executed: case QVariant::Invalid:
0
706 break;
never executed: break;
0
707 case
never executed: case QVariant::Pixmap:
QVariant::Pixmap:
never executed: case QVariant::Pixmap:
{
0
708 const QPixmap &pixmap = qvariant_cast<QPixmap>(value);-
709 return
never executed: return QRect(QPoint(0, 0), pixmap.size() / pixmap.devicePixelRatio() );
QRect(QPoint(0, 0), pixmap.size() / pixmap.devicePixelRatio() );
never executed: return QRect(QPoint(0, 0), pixmap.size() / pixmap.devicePixelRatio() );
}
0
710 case
never executed: case QVariant::Image:
QVariant::Image:
never executed: case QVariant::Image:
{
0
711 const QImage &image = qvariant_cast<QImage>(value);-
712 return
never executed: return QRect(QPoint(0, 0), image.size() / image.devicePixelRatio() );
QRect(QPoint(0, 0), image.size() / image.devicePixelRatio() );
never executed: return QRect(QPoint(0, 0), image.size() / image.devicePixelRatio() );
}
0
713 case
never executed: case QVariant::Icon:
QVariant::Icon:
never executed: case QVariant::Icon:
{
0
714 QIcon::Mode mode = d->iconMode(option.state);-
715 QIcon::State state = d->iconState(option.state);-
716 QIcon icon = qvariant_cast<QIcon>(value);-
717 QSize size = icon.actualSize(option.decorationSize, mode, state);-
718 return
never executed: return QRect(QPoint(0, 0), size);
QRect(QPoint(0, 0), size);
never executed: return QRect(QPoint(0, 0), size);
}
0
719 case
never executed: case QVariant::Color:
QVariant::Color:
never executed: case QVariant::Color:
0
720 return
never executed: return QRect(QPoint(0, 0), option.decorationSize);
QRect(QPoint(0, 0), option.decorationSize);
never executed: return QRect(QPoint(0, 0), option.decorationSize);
0
721 case
never executed: case QVariant::String:
QVariant::String:
never executed: case QVariant::String:
0
722 default
never executed: default:
:
never executed: default:
{
0
723 const QString text = d->valueToText(value, option);-
724 value = index.data(Qt::FontRole);-
725 QFont fnt = qvariant_cast<QFont>(value).resolve(option.font);-
726 return
never executed: return textRectangle(0, d->textLayoutBounds(option), fnt, text);
textRectangle(0, d->textLayoutBounds(option), fnt, text);
never executed: return textRectangle(0, d->textLayoutBounds(option), fnt, text);
}
0
727 }-
728 }-
729 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
730}-
731-
732-
733-
734-
735QRect QItemDelegate::doCheck(const QStyleOptionViewItem &option,-
736 const QRect &bounding, const QVariant &value) const-
737{-
738 if (value.isValid()
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
739 const QItemDelegatePrivate * const d = d_func();-
740 QStyleOptionButton opt;-
741 opt.QStyleOption::operator=(option);-
742 opt.rect = bounding;-
743 const QWidget *widget = d->widget(option);-
744 QStyle *style = widget
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
? widget->style() : QApplication::style();
0
745 return
never executed: return style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, widget);
style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, widget);
never executed: return style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, widget);
0
746 }-
747 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
748}-
749-
750-
751-
752-
753QRect QItemDelegate::textRectangle(QPainter * , const QRect &rect,-
754 const QFont &font, const QString &text) const-
755{-
756 const QItemDelegatePrivate * const d = d_func();-
757 d->textOption.setWrapMode(QTextOption::WordWrap);-
758 d->textLayout.setTextOption(d->textOption);-
759 d->textLayout.setFont(font);-
760 d->textLayout.setText(QItemDelegatePrivate::replaceNewLine(text));-
761 QSizeF fpSize = d->doTextLayout(rect.width());-
762 const QSize size = QSize(qCeil(fpSize.width()), qCeil(fpSize.height()));-
763-
764 const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;-
765 return
never executed: return QRect(0, 0, size.width() + 2 * textMargin, size.height());
QRect(0, 0, size.width() + 2 * textMargin, size.height());
never executed: return QRect(0, 0, size.width() + 2 * textMargin, size.height());
0
766}-
767bool QItemDelegate::eventFilter(QObject *object, QEvent *event)-
768{-
769 QItemDelegatePrivate * const d = d_func();-
770 return
never executed: return d->editorEventFilter(object, event);
d->editorEventFilter(object, event);
never executed: return d->editorEventFilter(object, event);
0
771}-
772-
773-
774-
775-
776-
777bool QItemDelegate::editorEvent(QEvent *event,-
778 QAbstractItemModel *model,-
779 const QStyleOptionViewItem &option,-
780 const QModelIndex &index)-
781{-
782 ((!(event)) ? qt_assert("event",__FILE__,1122) : qt_noop());-
783 ((!(model)) ? qt_assert("model",__FILE__,1123) : qt_noop());-
784-
785-
786 Qt::ItemFlags flags = model->flags(index);-
787 if (!(flags & Qt::ItemIsUserCheckable)
!(flags & Qt::...UserCheckable)Description
TRUEnever evaluated
FALSEnever evaluated
|| !(option.state & QStyle::State_Enabled)
!(option.state...State_Enabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
788 || !(flags & Qt::ItemIsEnabled)
!(flags & Qt::ItemIsEnabled)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
789 return
never executed: return false;
false;
never executed: return false;
0
790-
791-
792 QVariant value = index.data(Qt::CheckStateRole);-
793 if (!value.isValid()
!value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
794 return
never executed: return false;
false;
never executed: return false;
0
795-
796-
797 if ((
(event->type()...ButtonRelease)Description
TRUEnever evaluated
FALSEnever evaluated
event->type() == QEvent::MouseButtonRelease)
(event->type()...ButtonRelease)Description
TRUEnever evaluated
FALSEnever evaluated
0
798 || (
(event->type()...uttonDblClick)Description
TRUEnever evaluated
FALSEnever evaluated
event->type() == QEvent::MouseButtonDblClick)
(event->type()...uttonDblClick)Description
TRUEnever evaluated
FALSEnever evaluated
0
799 || (
(event->type()...seButtonPress)Description
TRUEnever evaluated
FALSEnever evaluated
event->type() == QEvent::MouseButtonPress)
(event->type()...seButtonPress)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
800 QRect checkRect = doCheck(option, option.rect, Qt::Checked);-
801 QRect emptyRect;-
802 doLayout(option, &checkRect, &emptyRect, &emptyRect, false);-
803 QMouseEvent *me = static_cast<QMouseEvent*>(event);-
804 if (me->button() != Qt::LeftButton
me->button() != Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
|| !checkRect.contains(me->pos())
!checkRect.contains(me->pos())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
805 return
never executed: return false;
false;
never executed: return false;
0
806-
807-
808 if ((
(event->type()...seButtonPress)Description
TRUEnever evaluated
FALSEnever evaluated
event->type() == QEvent::MouseButtonPress)
(event->type()...seButtonPress)Description
TRUEnever evaluated
FALSEnever evaluated
0
809 || (
(event->type()...uttonDblClick)Description
TRUEnever evaluated
FALSEnever evaluated
event->type() == QEvent::MouseButtonDblClick)
(event->type()...uttonDblClick)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
810 return
never executed: return true;
true;
never executed: return true;
0
811-
812 }
never executed: end of block
else if (event->type() == QEvent::KeyPress
event->type() ...vent::KeyPressDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
813 if (static_cast<
static_cast<QK... Qt::Key_SpaceDescription
TRUEnever evaluated
FALSEnever evaluated
QKeyEvent*>(event)->key() != Qt::Key_Space
static_cast<QK... Qt::Key_SpaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
814 && static_cast<
static_cast<QK...Qt::Key_SelectDescription
TRUEnever evaluated
FALSEnever evaluated
QKeyEvent*>(event)->key() != Qt::Key_Select
static_cast<QK...Qt::Key_SelectDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
815 return
never executed: return false;
false;
never executed: return false;
0
816 }
never executed: end of block
else {
0
817 return
never executed: return false;
false;
never executed: return false;
0
818 }-
819-
820 Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());-
821 if (flags & Qt::ItemIsUserTristate
flags & Qt::ItemIsUserTristateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
822 state = ((Qt::CheckState)((state + 1) % 3));
never executed: state = ((Qt::CheckState)((state + 1) % 3));
0
823 else-
824 state = (
(state == Qt::Checked)Description
TRUEnever evaluated
FALSEnever evaluated
state == Qt::Checked)
(state == Qt::Checked)Description
TRUEnever evaluated
FALSEnever evaluated
? Qt::Unchecked : Qt::Checked;
never executed: state = (state == Qt::Checked) ? Qt::Unchecked : Qt::Checked;
0
825 return
never executed: return model->setData(index, state, Qt::CheckStateRole);
model->setData(index, state, Qt::CheckStateRole);
never executed: return model->setData(index, state, Qt::CheckStateRole);
0
826}-
827-
828-
829-
830-
831-
832QStyleOptionViewItem QItemDelegate::setOptions(const QModelIndex &index,-
833 const QStyleOptionViewItem &option) const-
834{-
835 QStyleOptionViewItem opt = option;-
836-
837-
838 QVariant value = index.data(Qt::FontRole);-
839 if (value.isValid()
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
){
0
840 opt.font = qvariant_cast<QFont>(value).resolve(opt.font);-
841 opt.fontMetrics = QFontMetrics(opt.font);-
842 }
never executed: end of block
0
843-
844-
845 value = index.data(Qt::TextAlignmentRole);-
846 if (value.isValid()
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
847 opt.displayAlignment = Qt::Alignment(value.toInt());
never executed: opt.displayAlignment = Qt::Alignment(value.toInt());
0
848-
849-
850 value = index.data(Qt::ForegroundRole);-
851 if (value.canConvert<QBrush>()
value.canConvert<QBrush>()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
852 opt.palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
never executed: opt.palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
0
853-
854-
855 opt.styleObject = 0;-
856-
857 return
never executed: return opt;
opt;
never executed: return opt;
0
858}-
859-
860-
861-
Switch to Source codePreprocessed file

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