itemviews/qitemdelegate.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qitemdelegate.h" -
43 -
44#ifndef QT_NO_ITEMVIEWS -
45#include <qabstractitemmodel.h> -
46#include <qapplication.h> -
47#include <qpa/qplatformintegration.h> -
48#include <qpa/qplatformdrag.h> -
49#include <private/qguiapplication_p.h> -
50#include <qbrush.h> -
51#include <qlineedit.h> -
52#include <qtextedit.h> -
53#include <qplaintextedit.h> -
54#include <qpainter.h> -
55#include <qpalette.h> -
56#include <qpoint.h> -
57#include <qrect.h> -
58#include <qsize.h> -
59#include <qstyle.h> -
60#include <qdatetime.h> -
61#include <qstyleoption.h> -
62#include <qevent.h> -
63#include <qpixmap.h> -
64#include <qbitmap.h> -
65#include <qpixmapcache.h> -
66#include <qitemeditorfactory.h> -
67#include <qmetaobject.h> -
68#include <qtextlayout.h> -
69#include <private/qobject_p.h> -
70#include <private/qdnd_p.h> -
71#include <private/qtextengine_p.h> -
72#include <qdebug.h> -
73#include <qlocale.h> -
74#include <qdialog.h> -
75#include <qmath.h> -
76 -
77#include <limits.h> -
78 -
79#ifndef DBL_DIG -
80# define DBL_DIG 10 -
81#endif -
82 -
83QT_BEGIN_NAMESPACE -
84 -
85class QItemDelegatePrivate : public QObjectPrivate -
86{ -
87 Q_DECLARE_PUBLIC(QItemDelegate) -
88 -
89public: -
90 QItemDelegatePrivate() : f(0), clipPainting(true) {}
executed: }
Execution Count:473
473
91 -
92 inline const QItemEditorFactory *editorFactory() const -
93 { return f ? f : QItemEditorFactory::defaultFactory(); }
executed: return f ? f : QItemEditorFactory::defaultFactory();
Execution Count:3
3
94 -
95 inline QIcon::Mode iconMode(QStyle::State state) const -
96 { -
97 if (!(state & QStyle::State_Enabled)) return QIcon::Disabled;
executed: return QIcon::Disabled;
Execution Count:1
evaluated: !(state & QStyle::State_Enabled)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4141
1-4141
98 if (state & QStyle::State_Selected) return QIcon::Selected;
executed: return QIcon::Selected;
Execution Count:4
evaluated: state & QStyle::State_Selected
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4137
4-4137
99 return QIcon::Normal;
executed: return QIcon::Normal;
Execution Count:4137
4137
100 } -
101 -
102 inline QIcon::State iconState(QStyle::State state) const -
103 { return state & QStyle::State_Open ? QIcon::On : QIcon::Off; }
executed: return state & QStyle::State_Open ? QIcon::On : QIcon::Off;
Execution Count:4142
4142
104 -
105 inline static QString replaceNewLine(QString text) -
106 { -
107 const QChar nl = QLatin1Char('\n');
executed (the execution status of this line is deduced): const QChar nl = QLatin1Char('\n');
-
108 for (int i = 0; i < text.count(); ++i)
evaluated: i < text.count()
TRUEFALSE
yes
Evaluation Count:184311
yes
Evaluation Count:20626
20626-184311
109 if (text.at(i) == nl)
partially evaluated: text.at(i) == nl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:184311
0-184311
110 text[i] = QChar::LineSeparator;
never executed: text[i] = QChar::LineSeparator;
0
111 return text;
executed: return text;
Execution Count:20626
20626
112 } -
113 -
114 static QString valueToText(const QVariant &value, const QStyleOptionViewItem &option); -
115 -
116 void _q_commitDataAndCloseEditor(QWidget *editor); -
117 -
118 QItemEditorFactory *f; -
119 bool clipPainting; -
120 -
121 QRect textLayoutBounds(const QStyleOptionViewItem &options) const; -
122 QSizeF doTextLayout(int lineWidth) const; -
123 mutable QTextLayout textLayout; -
124 mutable QTextOption textOption; -
125 -
126 const QWidget *widget(const QStyleOptionViewItem &option) const -
127 { -
128 return option.widget;
executed: return option.widget;
Execution Count:14240
14240
129 } -
130 -
131 // ### temporary hack until we have QStandardItemDelegate -
132 mutable struct Icon { -
133 QIcon icon; -
134 QIcon::Mode mode; -
135 QIcon::State state; -
136 } tmp; -
137}; -
138 -
139void QItemDelegatePrivate::_q_commitDataAndCloseEditor(QWidget *editor) -
140{ -
141 Q_Q(QItemDelegate);
executed (the execution status of this line is deduced): QItemDelegate * const q = q_func();
-
142 emit q->commitData(editor);
executed (the execution status of this line is deduced): q->commitData(editor);
-
143 emit q->closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
executed (the execution status of this line is deduced): q->closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
-
144}
executed: }
Execution Count:1
1
145 -
146QRect QItemDelegatePrivate::textLayoutBounds(const QStyleOptionViewItem &option) const -
147{ -
148 QRect rect = option.rect;
executed (the execution status of this line is deduced): QRect rect = option.rect;
-
149 const bool wrapText = option.features & QStyleOptionViewItem::WrapText;
executed (the execution status of this line is deduced): const bool wrapText = option.features & QStyleOptionViewItem::WrapText;
-
150 switch (option.decorationPosition) { -
151 case QStyleOptionViewItem::Left: -
152 case QStyleOptionViewItem::Right: -
153 rect.setWidth(wrapText && rect.isValid() ? rect.width() : (QFIXED_MAX));
executed (the execution status of this line is deduced): rect.setWidth(wrapText && rect.isValid() ? rect.width() : ((2147483647/256)));
-
154 break;
executed: break;
Execution Count:9104
9104
155 case QStyleOptionViewItem::Top: -
156 case QStyleOptionViewItem::Bottom: -
157 rect.setWidth(wrapText ? option.decorationSize.width() : (QFIXED_MAX));
never executed (the execution status of this line is deduced): rect.setWidth(wrapText ? option.decorationSize.width() : ((2147483647/256)));
-
158 break;
never executed: break;
0
159 } -
160 -
161 return rect;
executed: return rect;
Execution Count:9104
9104
162} -
163 -
164QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const -
165{ -
166 qreal height = 0;
executed (the execution status of this line is deduced): qreal height = 0;
-
167 qreal widthUsed = 0;
executed (the execution status of this line is deduced): qreal widthUsed = 0;
-
168 textLayout.beginLayout();
executed (the execution status of this line is deduced): textLayout.beginLayout();
-
169 while (true) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:27720
no
Evaluation Count:0
0-27720
170 QTextLine line = textLayout.createLine();
executed (the execution status of this line is deduced): QTextLine line = textLayout.createLine();
-
171 if (!line.isValid())
evaluated: !line.isValid()
TRUEFALSE
yes
Evaluation Count:13860
yes
Evaluation Count:13860
13860
172 break;
executed: break;
Execution Count:13860
13860
173 line.setLineWidth(lineWidth);
executed (the execution status of this line is deduced): line.setLineWidth(lineWidth);
-
174 line.setPosition(QPointF(0, height));
executed (the execution status of this line is deduced): line.setPosition(QPointF(0, height));
-
175 height += line.height();
executed (the execution status of this line is deduced): height += line.height();
-
176 widthUsed = qMax(widthUsed, line.naturalTextWidth());
executed (the execution status of this line is deduced): widthUsed = qMax(widthUsed, line.naturalTextWidth());
-
177 }
executed: }
Execution Count:13860
13860
178 textLayout.endLayout();
executed (the execution status of this line is deduced): textLayout.endLayout();
-
179 return QSizeF(widthUsed, height);
executed: return QSizeF(widthUsed, height);
Execution Count:13860
13860
180} -
181 -
182/*! -
183 \class QItemDelegate -
184 -
185 \brief The QItemDelegate class provides display and editing facilities for -
186 data items from a model. -
187 -
188 \ingroup model-view -
189 \inmodule QtWidgets -
190 -
191 QItemDelegate can be used to provide custom display features and editor -
192 widgets for item views based on QAbstractItemView subclasses. Using a -
193 delegate for this purpose allows the display and editing mechanisms to be -
194 customized and developed independently from the model and view. -
195 -
196 The QItemDelegate class is one of the \l{Model/View Classes} and -
197 is part of Qt's \l{Model/View Programming}{model/view framework}. -
198 Note that QStyledItemDelegate has taken over the job of drawing -
199 Qt's item views. We recommend the use of QStyledItemDelegate when -
200 creating new delegates. -
201 -
202 When displaying items from a custom model in a standard view, it is -
203 often sufficient to simply ensure that the model returns appropriate -
204 data for each of the \l{Qt::ItemDataRole}{roles} that determine the -
205 appearance of items in views. The default delegate used by Qt's -
206 standard views uses this role information to display items in most -
207 of the common forms expected by users. However, it is sometimes -
208 necessary to have even more control over the appearance of items than -
209 the default delegate can provide. -
210 -
211 This class provides default implementations of the functions for -
212 painting item data in a view and editing data from item models. -
213 Default implementations of the paint() and sizeHint() virtual -
214 functions, defined in QAbstractItemDelegate, are provided to -
215 ensure that the delegate implements the correct basic behavior -
216 expected by views. You can reimplement these functions in -
217 subclasses to customize the appearance of items. -
218 -
219 When editing data in an item view, QItemDelegate provides an -
220 editor widget, which is a widget that is placed on top of the view -
221 while editing takes place. Editors are created with a -
222 QItemEditorFactory; a default static instance provided by -
223 QItemEditorFactory is installed on all item delegates. You can set -
224 a custom factory using setItemEditorFactory() or set a new default -
225 factory with QItemEditorFactory::setDefaultFactory(). It is the -
226 data stored in the item model with the Qt::EditRole that is edited. -
227 -
228 Only the standard editing functions for widget-based delegates are -
229 reimplemented here: -
230 -
231 \list -
232 \li createEditor() returns the widget used to change data from the model -
233 and can be reimplemented to customize editing behavior. -
234 \li setEditorData() provides the widget with data to manipulate. -
235 \li updateEditorGeometry() ensures that the editor is displayed correctly -
236 with respect to the item view. -
237 \li setModelData() returns updated data to the model. -
238 \endlist -
239 -
240 The closeEditor() signal indicates that the user has completed editing the data, -
241 and that the editor widget can be destroyed. -
242 -
243 \section1 Standard Roles and Data Types -
244 -
245 The default delegate used by the standard views supplied with Qt -
246 associates each standard role (defined by Qt::ItemDataRole) with certain -
247 data types. Models that return data in these types can influence the -
248 appearance of the delegate as described in the following table. -
249 -
250 \table -
251 \header \li Role \li Accepted Types -
252 \omit -
253 \row \li \l Qt::AccessibleDescriptionRole \li QString -
254 \row \li \l Qt::AccessibleTextRole \li QString -
255 \endomit -
256 \row \li \l Qt::BackgroundRole \li QBrush -
257 \row \li \l Qt::BackgroundColorRole \li QColor (obsolete; use Qt::BackgroundRole instead) -
258 \row \li \l Qt::CheckStateRole \li Qt::CheckState -
259 \row \li \l Qt::DecorationRole \li QIcon, QPixmap and QColor -
260 \row \li \l Qt::DisplayRole \li QString and types with a string representation -
261 \row \li \l Qt::EditRole \li See QItemEditorFactory for details -
262 \row \li \l Qt::FontRole \li QFont -
263 \row \li \l Qt::SizeHintRole \li QSize -
264 \omit -
265 \row \li \l Qt::StatusTipRole \li -
266 \endomit -
267 \row \li \l Qt::TextAlignmentRole \li Qt::Alignment -
268 \row \li \l Qt::ForegroundRole \li QBrush -
269 \row \li \l Qt::TextColorRole \li QColor (obsolete; use Qt::ForegroundRole instead) -
270 \omit -
271 \row \li \l Qt::ToolTipRole -
272 \row \li \l Qt::WhatsThisRole -
273 \endomit -
274 \endtable -
275 -
276 If the default delegate does not allow the level of customization that -
277 you need, either for display purposes or for editing data, it is possible to -
278 subclass QItemDelegate to implement the desired behavior. -
279 -
280 \section1 Subclassing -
281 -
282 When subclassing QItemDelegate to create a delegate that displays items -
283 using a custom renderer, it is important to ensure that the delegate can -
284 render items suitably for all the required states; e.g. selected, -
285 disabled, checked. The documentation for the paint() function contains -
286 some hints to show how this can be achieved. -
287 -
288 You can provide custom editors by using a QItemEditorFactory. The -
289 \l{Color Editor Factory Example} shows how a custom editor can be -
290 made available to delegates with the default item editor -
291 factory. This way, there is no need to subclass QItemDelegate. An -
292 alternative is to reimplement createEditor(), setEditorData(), -
293 setModelData(), and updateEditorGeometry(). This process is -
294 described in the \l{Spin Box Delegate Example}. -
295 -
296 \section1 QStyledItemDelegate vs. QItemDelegate -
297 -
298 Since Qt 4.4, there are two delegate classes: QItemDelegate and -
299 QStyledItemDelegate. However, the default delegate is QStyledItemDelegate. -
300 These two classes are independent alternatives to painting and providing -
301 editors for items in views. The difference between them is that -
302 QStyledItemDelegate uses the current style to paint its items. We therefore -
303 recommend using QStyledItemDelegate as the base class when implementing -
304 custom delegates or when working with Qt style sheets. The code required -
305 for either class should be equal unless the custom delegate needs to use -
306 the style for drawing. -
307 -
308 \sa {Delegate Classes}, QStyledItemDelegate, QAbstractItemDelegate, -
309 {Spin Box Delegate Example}, {Settings Editor Example}, -
310 {Icons Example} -
311*/ -
312 -
313/*! -
314 Constructs an item delegate with the given \a parent. -
315*/ -
316 -
317QItemDelegate::QItemDelegate(QObject *parent) -
318 : QAbstractItemDelegate(*new QItemDelegatePrivate(), parent) -
319{ -
320 -
321}
executed: }
Execution Count:473
473
322 -
323/*! -
324 Destroys the item delegate. -
325*/ -
326 -
327QItemDelegate::~QItemDelegate() -
328{ -
329} -
330 -
331/*! -
332 \property QItemDelegate::clipping -
333 \brief if the delegate should clip the paint events -
334 \since 4.2 -
335 -
336 This property will set the paint clip to the size of the item. -
337 The default value is on. It is useful for cases such -
338 as when images are larger than the size of the item. -
339*/ -
340 -
341bool QItemDelegate::hasClipping() const -
342{ -
343 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
344 return d->clipPainting;
executed: return d->clipPainting;
Execution Count:4742
4742
345} -
346 -
347void QItemDelegate::setClipping(bool clip) -
348{ -
349 Q_D(QItemDelegate);
executed (the execution status of this line is deduced): QItemDelegatePrivate * const d = d_func();
-
350 d->clipPainting = clip;
executed (the execution status of this line is deduced): d->clipPainting = clip;
-
351}
executed: }
Execution Count:2
2
352 -
353QString QItemDelegatePrivate::valueToText(const QVariant &value, const QStyleOptionViewItem &option) -
354{ -
355 QString text;
executed (the execution status of this line is deduced): QString text;
-
356 switch (value.userType()) { -
357 case QMetaType::Float: -
358 text = option.locale.toString(value.toFloat(), 'g');
never executed (the execution status of this line is deduced): text = option.locale.toString(value.toFloat(), 'g');
-
359 break;
never executed: break;
0
360 case QVariant::Double: -
361 text = option.locale.toString(value.toDouble(), 'g', DBL_DIG);
executed (the execution status of this line is deduced): text = option.locale.toString(value.toDouble(), 'g', 10);
-
362 break;
executed: break;
Execution Count:1
1
363 case QVariant::Int: -
364 case QVariant::LongLong: -
365 text = option.locale.toString(value.toLongLong());
executed (the execution status of this line is deduced): text = option.locale.toString(value.toLongLong());
-
366 break;
executed: break;
Execution Count:2352
2352
367 case QVariant::UInt: -
368 case QVariant::ULongLong: -
369 text = option.locale.toString(value.toULongLong());
never executed (the execution status of this line is deduced): text = option.locale.toString(value.toULongLong());
-
370 break;
never executed: break;
0
371 case QVariant::Date: -
372 text = option.locale.toString(value.toDate(), QLocale::ShortFormat);
never executed (the execution status of this line is deduced): text = option.locale.toString(value.toDate(), QLocale::ShortFormat);
-
373 break;
never executed: break;
0
374 case QVariant::Time: -
375 text = option.locale.toString(value.toTime(), QLocale::ShortFormat);
never executed (the execution status of this line is deduced): text = option.locale.toString(value.toTime(), QLocale::ShortFormat);
-
376 break;
never executed: break;
0
377 case QVariant::DateTime: -
378 text = option.locale.toString(value.toDateTime().date(), QLocale::ShortFormat);
never executed (the execution status of this line is deduced): text = option.locale.toString(value.toDateTime().date(), QLocale::ShortFormat);
-
379 text += QLatin1Char(' ');
never executed (the execution status of this line is deduced): text += QLatin1Char(' ');
-
380 text += option.locale.toString(value.toDateTime().time(), QLocale::ShortFormat);
never executed (the execution status of this line is deduced): text += option.locale.toString(value.toDateTime().time(), QLocale::ShortFormat);
-
381 break;
never executed: break;
0
382 default: -
383 text = replaceNewLine(value.toString());
executed (the execution status of this line is deduced): text = replaceNewLine(value.toString());
-
384 break;
executed: break;
Execution Count:6751
6751
385 } -
386 return text;
executed: return text;
Execution Count:9104
9104
387} -
388 -
389/*! -
390 Renders the delegate using the given \a painter and style \a option for -
391 the item specified by \a index. -
392 -
393 When reimplementing this function in a subclass, you should update the area -
394 held by the option's \l{QStyleOption::rect}{rect} variable, using the -
395 option's \l{QStyleOption::state}{state} variable to determine the state of -
396 the item to be displayed, and adjust the way it is painted accordingly. -
397 -
398 For example, a selected item may need to be displayed differently to -
399 unselected items, as shown in the following code: -
400 -
401 \snippet itemviews/pixelator/pixeldelegate.cpp 2 -
402 \dots -
403 -
404 After painting, you should ensure that the painter is returned to its -
405 the state it was supplied in when this function was called. For example, -
406 it may be useful to call QPainter::save() before painting and -
407 QPainter::restore() afterwards. -
408 -
409 \sa QStyle::State -
410*/ -
411void QItemDelegate::paint(QPainter *painter, -
412 const QStyleOptionViewItem &option, -
413 const QModelIndex &index) const -
414{ -
415 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
416 Q_ASSERT(index.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
417 -
418 QStyleOptionViewItem opt = setOptions(index, option);
executed (the execution status of this line is deduced): QStyleOptionViewItem opt = setOptions(index, option);
-
419 -
420 // prepare -
421 painter->save();
executed (the execution status of this line is deduced): painter->save();
-
422 if (d->clipPainting)
partially evaluated: d->clipPainting
TRUEFALSE
yes
Evaluation Count:4850
no
Evaluation Count:0
0-4850
423 painter->setClipRect(opt.rect);
executed: painter->setClipRect(opt.rect);
Execution Count:4850
4850
424 -
425 // get the data and the rectangles -
426 -
427 QVariant value;
executed (the execution status of this line is deduced): QVariant value;
-
428 -
429 QPixmap pixmap;
executed (the execution status of this line is deduced): QPixmap pixmap;
-
430 QRect decorationRect;
executed (the execution status of this line is deduced): QRect decorationRect;
-
431 value = index.data(Qt::DecorationRole);
executed (the execution status of this line is deduced): value = index.data(Qt::DecorationRole);
-
432 if (value.isValid()) {
evaluated: value.isValid()
TRUEFALSE
yes
Evaluation Count:82
yes
Evaluation Count:4768
82-4768
433 // ### we need the pixmap to call the virtual function -
434 pixmap = decoration(opt, value);
executed (the execution status of this line is deduced): pixmap = decoration(opt, value);
-
435 if (value.type() == QVariant::Icon) {
evaluated: value.type() == QVariant::Icon
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:3
3-79
436 d->tmp.icon = qvariant_cast<QIcon>(value);
executed (the execution status of this line is deduced): d->tmp.icon = qvariant_cast<QIcon>(value);
-
437 d->tmp.mode = d->iconMode(option.state);
executed (the execution status of this line is deduced): d->tmp.mode = d->iconMode(option.state);
-
438 d->tmp.state = d->iconState(option.state);
executed (the execution status of this line is deduced): d->tmp.state = d->iconState(option.state);
-
439 const QSize size = d->tmp.icon.actualSize(option.decorationSize,
executed (the execution status of this line is deduced): const QSize size = d->tmp.icon.actualSize(option.decorationSize,
-
440 d->tmp.mode, d->tmp.state);
executed (the execution status of this line is deduced): d->tmp.mode, d->tmp.state);
-
441 decorationRect = QRect(QPoint(0, 0), size);
executed (the execution status of this line is deduced): decorationRect = QRect(QPoint(0, 0), size);
-
442 } else {
executed: }
Execution Count:79
79
443 d->tmp.icon = QIcon();
executed (the execution status of this line is deduced): d->tmp.icon = QIcon();
-
444 decorationRect = QRect(QPoint(0, 0), pixmap.size());
executed (the execution status of this line is deduced): decorationRect = QRect(QPoint(0, 0), pixmap.size());
-
445 }
executed: }
Execution Count:3
3
446 } else { -
447 d->tmp.icon = QIcon();
executed (the execution status of this line is deduced): d->tmp.icon = QIcon();
-
448 decorationRect = QRect();
executed (the execution status of this line is deduced): decorationRect = QRect();
-
449 }
executed: }
Execution Count:4768
4768
450 -
451 QString text;
executed (the execution status of this line is deduced): QString text;
-
452 QRect displayRect;
executed (the execution status of this line is deduced): QRect displayRect;
-
453 value = index.data(Qt::DisplayRole);
executed (the execution status of this line is deduced): value = index.data(Qt::DisplayRole);
-
454 if (value.isValid() && !value.isNull()) {
evaluated: value.isValid()
TRUEFALSE
yes
Evaluation Count:4790
yes
Evaluation Count:60
evaluated: !value.isNull()
TRUEFALSE
yes
Evaluation Count:4741
yes
Evaluation Count:49
49-4790
455 text = QItemDelegatePrivate::valueToText(value, opt);
executed (the execution status of this line is deduced): text = QItemDelegatePrivate::valueToText(value, opt);
-
456 displayRect = textRectangle(painter, d->textLayoutBounds(opt), opt.font, text);
executed (the execution status of this line is deduced): displayRect = textRectangle(painter, d->textLayoutBounds(opt), opt.font, text);
-
457 }
executed: }
Execution Count:4741
4741
458 -
459 QRect checkRect;
executed (the execution status of this line is deduced): QRect checkRect;
-
460 Qt::CheckState checkState = Qt::Unchecked;
executed (the execution status of this line is deduced): Qt::CheckState checkState = Qt::Unchecked;
-
461 value = index.data(Qt::CheckStateRole);
executed (the execution status of this line is deduced): value = index.data(Qt::CheckStateRole);
-
462 if (value.isValid()) {
evaluated: value.isValid()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4844
6-4844
463 checkState = static_cast<Qt::CheckState>(value.toInt());
executed (the execution status of this line is deduced): checkState = static_cast<Qt::CheckState>(value.toInt());
-
464 checkRect = doCheck(opt, opt.rect, value);
executed (the execution status of this line is deduced): checkRect = doCheck(opt, opt.rect, value);
-
465 }
executed: }
Execution Count:6
6
466 -
467 // do the layout -
468 -
469 doLayout(opt, &checkRect, &decorationRect, &displayRect, false);
executed (the execution status of this line is deduced): doLayout(opt, &checkRect, &decorationRect, &displayRect, false);
-
470 -
471 // draw the item -
472 -
473 drawBackground(painter, opt, index);
executed (the execution status of this line is deduced): drawBackground(painter, opt, index);
-
474 drawCheck(painter, opt, checkRect, checkState);
executed (the execution status of this line is deduced): drawCheck(painter, opt, checkRect, checkState);
-
475 drawDecoration(painter, opt, decorationRect, pixmap);
executed (the execution status of this line is deduced): drawDecoration(painter, opt, decorationRect, pixmap);
-
476 drawDisplay(painter, opt, displayRect, text);
executed (the execution status of this line is deduced): drawDisplay(painter, opt, displayRect, text);
-
477 drawFocus(painter, opt, displayRect);
executed (the execution status of this line is deduced): drawFocus(painter, opt, displayRect);
-
478 -
479 // done -
480 painter->restore();
executed (the execution status of this line is deduced): painter->restore();
-
481}
executed: }
Execution Count:4850
4850
482 -
483/*! -
484 Returns the size needed by the delegate to display the item -
485 specified by \a index, taking into account the style information -
486 provided by \a option. -
487 -
488 When reimplementing this function, note that in case of text -
489 items, QItemDelegate adds a margin (i.e. 2 * -
490 QStyle::PM_FocusFrameHMargin) to the length of the text. -
491*/ -
492 -
493QSize QItemDelegate::sizeHint(const QStyleOptionViewItem &option, -
494 const QModelIndex &index) const -
495{ -
496 QVariant value = index.data(Qt::SizeHintRole);
executed (the execution status of this line is deduced): QVariant value = index.data(Qt::SizeHintRole);
-
497 if (value.isValid())
partially evaluated: value.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4402
0-4402
498 return qvariant_cast<QSize>(value);
never executed: return qvariant_cast<QSize>(value);
0
499 QRect decorationRect = rect(option, index, Qt::DecorationRole);
executed (the execution status of this line is deduced): QRect decorationRect = rect(option, index, Qt::DecorationRole);
-
500 QRect displayRect = rect(option, index, Qt::DisplayRole);
executed (the execution status of this line is deduced): QRect displayRect = rect(option, index, Qt::DisplayRole);
-
501 QRect checkRect = rect(option, index, Qt::CheckStateRole);
executed (the execution status of this line is deduced): QRect checkRect = rect(option, index, Qt::CheckStateRole);
-
502 -
503 doLayout(option, &checkRect, &decorationRect, &displayRect, true);
executed (the execution status of this line is deduced): doLayout(option, &checkRect, &decorationRect, &displayRect, true);
-
504 -
505 return (decorationRect|displayRect|checkRect).size();
executed: return (decorationRect|displayRect|checkRect).size();
Execution Count:4402
4402
506} -
507 -
508/*! -
509 Returns the widget used to edit the item specified by \a index -
510 for editing. The \a parent widget and style \a option are used to -
511 control how the editor widget appears. -
512 -
513 \sa QAbstractItemDelegate::createEditor() -
514*/ -
515 -
516QWidget *QItemDelegate::createEditor(QWidget *parent, -
517 const QStyleOptionViewItem &, -
518 const QModelIndex &index) const -
519{ -
520 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
521 if (!index.isValid())
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
522 return 0;
never executed: return 0;
0
523 const QItemEditorFactory *factory = d->f;
executed (the execution status of this line is deduced): const QItemEditorFactory *factory = d->f;
-
524 if (factory == 0)
partially evaluated: factory == 0
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
525 factory = QItemEditorFactory::defaultFactory();
executed: factory = QItemEditorFactory::defaultFactory();
Execution Count:10
10
526 return factory->createEditor(index.data(Qt::EditRole).userType(), parent);
executed: return factory->createEditor(index.data(Qt::EditRole).userType(), parent);
Execution Count:10
10
527} -
528 -
529/*! -
530 Sets the data to be displayed and edited by the \a editor from the -
531 data model item specified by the model \a index. -
532 -
533 The default implementation stores the data in the \a editor -
534 widget's \l {Qt's Property System} {user property}. -
535 -
536 \sa QMetaProperty::isUser() -
537*/ -
538 -
539void QItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const -
540{ -
541#ifdef QT_NO_PROPERTIES -
542 Q_UNUSED(editor); -
543 Q_UNUSED(index); -
544#else -
545 QVariant v = index.data(Qt::EditRole);
executed (the execution status of this line is deduced): QVariant v = index.data(Qt::EditRole);
-
546 QByteArray n = editor->metaObject()->userProperty().name();
executed (the execution status of this line is deduced): QByteArray n = editor->metaObject()->userProperty().name();
-
547 -
548 if (!n.isEmpty()) {
partially evaluated: !n.isEmpty()
TRUEFALSE
yes
Evaluation Count:69
no
Evaluation Count:0
0-69
549 if (!v.isValid())
evaluated: !v.isValid()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:56
13-56
550 v = QVariant(editor->property(n).userType(), (const void *)0);
executed: v = QVariant(editor->property(n).userType(), (const void *)0);
Execution Count:13
13
551 editor->setProperty(n, v);
executed (the execution status of this line is deduced): editor->setProperty(n, v);
-
552 }
executed: }
Execution Count:69
69
553#endif -
554}
executed: }
Execution Count:69
69
555 -
556/*! -
557 Gets data from the \a editor widget and stores it in the specified -
558 \a model at the item \a index. -
559 -
560 The default implementation gets the value to be stored in the data -
561 model from the \a editor widget's \l {Qt's Property System} {user -
562 property}. -
563 -
564 \sa QMetaProperty::isUser() -
565*/ -
566 -
567void QItemDelegate::setModelData(QWidget *editor, -
568 QAbstractItemModel *model, -
569 const QModelIndex &index) const -
570{ -
571#ifdef QT_NO_PROPERTIES -
572 Q_UNUSED(model); -
573 Q_UNUSED(editor); -
574 Q_UNUSED(index); -
575#else -
576 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
577 Q_ASSERT(model);
executed (the execution status of this line is deduced): qt_noop();
-
578 Q_ASSERT(editor);
executed (the execution status of this line is deduced): qt_noop();
-
579 QByteArray n = editor->metaObject()->userProperty().name();
executed (the execution status of this line is deduced): QByteArray n = editor->metaObject()->userProperty().name();
-
580 if (n.isEmpty())
evaluated: n.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:19
3-19
581 n = d->editorFactory()->valuePropertyName(
executed: n = d->editorFactory()->valuePropertyName( model->data(index, Qt::EditRole).userType());
Execution Count:3
3
582 model->data(index, Qt::EditRole).userType());
executed: n = d->editorFactory()->valuePropertyName( model->data(index, Qt::EditRole).userType());
Execution Count:3
3
583 if (!n.isEmpty())
partially evaluated: !n.isEmpty()
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
0-22
584 model->setData(index, editor->property(n), Qt::EditRole);
executed: model->setData(index, editor->property(n), Qt::EditRole);
Execution Count:22
22
585#endif -
586}
executed: }
Execution Count:22
22
587 -
588/*! -
589 Updates the \a editor for the item specified by \a index -
590 according to the style \a option given. -
591*/ -
592 -
593void QItemDelegate::updateEditorGeometry(QWidget *editor, -
594 const QStyleOptionViewItem &option, -
595 const QModelIndex &index) const -
596{ -
597 if (!editor)
partially evaluated: !editor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
598 return;
never executed: return;
0
599 Q_ASSERT(index.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
600 QPixmap pixmap = decoration(option, index.data(Qt::DecorationRole));
executed (the execution status of this line is deduced): QPixmap pixmap = decoration(option, index.data(Qt::DecorationRole));
-
601 QString text = QItemDelegatePrivate::replaceNewLine(index.data(Qt::DisplayRole).toString());
executed (the execution status of this line is deduced): QString text = QItemDelegatePrivate::replaceNewLine(index.data(Qt::DisplayRole).toString());
-
602 QRect pixmapRect = QRect(QPoint(0, 0), option.decorationSize).intersected(pixmap.rect());
executed (the execution status of this line is deduced): QRect pixmapRect = QRect(QPoint(0, 0), option.decorationSize).intersected(pixmap.rect());
-
603 QRect textRect = textRectangle(0, option.rect, option.font, text);
executed (the execution status of this line is deduced): QRect textRect = textRectangle(0, option.rect, option.font, text);
-
604 QRect checkRect = doCheck(option, textRect, index.data(Qt::CheckStateRole));
executed (the execution status of this line is deduced): QRect checkRect = doCheck(option, textRect, index.data(Qt::CheckStateRole));
-
605 QStyleOptionViewItem opt = option;
executed (the execution status of this line is deduced): QStyleOptionViewItem opt = option;
-
606 opt.showDecorationSelected = true; // let the editor take up all available space
executed (the execution status of this line is deduced): opt.showDecorationSelected = true;
-
607 doLayout(opt, &checkRect, &pixmapRect, &textRect, false);
executed (the execution status of this line is deduced): doLayout(opt, &checkRect, &pixmapRect, &textRect, false);
-
608 editor->setGeometry(textRect);
executed (the execution status of this line is deduced): editor->setGeometry(textRect);
-
609}
executed: }
Execution Count:15
15
610 -
611/*! -
612 Returns the editor factory used by the item delegate. -
613 If no editor factory is set, the function will return null. -
614 -
615 \sa setItemEditorFactory() -
616*/ -
617QItemEditorFactory *QItemDelegate::itemEditorFactory() const -
618{ -
619 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
620 return d->f;
executed: return d->f;
Execution Count:2
2
621} -
622 -
623/*! -
624 Sets the editor factory to be used by the item delegate to be the \a factory -
625 specified. If no editor factory is set, the item delegate will use the -
626 default editor factory. -
627 -
628 \sa itemEditorFactory() -
629*/ -
630void QItemDelegate::setItemEditorFactory(QItemEditorFactory *factory) -
631{ -
632 Q_D(QItemDelegate);
executed (the execution status of this line is deduced): QItemDelegatePrivate * const d = d_func();
-
633 d->f = factory;
executed (the execution status of this line is deduced): d->f = factory;
-
634}
executed: }
Execution Count:2
2
635 -
636/*! -
637 Renders the item view \a text within the rectangle specified by \a rect -
638 using the given \a painter and style \a option. -
639*/ -
640 -
641void QItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, -
642 const QRect &rect, const QString &text) const -
643{ -
644 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
645 -
646 QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
evaluated: option.state & QStyle::State_Enabled
TRUEFALSE
yes
Evaluation Count:4843
yes
Evaluation Count:7
7-4843
647 ? QPalette::Normal : QPalette::Disabled;
executed (the execution status of this line is deduced): ? QPalette::Normal : QPalette::Disabled;
-
648 if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
evaluated: cg == QPalette::Normal
TRUEFALSE
yes
Evaluation Count:4843
yes
Evaluation Count:7
evaluated: !(option.state & QStyle::State_Active)
TRUEFALSE
yes
Evaluation Count:1591
yes
Evaluation Count:3252
7-4843
649 cg = QPalette::Inactive;
executed: cg = QPalette::Inactive;
Execution Count:1591
1591
650 if (option.state & QStyle::State_Selected) {
evaluated: option.state & QStyle::State_Selected
TRUEFALSE
yes
Evaluation Count:61
yes
Evaluation Count:4789
61-4789
651 painter->fillRect(rect, option.palette.brush(cg, QPalette::Highlight));
executed (the execution status of this line is deduced): painter->fillRect(rect, option.palette.brush(cg, QPalette::Highlight));
-
652 painter->setPen(option.palette.color(cg, QPalette::HighlightedText));
executed (the execution status of this line is deduced): painter->setPen(option.palette.color(cg, QPalette::HighlightedText));
-
653 } else {
executed: }
Execution Count:61
61
654 painter->setPen(option.palette.color(cg, QPalette::Text));
executed (the execution status of this line is deduced): painter->setPen(option.palette.color(cg, QPalette::Text));
-
655 }
executed: }
Execution Count:4789
4789
656 -
657 if (text.isEmpty())
evaluated: text.isEmpty()
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:4739
111-4739
658 return;
executed: return;
Execution Count:111
111
659 -
660 if (option.state & QStyle::State_Editing) {
partially evaluated: option.state & QStyle::State_Editing
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4739
0-4739
661 painter->save();
never executed (the execution status of this line is deduced): painter->save();
-
662 painter->setPen(option.palette.color(cg, QPalette::Text));
never executed (the execution status of this line is deduced): painter->setPen(option.palette.color(cg, QPalette::Text));
-
663 painter->drawRect(rect.adjusted(0, 0, -1, -1));
never executed (the execution status of this line is deduced): painter->drawRect(rect.adjusted(0, 0, -1, -1));
-
664 painter->restore();
never executed (the execution status of this line is deduced): painter->restore();
-
665 }
never executed: }
0
666 -
667 const QStyleOptionViewItem opt = option;
executed (the execution status of this line is deduced): const QStyleOptionViewItem opt = option;
-
668 -
669 const QWidget *widget = d->widget(option);
executed (the execution status of this line is deduced): const QWidget *widget = d->widget(option);
-
670 QStyle *style = widget ? widget->style() : QApplication::style();
partially evaluated: widget
TRUEFALSE
yes
Evaluation Count:4739
no
Evaluation Count:0
0-4739
671 const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1;
executed (the execution status of this line is deduced): const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1;
-
672 QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding
executed (the execution status of this line is deduced): QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0);
-
673 const bool wrapText = opt.features & QStyleOptionViewItem::WrapText;
executed (the execution status of this line is deduced): const bool wrapText = opt.features & QStyleOptionViewItem::WrapText;
-
674 d->textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap);
executed (the execution status of this line is deduced): d->textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap);
-
675 d->textOption.setTextDirection(option.direction);
executed (the execution status of this line is deduced): d->textOption.setTextDirection(option.direction);
-
676 d->textOption.setAlignment(QStyle::visualAlignment(option.direction, option.displayAlignment));
executed (the execution status of this line is deduced): d->textOption.setAlignment(QStyle::visualAlignment(option.direction, option.displayAlignment));
-
677 d->textLayout.setTextOption(d->textOption);
executed (the execution status of this line is deduced): d->textLayout.setTextOption(d->textOption);
-
678 d->textLayout.setFont(option.font);
executed (the execution status of this line is deduced): d->textLayout.setFont(option.font);
-
679 d->textLayout.setText(QItemDelegatePrivate::replaceNewLine(text));
executed (the execution status of this line is deduced): d->textLayout.setText(QItemDelegatePrivate::replaceNewLine(text));
-
680 -
681 QSizeF textLayoutSize = d->doTextLayout(textRect.width());
executed (the execution status of this line is deduced): QSizeF textLayoutSize = d->doTextLayout(textRect.width());
-
682 -
683 if (textRect.width() < textLayoutSize.width()
partially evaluated: textRect.width() < textLayoutSize.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4739
0-4739
684 || textRect.height() < textLayoutSize.height()) {
partially evaluated: textRect.height() < textLayoutSize.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4739
0-4739
685 QString elided;
never executed (the execution status of this line is deduced): QString elided;
-
686 int start = 0;
never executed (the execution status of this line is deduced): int start = 0;
-
687 int end = text.indexOf(QChar::LineSeparator, start);
never executed (the execution status of this line is deduced): int end = text.indexOf(QChar::LineSeparator, start);
-
688 if (end == -1) {
never evaluated: end == -1
0
689 elided += option.fontMetrics.elidedText(text, option.textElideMode, textRect.width());
never executed (the execution status of this line is deduced): elided += option.fontMetrics.elidedText(text, option.textElideMode, textRect.width());
-
690 } else {
never executed: }
0
691 while (end != -1) {
never evaluated: end != -1
0
692 elided += option.fontMetrics.elidedText(text.mid(start, end - start),
never executed (the execution status of this line is deduced): elided += option.fontMetrics.elidedText(text.mid(start, end - start),
-
693 option.textElideMode, textRect.width());
never executed (the execution status of this line is deduced): option.textElideMode, textRect.width());
-
694 elided += QChar::LineSeparator;
never executed (the execution status of this line is deduced): elided += QChar::LineSeparator;
-
695 start = end + 1;
never executed (the execution status of this line is deduced): start = end + 1;
-
696 end = text.indexOf(QChar::LineSeparator, start);
never executed (the execution status of this line is deduced): end = text.indexOf(QChar::LineSeparator, start);
-
697 }
never executed: }
0
698 //let's add the last line (after the last QChar::LineSeparator) -
699 elided += option.fontMetrics.elidedText(text.mid(start),
never executed (the execution status of this line is deduced): elided += option.fontMetrics.elidedText(text.mid(start),
-
700 option.textElideMode, textRect.width());
never executed (the execution status of this line is deduced): option.textElideMode, textRect.width());
-
701 }
never executed: }
0
702 d->textLayout.setText(elided);
never executed (the execution status of this line is deduced): d->textLayout.setText(elided);
-
703 textLayoutSize = d->doTextLayout(textRect.width());
never executed (the execution status of this line is deduced): textLayoutSize = d->doTextLayout(textRect.width());
-
704 }
never executed: }
0
705 -
706 const QSize layoutSize(textRect.width(), int(textLayoutSize.height()));
executed (the execution status of this line is deduced): const QSize layoutSize(textRect.width(), int(textLayoutSize.height()));
-
707 const QRect layoutRect = QStyle::alignedRect(option.direction, option.displayAlignment,
executed (the execution status of this line is deduced): const QRect layoutRect = QStyle::alignedRect(option.direction, option.displayAlignment,
-
708 layoutSize, textRect);
executed (the execution status of this line is deduced): layoutSize, textRect);
-
709 // if we still overflow even after eliding the text, enable clipping -
710 if (!hasClipping() && (textRect.width() < textLayoutSize.width()
partially evaluated: !hasClipping()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4739
never evaluated: textRect.width() < textLayoutSize.width()
0-4739
711 || textRect.height() < textLayoutSize.height())) {
never evaluated: textRect.height() < textLayoutSize.height()
0
712 painter->save();
never executed (the execution status of this line is deduced): painter->save();
-
713 painter->setClipRect(layoutRect);
never executed (the execution status of this line is deduced): painter->setClipRect(layoutRect);
-
714 d->textLayout.draw(painter, layoutRect.topLeft(), QVector<QTextLayout::FormatRange>(), layoutRect);
never executed (the execution status of this line is deduced): d->textLayout.draw(painter, layoutRect.topLeft(), QVector<QTextLayout::FormatRange>(), layoutRect);
-
715 painter->restore();
never executed (the execution status of this line is deduced): painter->restore();
-
716 } else {
never executed: }
0
717 d->textLayout.draw(painter, layoutRect.topLeft(), QVector<QTextLayout::FormatRange>(), layoutRect);
executed (the execution status of this line is deduced): d->textLayout.draw(painter, layoutRect.topLeft(), QVector<QTextLayout::FormatRange>(), layoutRect);
-
718 }
executed: }
Execution Count:4739
4739
719} -
720 -
721/*! -
722 Renders the decoration \a pixmap within the rectangle specified by -
723 \a rect using the given \a painter and style \a option. -
724*/ -
725void QItemDelegate::drawDecoration(QPainter *painter, const QStyleOptionViewItem &option, -
726 const QRect &rect, const QPixmap &pixmap) const -
727{ -
728 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
729 // if we have an icon, we ignore the pixmap -
730 if (!d->tmp.icon.isNull()) {
evaluated: !d->tmp.icon.isNull()
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:4771
79-4771
731 d->tmp.icon.paint(painter, rect, option.decorationAlignment,
executed (the execution status of this line is deduced): d->tmp.icon.paint(painter, rect, option.decorationAlignment,
-
732 d->tmp.mode, d->tmp.state);
executed (the execution status of this line is deduced): d->tmp.mode, d->tmp.state);
-
733 return;
executed: return;
Execution Count:79
79
734 } -
735 -
736 if (pixmap.isNull() || !rect.isValid())
evaluated: pixmap.isNull()
TRUEFALSE
yes
Evaluation Count:4768
yes
Evaluation Count:3
partially evaluated: !rect.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-4768
737 return;
executed: return;
Execution Count:4768
4768
738 QPoint p = QStyle::alignedRect(option.direction, option.decorationAlignment,
executed (the execution status of this line is deduced): QPoint p = QStyle::alignedRect(option.direction, option.decorationAlignment,
-
739 pixmap.size(), rect).topLeft();
executed (the execution status of this line is deduced): pixmap.size(), rect).topLeft();
-
740 if (option.state & QStyle::State_Selected) {
partially evaluated: option.state & QStyle::State_Selected
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
741 QPixmap *pm = selected(pixmap, option.palette, option.state & QStyle::State_Enabled);
executed (the execution status of this line is deduced): QPixmap *pm = selected(pixmap, option.palette, option.state & QStyle::State_Enabled);
-
742 painter->drawPixmap(p, *pm);
executed (the execution status of this line is deduced): painter->drawPixmap(p, *pm);
-
743 } else {
executed: }
Execution Count:3
3
744 painter->drawPixmap(p, pixmap);
never executed (the execution status of this line is deduced): painter->drawPixmap(p, pixmap);
-
745 }
never executed: }
0
746} -
747 -
748/*! -
749 Renders the region within the rectangle specified by \a rect, indicating -
750 that it has the focus, using the given \a painter and style \a option. -
751*/ -
752 -
753void QItemDelegate::drawFocus(QPainter *painter, -
754 const QStyleOptionViewItem &option, -
755 const QRect &rect) const -
756{ -
757 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
758 if ((option.state & QStyle::State_HasFocus) == 0 || !rect.isValid())
evaluated: (option.state & QStyle::State_HasFocus) == 0
TRUEFALSE
yes
Evaluation Count:4652
yes
Evaluation Count:198
partially evaluated: !rect.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:198
0-4652
759 return;
executed: return;
Execution Count:4652
4652
760 QStyleOptionFocusRect o;
executed (the execution status of this line is deduced): QStyleOptionFocusRect o;
-
761 o.QStyleOption::operator=(option);
executed (the execution status of this line is deduced): o.QStyleOption::operator=(option);
-
762 o.rect = rect;
executed (the execution status of this line is deduced): o.rect = rect;
-
763 o.state |= QStyle::State_KeyboardFocusChange;
executed (the execution status of this line is deduced): o.state |= QStyle::State_KeyboardFocusChange;
-
764 o.state |= QStyle::State_Item;
executed (the execution status of this line is deduced): o.state |= QStyle::State_Item;
-
765 QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled)
partially evaluated: (option.state & QStyle::State_Enabled)
TRUEFALSE
yes
Evaluation Count:198
no
Evaluation Count:0
0-198
766 ? QPalette::Normal : QPalette::Disabled;
executed (the execution status of this line is deduced): ? QPalette::Normal : QPalette::Disabled;
-
767 o.backgroundColor = option.palette.color(cg, (option.state & QStyle::State_Selected)
executed (the execution status of this line is deduced): o.backgroundColor = option.palette.color(cg, (option.state & QStyle::State_Selected)
-
768 ? QPalette::Highlight : QPalette::Window);
executed (the execution status of this line is deduced): ? QPalette::Highlight : QPalette::Window);
-
769 const QWidget *widget = d->widget(option);
executed (the execution status of this line is deduced): const QWidget *widget = d->widget(option);
-
770 QStyle *style = widget ? widget->style() : QApplication::style();
partially evaluated: widget
TRUEFALSE
yes
Evaluation Count:198
no
Evaluation Count:0
0-198
771 style->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter, widget);
executed (the execution status of this line is deduced): style->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter, widget);
-
772}
executed: }
Execution Count:198
198
773 -
774/*! -
775 Renders a check indicator within the rectangle specified by \a -
776 rect, using the given \a painter and style \a option, using the -
777 given \a state. -
778*/ -
779 -
780void QItemDelegate::drawCheck(QPainter *painter, -
781 const QStyleOptionViewItem &option, -
782 const QRect &rect, Qt::CheckState state) const -
783{ -
784 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
785 if (!rect.isValid())
evaluated: !rect.isValid()
TRUEFALSE
yes
Evaluation Count:4844
yes
Evaluation Count:6
6-4844
786 return;
executed: return;
Execution Count:4844
4844
787 -
788 QStyleOptionViewItem opt(option);
executed (the execution status of this line is deduced): QStyleOptionViewItem opt(option);
-
789 opt.rect = rect;
executed (the execution status of this line is deduced): opt.rect = rect;
-
790 opt.state = opt.state & ~QStyle::State_HasFocus;
executed (the execution status of this line is deduced): opt.state = opt.state & ~QStyle::State_HasFocus;
-
791 -
792 switch (state) { -
793 case Qt::Unchecked: -
794 opt.state |= QStyle::State_Off;
executed (the execution status of this line is deduced): opt.state |= QStyle::State_Off;
-
795 break;
executed: break;
Execution Count:6
6
796 case Qt::PartiallyChecked: -
797 opt.state |= QStyle::State_NoChange;
never executed (the execution status of this line is deduced): opt.state |= QStyle::State_NoChange;
-
798 break;
never executed: break;
0
799 case Qt::Checked: -
800 opt.state |= QStyle::State_On;
never executed (the execution status of this line is deduced): opt.state |= QStyle::State_On;
-
801 break;
never executed: break;
0
802 } -
803 -
804 const QWidget *widget = d->widget(option);
executed (the execution status of this line is deduced): const QWidget *widget = d->widget(option);
-
805 QStyle *style = widget ? widget->style() : QApplication::style();
partially evaluated: widget
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
806 style->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &opt, painter, widget);
executed (the execution status of this line is deduced): style->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &opt, painter, widget);
-
807}
executed: }
Execution Count:6
6
808 -
809/*! -
810 \since 4.2 -
811 -
812 Renders the item background for the given \a index, -
813 using the given \a painter and style \a option. -
814*/ -
815 -
816void QItemDelegate::drawBackground(QPainter *painter, -
817 const QStyleOptionViewItem &option, -
818 const QModelIndex &index) const -
819{ -
820 if (option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
partially evaluated: option.showDecorationSelected
TRUEFALSE
yes
Evaluation Count:4850
no
Evaluation Count:0
evaluated: (option.state & QStyle::State_Selected)
TRUEFALSE
yes
Evaluation Count:61
yes
Evaluation Count:4789
0-4850
821 QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
partially evaluated: option.state & QStyle::State_Enabled
TRUEFALSE
yes
Evaluation Count:61
no
Evaluation Count:0
0-61
822 ? QPalette::Normal : QPalette::Disabled;
executed (the execution status of this line is deduced): ? QPalette::Normal : QPalette::Disabled;
-
823 if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
partially evaluated: cg == QPalette::Normal
TRUEFALSE
yes
Evaluation Count:61
no
Evaluation Count:0
evaluated: !(option.state & QStyle::State_Active)
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:28
0-61
824 cg = QPalette::Inactive;
executed: cg = QPalette::Inactive;
Execution Count:33
33
825 -
826 painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
executed (the execution status of this line is deduced): painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
-
827 } else {
executed: }
Execution Count:61
61
828 QVariant value = index.data(Qt::BackgroundRole);
executed (the execution status of this line is deduced): QVariant value = index.data(Qt::BackgroundRole);
-
829 if (value.canConvert<QBrush>()) {
evaluated: value.canConvert<QBrush>()
TRUEFALSE
yes
Evaluation Count:2706
yes
Evaluation Count:2083
2083-2706
830 QPointF oldBO = painter->brushOrigin();
executed (the execution status of this line is deduced): QPointF oldBO = painter->brushOrigin();
-
831 painter->setBrushOrigin(option.rect.topLeft());
executed (the execution status of this line is deduced): painter->setBrushOrigin(option.rect.topLeft());
-
832 painter->fillRect(option.rect, qvariant_cast<QBrush>(value));
executed (the execution status of this line is deduced): painter->fillRect(option.rect, qvariant_cast<QBrush>(value));
-
833 painter->setBrushOrigin(oldBO);
executed (the execution status of this line is deduced): painter->setBrushOrigin(oldBO);
-
834 }
executed: }
Execution Count:2706
2706
835 }
executed: }
Execution Count:4789
4789
836} -
837 -
838 -
839/*! -
840 \internal -
841 -
842 Code duplicated in QCommonStylePrivate::viewItemLayout -
843*/ -
844 -
845void QItemDelegate::doLayout(const QStyleOptionViewItem &option, -
846 QRect *checkRect, QRect *pixmapRect, QRect *textRect, -
847 bool hint) const -
848{ -
849 Q_ASSERT(checkRect && pixmapRect && textRect);
executed (the execution status of this line is deduced): qt_noop();
-
850 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
851 const QWidget *widget = d->widget(option);
executed (the execution status of this line is deduced): const QWidget *widget = d->widget(option);
-
852 QStyle *style = widget ? widget->style() : QApplication::style();
evaluated: widget
TRUEFALSE
yes
Evaluation Count:9268
yes
Evaluation Count:15
15-9268
853 const bool hasCheck = checkRect->isValid();
executed (the execution status of this line is deduced): const bool hasCheck = checkRect->isValid();
-
854 const bool hasPixmap = pixmapRect->isValid();
executed (the execution status of this line is deduced): const bool hasPixmap = pixmapRect->isValid();
-
855 const bool hasText = textRect->isValid();
executed (the execution status of this line is deduced): const bool hasText = textRect->isValid();
-
856 const int textMargin = hasText ? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
evaluated: hasText
TRUEFALSE
yes
Evaluation Count:9126
yes
Evaluation Count:157
157-9126
857 const int pixmapMargin = hasPixmap ? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
evaluated: hasPixmap
TRUEFALSE
yes
Evaluation Count:4073
yes
Evaluation Count:5210
4073-5210
858 const int checkMargin = hasCheck ? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
evaluated: hasCheck
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:9261
22-9261
859 int x = option.rect.left();
executed (the execution status of this line is deduced): int x = option.rect.left();
-
860 int y = option.rect.top();
executed (the execution status of this line is deduced): int y = option.rect.top();
-
861 int w, h;
executed (the execution status of this line is deduced): int w, h;
-
862 -
863 textRect->adjust(-textMargin, 0, textMargin, 0); // add width padding
executed (the execution status of this line is deduced): textRect->adjust(-textMargin, 0, textMargin, 0);
-
864 if (textRect->height() == 0 && (!hasPixmap || !hint)) {
evaluated: textRect->height() == 0
TRUEFALSE
yes
Evaluation Count:157
yes
Evaluation Count:9126
evaluated: !hasPixmap
TRUEFALSE
yes
Evaluation Count:153
yes
Evaluation Count:4
partially evaluated: !hint
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-9126
865 //if there is no text, we still want to have a decent height for the item sizeHint and the editor size -
866 textRect->setHeight(option.fontMetrics.height());
executed (the execution status of this line is deduced): textRect->setHeight(option.fontMetrics.height());
-
867 }
executed: }
Execution Count:157
157
868 -
869 QSize pm(0, 0);
executed (the execution status of this line is deduced): QSize pm(0, 0);
-
870 if (hasPixmap) {
evaluated: hasPixmap
TRUEFALSE
yes
Evaluation Count:4073
yes
Evaluation Count:5210
4073-5210
871 pm = pixmapRect->size();
executed (the execution status of this line is deduced): pm = pixmapRect->size();
-
872 pm.rwidth() += 2 * pixmapMargin;
executed (the execution status of this line is deduced): pm.rwidth() += 2 * pixmapMargin;
-
873 }
executed: }
Execution Count:4073
4073
874 if (hint) {
evaluated: hint
TRUEFALSE
yes
Evaluation Count:4410
yes
Evaluation Count:4873
4410-4873
875 h = qMax(checkRect->height(), qMax(textRect->height(), pm.height()));
executed (the execution status of this line is deduced): h = qMax(checkRect->height(), qMax(textRect->height(), pm.height()));
-
876 if (option.decorationPosition == QStyleOptionViewItem::Left
evaluated: option.decorationPosition == QStyleOptionViewItem::Left
TRUEFALSE
yes
Evaluation Count:4404
yes
Evaluation Count:6
6-4404
877 || option.decorationPosition == QStyleOptionViewItem::Right) {
evaluated: option.decorationPosition == QStyleOptionViewItem::Right
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
2-4
878 w = textRect->width() + pm.width();
executed (the execution status of this line is deduced): w = textRect->width() + pm.width();
-
879 } else {
executed: }
Execution Count:4406
4406
880 w = qMax(textRect->width(), pm.width());
executed (the execution status of this line is deduced): w = qMax(textRect->width(), pm.width());
-
881 }
executed: }
Execution Count:4
4
882 } else { -
883 w = option.rect.width();
executed (the execution status of this line is deduced): w = option.rect.width();
-
884 h = option.rect.height();
executed (the execution status of this line is deduced): h = option.rect.height();
-
885 }
executed: }
Execution Count:4873
4873
886 -
887 int cw = 0;
executed (the execution status of this line is deduced): int cw = 0;
-
888 QRect check;
executed (the execution status of this line is deduced): QRect check;
-
889 if (hasCheck) {
evaluated: hasCheck
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:9261
22-9261
890 cw = checkRect->width() + 2 * checkMargin;
executed (the execution status of this line is deduced): cw = checkRect->width() + 2 * checkMargin;
-
891 if (hint) w += cw;
executed: w += cw;
Execution Count:8
evaluated: hint
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:14
8-14
892 if (option.direction == Qt::RightToLeft) {
evaluated: option.direction == Qt::RightToLeft
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:18
4-18
893 check.setRect(x + w - cw, y, cw, h);
executed (the execution status of this line is deduced): check.setRect(x + w - cw, y, cw, h);
-
894 } else {
executed: }
Execution Count:4
4
895 check.setRect(x + checkMargin, y, cw, h);
executed (the execution status of this line is deduced): check.setRect(x + checkMargin, y, cw, h);
-
896 }
executed: }
Execution Count:18
18
897 } -
898 -
899 // at this point w should be the *total* width -
900 -
901 QRect display;
executed (the execution status of this line is deduced): QRect display;
-
902 QRect decoration;
executed (the execution status of this line is deduced): QRect decoration;
-
903 switch (option.decorationPosition) { -
904 case QStyleOptionViewItem::Top: { -
905 if (hasPixmap)
partially evaluated: hasPixmap
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
906 pm.setHeight(pm.height() + pixmapMargin); // add space
executed: pm.setHeight(pm.height() + pixmapMargin);
Execution Count:2
2
907 h = hint ? textRect->height() : h - pm.height();
partially evaluated: hint
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
908 -
909 if (option.direction == Qt::RightToLeft) {
evaluated: option.direction == Qt::RightToLeft
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
910 decoration.setRect(x, y, w - cw, pm.height());
executed (the execution status of this line is deduced): decoration.setRect(x, y, w - cw, pm.height());
-
911 display.setRect(x, y + pm.height(), w - cw, h);
executed (the execution status of this line is deduced): display.setRect(x, y + pm.height(), w - cw, h);
-
912 } else {
executed: }
Execution Count:1
1
913 decoration.setRect(x + cw, y, w - cw, pm.height());
executed (the execution status of this line is deduced): decoration.setRect(x + cw, y, w - cw, pm.height());
-
914 display.setRect(x + cw, y + pm.height(), w - cw, h);
executed (the execution status of this line is deduced): display.setRect(x + cw, y + pm.height(), w - cw, h);
-
915 }
executed: }
Execution Count:1
1
916 break; }
executed: break;
Execution Count:2
2
917 case QStyleOptionViewItem::Bottom: { -
918 if (hasText)
partially evaluated: hasText
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
919 textRect->setHeight(textRect->height() + textMargin); // add space
executed: textRect->setHeight(textRect->height() + textMargin);
Execution Count:2
2
920 h = hint ? textRect->height() + pm.height() : h;
partially evaluated: hint
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
921 -
922 if (option.direction == Qt::RightToLeft) {
evaluated: option.direction == Qt::RightToLeft
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
923 display.setRect(x, y, w - cw, textRect->height());
executed (the execution status of this line is deduced): display.setRect(x, y, w - cw, textRect->height());
-
924 decoration.setRect(x, y + textRect->height(), w - cw, h - textRect->height());
executed (the execution status of this line is deduced): decoration.setRect(x, y + textRect->height(), w - cw, h - textRect->height());
-
925 } else {
executed: }
Execution Count:1
1
926 display.setRect(x + cw, y, w - cw, textRect->height());
executed (the execution status of this line is deduced): display.setRect(x + cw, y, w - cw, textRect->height());
-
927 decoration.setRect(x + cw, y + textRect->height(), w - cw, h - textRect->height());
executed (the execution status of this line is deduced): decoration.setRect(x + cw, y + textRect->height(), w - cw, h - textRect->height());
-
928 }
executed: }
Execution Count:1
1
929 break; }
executed: break;
Execution Count:2
2
930 case QStyleOptionViewItem::Left: { -
931 if (option.direction == Qt::LeftToRight) {
evaluated: option.direction == Qt::LeftToRight
TRUEFALSE
yes
Evaluation Count:9276
yes
Evaluation Count:1
1-9276
932 decoration.setRect(x + cw, y, pm.width(), h);
executed (the execution status of this line is deduced): decoration.setRect(x + cw, y, pm.width(), h);
-
933 display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h);
executed (the execution status of this line is deduced): display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h);
-
934 } else {
executed: }
Execution Count:9276
9276
935 display.setRect(x, y, w - pm.width() - cw, h);
executed (the execution status of this line is deduced): display.setRect(x, y, w - pm.width() - cw, h);
-
936 decoration.setRect(display.right() + 1, y, pm.width(), h);
executed (the execution status of this line is deduced): decoration.setRect(display.right() + 1, y, pm.width(), h);
-
937 }
executed: }
Execution Count:1
1
938 break; }
executed: break;
Execution Count:9277
9277
939 case QStyleOptionViewItem::Right: { -
940 if (option.direction == Qt::LeftToRight) {
evaluated: option.direction == Qt::LeftToRight
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
941 display.setRect(x + cw, y, w - pm.width() - cw, h);
executed (the execution status of this line is deduced): display.setRect(x + cw, y, w - pm.width() - cw, h);
-
942 decoration.setRect(display.right() + 1, y, pm.width(), h);
executed (the execution status of this line is deduced): decoration.setRect(display.right() + 1, y, pm.width(), h);
-
943 } else {
executed: }
Execution Count:1
1
944 decoration.setRect(x, y, pm.width(), h);
executed (the execution status of this line is deduced): decoration.setRect(x, y, pm.width(), h);
-
945 display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h);
executed (the execution status of this line is deduced): display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h);
-
946 }
executed: }
Execution Count:1
1
947 break; }
executed: break;
Execution Count:2
2
948 default: -
949 qWarning("doLayout: decoration position is invalid");
never executed (the execution status of this line is deduced): QMessageLogger("itemviews/qitemdelegate.cpp", 949, __PRETTY_FUNCTION__).warning("doLayout: decoration position is invalid");
-
950 decoration = *pixmapRect;
never executed (the execution status of this line is deduced): decoration = *pixmapRect;
-
951 break;
never executed: break;
0
952 } -
953 -
954 if (!hint) { // we only need to do the internal layout if we are going to paint
evaluated: !hint
TRUEFALSE
yes
Evaluation Count:4873
yes
Evaluation Count:4410
4410-4873
955 *checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,
executed (the execution status of this line is deduced): *checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,
-
956 checkRect->size(), check);
executed (the execution status of this line is deduced): checkRect->size(), check);
-
957 *pixmapRect = QStyle::alignedRect(option.direction, option.decorationAlignment,
executed (the execution status of this line is deduced): *pixmapRect = QStyle::alignedRect(option.direction, option.decorationAlignment,
-
958 pixmapRect->size(), decoration);
executed (the execution status of this line is deduced): pixmapRect->size(), decoration);
-
959 // the text takes up all available space, unless the decoration is not shown as selected -
960 if (option.showDecorationSelected)
evaluated: option.showDecorationSelected
TRUEFALSE
yes
Evaluation Count:4865
yes
Evaluation Count:8
8-4865
961 *textRect = display;
executed: *textRect = display;
Execution Count:4865
4865
962 else -
963 *textRect = QStyle::alignedRect(option.direction, option.displayAlignment,
executed: *textRect = QStyle::alignedRect(option.direction, option.displayAlignment, textRect->size().boundedTo(display.size()), display);
Execution Count:8
8
964 textRect->size().boundedTo(display.size()), display);
executed: *textRect = QStyle::alignedRect(option.direction, option.displayAlignment, textRect->size().boundedTo(display.size()), display);
Execution Count:8
8
965 } else { -
966 *checkRect = check;
executed (the execution status of this line is deduced): *checkRect = check;
-
967 *pixmapRect = decoration;
executed (the execution status of this line is deduced): *pixmapRect = decoration;
-
968 *textRect = display;
executed (the execution status of this line is deduced): *textRect = display;
-
969 }
executed: }
Execution Count:4410
4410
970} -
971 -
972/*! -
973 \internal -
974 -
975 Returns the pixmap used to decorate the root of the item view. -
976 The style \a option controls the appearance of the root; the \a variant -
977 refers to the data associated with an item. -
978*/ -
979 -
980QPixmap QItemDelegate::decoration(const QStyleOptionViewItem &option, const QVariant &variant) const -
981{ -
982 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
983 switch (variant.type()) { -
984 case QVariant::Icon: { -
985 QIcon::Mode mode = d->iconMode(option.state);
executed (the execution status of this line is deduced): QIcon::Mode mode = d->iconMode(option.state);
-
986 QIcon::State state = d->iconState(option.state);
executed (the execution status of this line is deduced): QIcon::State state = d->iconState(option.state);
-
987 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
988 case QVariant::Color: { -
989 static QPixmap pixmap(option.decorationSize); -
990 pixmap.fill(qvariant_cast<QColor>(variant));
executed (the execution status of this line is deduced): pixmap.fill(qvariant_cast<QColor>(variant));
-
991 return pixmap; }
executed: return pixmap;
Execution Count:1
1
992 default: -
993 break;
executed: break;
Execution Count:17
17
994 } -
995 -
996 return qvariant_cast<QPixmap>(variant);
executed: return qvariant_cast<QPixmap>(variant);
Execution Count:17
17
997} -
998 -
999// hacky but faster version of "QString::sprintf("%d-%d", i, enabled)" -
1000static QString qPixmapSerial(quint64 i, bool enabled) -
1001{ -
1002 ushort arr[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', ushort('0' + enabled) };
executed (the execution status of this line is deduced): ushort arr[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', ushort('0' + enabled) };
-
1003 ushort *ptr = &arr[16];
executed (the execution status of this line is deduced): ushort *ptr = &arr[16];
-
1004 -
1005 while (i > 0) {
evaluated: i > 0
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:3
3-33
1006 // hey - it's our internal representation, so use the ascii character after '9' -
1007 // instead of 'a' for hex -
1008 *(--ptr) = '0' + i % 16;
executed (the execution status of this line is deduced): *(--ptr) = '0' + i % 16;
-
1009 i >>= 4;
executed (the execution status of this line is deduced): i >>= 4;
-
1010 }
executed: }
Execution Count:33
33
1011 -
1012 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
1013} -
1014 -
1015/*! -
1016 \internal -
1017 Returns the selected version of the given \a pixmap using the given \a palette. -
1018 The \a enabled argument decides whether the normal or disabled highlight color of -
1019 the palette is used. -
1020*/ -
1021QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const -
1022{ -
1023 QString key = qPixmapSerial(pixmap.cacheKey(), enabled);
executed (the execution status of this line is deduced): QString key = qPixmapSerial(pixmap.cacheKey(), enabled);
-
1024 QPixmap *pm = QPixmapCache::find(key);
executed (the execution status of this line is deduced): QPixmap *pm = QPixmapCache::find(key);
-
1025 if (!pm) {
partially evaluated: !pm
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1026 QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
executed (the execution status of this line is deduced): QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
-
1027 -
1028 QColor color = palette.color(enabled ? QPalette::Normal : QPalette::Disabled,
executed (the execution status of this line is deduced): QColor color = palette.color(enabled ? QPalette::Normal : QPalette::Disabled,
-
1029 QPalette::Highlight);
executed (the execution status of this line is deduced): QPalette::Highlight);
-
1030 color.setAlphaF((qreal)0.3);
executed (the execution status of this line is deduced): color.setAlphaF((qreal)0.3);
-
1031 -
1032 QPainter painter(&img);
executed (the execution status of this line is deduced): QPainter painter(&img);
-
1033 painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
executed (the execution status of this line is deduced): painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
-
1034 painter.fillRect(0, 0, img.width(), img.height(), color);
executed (the execution status of this line is deduced): painter.fillRect(0, 0, img.width(), img.height(), color);
-
1035 painter.end();
executed (the execution status of this line is deduced): painter.end();
-
1036 -
1037 QPixmap selected = QPixmap(QPixmap::fromImage(img));
executed (the execution status of this line is deduced): QPixmap selected = QPixmap(QPixmap::fromImage(img));
-
1038 int n = (img.byteCount() >> 10) + 1;
executed (the execution status of this line is deduced): int n = (img.byteCount() >> 10) + 1;
-
1039 if (QPixmapCache::cacheLimit() < n)
partially evaluated: QPixmapCache::cacheLimit() < n
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1040 QPixmapCache::setCacheLimit(n);
never executed: QPixmapCache::setCacheLimit(n);
0
1041 -
1042 QPixmapCache::insert(key, selected);
executed (the execution status of this line is deduced): QPixmapCache::insert(key, selected);
-
1043 pm = QPixmapCache::find(key);
executed (the execution status of this line is deduced): pm = QPixmapCache::find(key);
-
1044 }
executed: }
Execution Count:3
3
1045 return pm;
executed: return pm;
Execution Count:3
3
1046} -
1047 -
1048/*! -
1049 \internal -
1050*/ -
1051 -
1052QRect QItemDelegate::rect(const QStyleOptionViewItem &option, -
1053 const QModelIndex &index, int role) const -
1054{ -
1055 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
1056 QVariant value = index.data(role);
executed (the execution status of this line is deduced): QVariant value = index.data(role);
-
1057 if (role == Qt::CheckStateRole)
evaluated: role == Qt::CheckStateRole
TRUEFALSE
yes
Evaluation Count:4402
yes
Evaluation Count:8809
4402-8809
1058 return doCheck(option, option.rect, value);
executed: return doCheck(option, option.rect, value);
Execution Count:4402
4402
1059 if (value.isValid() && !value.isNull()) {
evaluated: value.isValid()
TRUEFALSE
yes
Evaluation Count:8350
yes
Evaluation Count:459
partially evaluated: !value.isNull()
TRUEFALSE
yes
Evaluation Count:8350
no
Evaluation Count:0
0-8350
1060 switch (value.type()) { -
1061 case QVariant::Invalid: -
1062 break;
never executed: break;
0
1063 case QVariant::Pixmap: { -
1064 const QPixmap &pixmap = qvariant_cast<QPixmap>(value);
executed (the execution status of this line is deduced): const QPixmap &pixmap = qvariant_cast<QPixmap>(value);
-
1065 return QRect(QPoint(0, 0), pixmap.size() / pixmap.devicePixelRatio() ); }
executed: return QRect(QPoint(0, 0), pixmap.size() / pixmap.devicePixelRatio() );
Execution Count:1
1
1066 case QVariant::Image: { -
1067 const QImage &image = qvariant_cast<QImage>(value);
executed (the execution status of this line is deduced): const QImage &image = qvariant_cast<QImage>(value);
-
1068 return QRect(QPoint(0, 0), image.size() / image.devicePixelRatio() ); }
executed: return QRect(QPoint(0, 0), image.size() / image.devicePixelRatio() );
Execution Count:1
1
1069 case QVariant::Icon: { -
1070 QIcon::Mode mode = d->iconMode(option.state);
executed (the execution status of this line is deduced): QIcon::Mode mode = d->iconMode(option.state);
-
1071 QIcon::State state = d->iconState(option.state);
executed (the execution status of this line is deduced): QIcon::State state = d->iconState(option.state);
-
1072 QIcon icon = qvariant_cast<QIcon>(value);
executed (the execution status of this line is deduced): QIcon icon = qvariant_cast<QIcon>(value);
-
1073 QSize size = icon.actualSize(option.decorationSize, mode, state);
executed (the execution status of this line is deduced): QSize size = icon.actualSize(option.decorationSize, mode, state);
-
1074 return QRect(QPoint(0, 0), size); }
executed: return QRect(QPoint(0, 0), size);
Execution Count:3984
3984
1075 case QVariant::Color: -
1076 return QRect(QPoint(0, 0), option.decorationSize);
executed: return QRect(QPoint(0, 0), option.decorationSize);
Execution Count:1
1
1077 case QVariant::String: -
1078 default: { -
1079 QString text = QItemDelegatePrivate::valueToText(value, option);
executed (the execution status of this line is deduced): QString text = QItemDelegatePrivate::valueToText(value, option);
-
1080 value = index.data(Qt::FontRole);
executed (the execution status of this line is deduced): value = index.data(Qt::FontRole);
-
1081 QFont fnt = qvariant_cast<QFont>(value).resolve(option.font);
executed (the execution status of this line is deduced): QFont fnt = qvariant_cast<QFont>(value).resolve(option.font);
-
1082 return textRectangle(0, d->textLayoutBounds(option), fnt, text); }
executed: return textRectangle(0, d->textLayoutBounds(option), fnt, text);
Execution Count:4363
4363
1083 } -
1084 }
never executed: }
0
1085 return QRect();
executed: return QRect();
Execution Count:459
459
1086} -
1087 -
1088/*! -
1089 \internal -
1090*/ -
1091QRect QItemDelegate::doCheck(const QStyleOptionViewItem &option, -
1092 const QRect &bounding, const QVariant &value) const -
1093{ -
1094 if (value.isValid()) {
evaluated: value.isValid()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:4417
14-4417
1095 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
1096 QStyleOptionButton opt;
executed (the execution status of this line is deduced): QStyleOptionButton opt;
-
1097 opt.QStyleOption::operator=(option);
executed (the execution status of this line is deduced): opt.QStyleOption::operator=(option);
-
1098 opt.rect = bounding;
executed (the execution status of this line is deduced): opt.rect = bounding;
-
1099 const QWidget *widget = d->widget(option); // cast
executed (the execution status of this line is deduced): const QWidget *widget = d->widget(option);
-
1100 QStyle *style = widget ? widget->style() : QApplication::style();
evaluated: widget
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:6
6-8
1101 return style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, widget);
executed: return style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, widget);
Execution Count:14
14
1102 } -
1103 return QRect();
executed: return QRect();
Execution Count:4417
4417
1104} -
1105 -
1106/*! -
1107 \internal -
1108*/ -
1109QRect QItemDelegate::textRectangle(QPainter * /*painter*/, const QRect &rect, -
1110 const QFont &font, const QString &text) const -
1111{ -
1112 Q_D(const QItemDelegate);
executed (the execution status of this line is deduced): const QItemDelegatePrivate * const d = d_func();
-
1113 d->textOption.setWrapMode(QTextOption::WordWrap);
executed (the execution status of this line is deduced): d->textOption.setWrapMode(QTextOption::WordWrap);
-
1114 d->textLayout.setTextOption(d->textOption);
executed (the execution status of this line is deduced): d->textLayout.setTextOption(d->textOption);
-
1115 d->textLayout.setFont(font);
executed (the execution status of this line is deduced): d->textLayout.setFont(font);
-
1116 d->textLayout.setText(QItemDelegatePrivate::replaceNewLine(text));
executed (the execution status of this line is deduced): d->textLayout.setText(QItemDelegatePrivate::replaceNewLine(text));
-
1117 QSizeF fpSize = d->doTextLayout(rect.width());
executed (the execution status of this line is deduced): QSizeF fpSize = d->doTextLayout(rect.width());
-
1118 const QSize size = QSize(qCeil(fpSize.width()), qCeil(fpSize.height()));
executed (the execution status of this line is deduced): const QSize size = QSize(qCeil(fpSize.width()), qCeil(fpSize.height()));
-
1119 // ###: textRectangle should take style option as argument -
1120 const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
executed (the execution status of this line is deduced): const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
-
1121 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
1122} -
1123 -
1124/*! -
1125 \fn bool QItemDelegate::eventFilter(QObject *editor, QEvent *event) -
1126 -
1127 Returns true if the given \a editor is a valid QWidget and the -
1128 given \a event is handled; otherwise returns false. The following -
1129 key press events are handled by default: -
1130 -
1131 \list -
1132 \li \uicontrol Tab -
1133 \li \uicontrol Backtab -
1134 \li \uicontrol Enter -
1135 \li \uicontrol Return -
1136 \li \uicontrol Esc -
1137 \endlist -
1138 -
1139 In the case of \uicontrol Tab, \uicontrol Backtab, \uicontrol Enter and \uicontrol Return -
1140 key press events, the \a editor's data is comitted to the model -
1141 and the editor is closed. If the \a event is a \uicontrol Tab key press -
1142 the view will open an editor on the next item in the -
1143 view. Likewise, if the \a event is a \uicontrol Backtab key press the -
1144 view will open an editor on the \e previous item in the view. -
1145 -
1146 If the event is a \uicontrol Esc key press event, the \a editor is -
1147 closed \e without committing its data. -
1148 -
1149 \sa commitData(), closeEditor() -
1150*/ -
1151 -
1152bool QItemDelegate::eventFilter(QObject *object, QEvent *event) -
1153{ -
1154 QWidget *editor = qobject_cast<QWidget*>(object);
executed (the execution status of this line is deduced): QWidget *editor = qobject_cast<QWidget*>(object);
-
1155 if (!editor)
partially evaluated: !editor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:239
0-239
1156 return false;
never executed: return false;
0
1157 if (event->type() == QEvent::KeyPress) {
evaluated: event->type() == QEvent::KeyPress
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:229
10-229
1158 switch (static_cast<QKeyEvent *>(event)->key()) { -
1159 case Qt::Key_Tab: -
1160 emit commitData(editor);
executed (the execution status of this line is deduced): commitData(editor);
-
1161 emit closeEditor(editor, QAbstractItemDelegate::EditNextItem);
executed (the execution status of this line is deduced): closeEditor(editor, QAbstractItemDelegate::EditNextItem);
-
1162 return true;
executed: return true;
Execution Count:3
3
1163 case Qt::Key_Backtab: -
1164 emit commitData(editor);
executed (the execution status of this line is deduced): commitData(editor);
-
1165 emit closeEditor(editor, QAbstractItemDelegate::EditPreviousItem);
executed (the execution status of this line is deduced): closeEditor(editor, QAbstractItemDelegate::EditPreviousItem);
-
1166 return true;
executed: return true;
Execution Count:1
1
1167 case Qt::Key_Enter: -
1168 case Qt::Key_Return: -
1169#ifndef QT_NO_TEXTEDIT -
1170 if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor))
evaluated: qobject_cast<QTextEdit *>(editor)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
evaluated: qobject_cast<QPlainTextEdit *>(editor)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-3
1171 return false; // don't filter enter key events for QTextEdit
executed: return false;
Execution Count:3
3
1172 // We want the editor to be able to process the key press -
1173 // before committing the data (e.g. so it can do -
1174 // validation/fixup of the input). -
1175#endif // QT_NO_TEXTEDIT -
1176#ifndef QT_NO_LINEEDIT -
1177 if (QLineEdit *e = qobject_cast<QLineEdit*>(editor))
partially evaluated: QLineEdit *e = qobject_cast<QLineEdit*>(editor)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1178 if (!e->hasAcceptableInput())
partially evaluated: !e->hasAcceptableInput()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1179 return false;
never executed: return false;
0
1180#endif // QT_NO_LINEEDIT -
1181 QMetaObject::invokeMethod(this, "_q_commitDataAndCloseEditor",
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "_q_commitDataAndCloseEditor",
-
1182 Qt::QueuedConnection, Q_ARG(QWidget*, editor));
executed (the execution status of this line is deduced): Qt::QueuedConnection, QArgument<QWidget* >("QWidget*", editor));
-
1183 return false;
executed: return false;
Execution Count:1
1
1184 case Qt::Key_Escape: -
1185 // don't commit data -
1186 emit closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
executed (the execution status of this line is deduced): closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
-
1187 break;
executed: break;
Execution Count:1
1
1188 default: -
1189 return false;
executed: return false;
Execution Count:1
1
1190 } -
1191 if (editor->parentWidget())
partially evaluated: editor->parentWidget()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1192 editor->parentWidget()->setFocus();
never executed: editor->parentWidget()->setFocus();
0
1193 return true;
executed: return true;
Execution Count:1
1
1194 } else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow())) {
evaluated: event->type() == QEvent::FocusOut
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:221
evaluated: event->type() == QEvent::Hide
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:215
partially evaluated: editor->isWindow()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-221
1195 //the Hide event will take care of he editors that are in fact complete dialogs -
1196 if (!editor->isActiveWindow() || (QApplication::focusWidget() != editor)) {
evaluated: !editor->isActiveWindow()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6
partially evaluated: (QApplication::focusWidget() != editor)
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1197 QWidget *w = QApplication::focusWidget();
executed (the execution status of this line is deduced): QWidget *w = QApplication::focusWidget();
-
1198 while (w) { // don't worry about focus changes internally in the editor
evaluated: w
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:8
3-8
1199 if (w == editor)
partially evaluated: w == editor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1200 return false;
never executed: return false;
0
1201 w = w->parentWidget();
executed (the execution status of this line is deduced): w = w->parentWidget();
-
1202 }
executed: }
Execution Count:3
3
1203#ifndef QT_NO_DRAGANDDROP -
1204 // The window may lose focus during an drag operation. -
1205 // i.e when dragging involves the taskbar on Windows. -
1206 QPlatformDrag *platformDrag = QGuiApplicationPrivate::instance()->platformIntegration()->drag();
executed (the execution status of this line is deduced): QPlatformDrag *platformDrag = QGuiApplicationPrivate::instance()->platformIntegration()->drag();
-
1207 if (platformDrag && platformDrag->currentDrag()) {
partially evaluated: platformDrag
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
partially evaluated: platformDrag->currentDrag()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1208 return false;
never executed: return false;
0
1209 } -
1210#endif -
1211 -
1212 emit commitData(editor);
executed (the execution status of this line is deduced): commitData(editor);
-
1213 emit closeEditor(editor, NoHint);
executed (the execution status of this line is deduced): closeEditor(editor, NoHint);
-
1214 }
executed: }
Execution Count:8
8
1215 } else if (event->type() == QEvent::ShortcutOverride) {
executed: }
Execution Count:8
evaluated: event->type() == QEvent::ShortcutOverride
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:215
6-215
1216 if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) {
partially evaluated: static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1217 event->accept();
never executed (the execution status of this line is deduced): event->accept();
-
1218 return true;
never executed: return true;
0
1219 } -
1220 }
executed: }
Execution Count:6
6
1221 return false;
executed: return false;
Execution Count:229
229
1222} -
1223 -
1224/*! -
1225 \reimp -
1226*/ -
1227 -
1228bool QItemDelegate::editorEvent(QEvent *event, -
1229 QAbstractItemModel *model, -
1230 const QStyleOptionViewItem &option, -
1231 const QModelIndex &index) -
1232{ -
1233 Q_ASSERT(event);
executed (the execution status of this line is deduced): qt_noop();
-
1234 Q_ASSERT(model);
executed (the execution status of this line is deduced): qt_noop();
-
1235 -
1236 // make sure that the item is checkable -
1237 Qt::ItemFlags flags = model->flags(index);
executed (the execution status of this line is deduced): Qt::ItemFlags flags = model->flags(index);
-
1238 if (!(flags & Qt::ItemIsUserCheckable) || !(option.state & QStyle::State_Enabled)
evaluated: !(flags & Qt::ItemIsUserCheckable)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:8
partially evaluated: !(option.state & QStyle::State_Enabled)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1239 || !(flags & Qt::ItemIsEnabled))
partially evaluated: !(flags & Qt::ItemIsEnabled)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1240 return false;
executed: return false;
Execution Count:4
4
1241 -
1242 // make sure that we have a check state -
1243 QVariant value = index.data(Qt::CheckStateRole);
executed (the execution status of this line is deduced): QVariant value = index.data(Qt::CheckStateRole);
-
1244 if (!value.isValid())
partially evaluated: !value.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1245 return false;
never executed: return false;
0
1246 -
1247 // make sure that we have the right event type -
1248 if ((event->type() == QEvent::MouseButtonRelease)
evaluated: (event->type() == QEvent::MouseButtonRelease)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
1249 || (event->type() == QEvent::MouseButtonDblClick)
evaluated: (event->type() == QEvent::MouseButtonDblClick)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1250 || (event->type() == QEvent::MouseButtonPress)) {
partially evaluated: (event->type() == QEvent::MouseButtonPress)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1251 QRect checkRect = doCheck(option, option.rect, Qt::Checked);
executed (the execution status of this line is deduced): QRect checkRect = doCheck(option, option.rect, Qt::Checked);
-
1252 QRect emptyRect;
executed (the execution status of this line is deduced): QRect emptyRect;
-
1253 doLayout(option, &checkRect, &emptyRect, &emptyRect, false);
executed (the execution status of this line is deduced): doLayout(option, &checkRect, &emptyRect, &emptyRect, false);
-
1254 QMouseEvent *me = static_cast<QMouseEvent*>(event);
executed (the execution status of this line is deduced): QMouseEvent *me = static_cast<QMouseEvent*>(event);
-
1255 if (me->button() != Qt::LeftButton || !checkRect.contains(me->pos()))
evaluated: me->button() != Qt::LeftButton
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
evaluated: !checkRect.contains(me->pos())
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-7
1256 return false;
executed: return false;
Execution Count:2
2
1257 -
1258 // eat the double click events inside the check rect -
1259 if ((event->type() == QEvent::MouseButtonPress)
evaluated: (event->type() == QEvent::MouseButtonPress)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
1260 || (event->type() == QEvent::MouseButtonDblClick))
evaluated: (event->type() == QEvent::MouseButtonDblClick)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
1261 return true;
executed: return true;
Execution Count:2
2
1262 -
1263 } else if (event->type() == QEvent::KeyPress) {
executed: }
Execution Count:4
never evaluated: event->type() == QEvent::KeyPress
0-4
1264 if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space
never evaluated: static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space
0
1265 && static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)
never evaluated: static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select
0
1266 return false;
never executed: return false;
0
1267 } else {
never executed: }
0
1268 return false;
never executed: return false;
0
1269 } -
1270 -
1271 Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
evaluated: static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
1272 ? Qt::Unchecked : Qt::Checked);
executed (the execution status of this line is deduced): ? Qt::Unchecked : Qt::Checked);
-
1273 return model->setData(index, state, Qt::CheckStateRole);
executed: return model->setData(index, state, Qt::CheckStateRole);
Execution Count:4
4
1274} -
1275 -
1276/*! -
1277 \internal -
1278*/ -
1279 -
1280QStyleOptionViewItem QItemDelegate::setOptions(const QModelIndex &index, -
1281 const QStyleOptionViewItem &option) const -
1282{ -
1283 QStyleOptionViewItem opt = option;
executed (the execution status of this line is deduced): QStyleOptionViewItem opt = option;
-
1284 -
1285 // set font -
1286 QVariant value = index.data(Qt::FontRole);
executed (the execution status of this line is deduced): QVariant value = index.data(Qt::FontRole);
-
1287 if (value.isValid()){
evaluated: value.isValid()
TRUEFALSE
yes
Evaluation Count:2747
yes
Evaluation Count:2103
2103-2747
1288 opt.font = qvariant_cast<QFont>(value).resolve(opt.font);
executed (the execution status of this line is deduced): opt.font = qvariant_cast<QFont>(value).resolve(opt.font);
-
1289 opt.fontMetrics = QFontMetrics(opt.font);
executed (the execution status of this line is deduced): opt.fontMetrics = QFontMetrics(opt.font);
-
1290 }
executed: }
Execution Count:2747
2747
1291 -
1292 // set text alignment -
1293 value = index.data(Qt::TextAlignmentRole);
executed (the execution status of this line is deduced): value = index.data(Qt::TextAlignmentRole);
-
1294 if (value.isValid())
evaluated: value.isValid()
TRUEFALSE
yes
Evaluation Count:2744
yes
Evaluation Count:2106
2106-2744
1295 opt.displayAlignment = Qt::Alignment(value.toInt());
executed: opt.displayAlignment = Qt::Alignment(value.toInt());
Execution Count:2744
2744
1296 -
1297 // set foreground brush -
1298 value = index.data(Qt::ForegroundRole);
executed (the execution status of this line is deduced): value = index.data(Qt::ForegroundRole);
-
1299 if (value.canConvert<QBrush>())
evaluated: value.canConvert<QBrush>()
TRUEFALSE
yes
Evaluation Count:2744
yes
Evaluation Count:2106
2106-2744
1300 opt.palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
executed: opt.palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
Execution Count:2744
2744
1301 -
1302 return opt;
executed: return opt;
Execution Count:4850
4850
1303} -
1304 -
1305QT_END_NAMESPACE -
1306 -
1307#include "moc_qitemdelegate.cpp" -
1308 -
1309#endif // QT_NO_ITEMVIEWS -
1310 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial