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