Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | class QBooleanComboBox : public QComboBox | - |
11 | { | - |
12 | public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; | - |
13 | | - |
14 | | - |
15 | public: | - |
16 | QBooleanComboBox(QWidget *parent); | - |
17 | void setValue(bool); | - |
18 | bool value() const; | - |
19 | }; | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | class QUIntSpinBox : public QSpinBox | - |
27 | { | - |
28 | public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; | - |
29 | | - |
30 | public: | - |
31 | explicit QUIntSpinBox(QWidget *parent = 0) | - |
32 | : QSpinBox(parent) | - |
33 | { | - |
34 | connect(this, "2""valueChanged(int)", "2""uintValueChanged()"); | - |
35 | } executed: } Execution Count:3 | 3 |
36 | | - |
37 | uint uintValue() | - |
38 | { | - |
39 | return value(); executed: return value(); Execution Count:2 | 2 |
40 | } | - |
41 | | - |
42 | void setUIntValue(uint value_) | - |
43 | { | - |
44 | return setValue(value_); executed: return setValue(value_); Execution Count:4 | 4 |
45 | } | - |
46 | | - |
47 | public: | - |
48 | void uintValueChanged(); | - |
49 | }; | - |
50 | QWidget *QItemEditorFactory::createEditor(int userType, QWidget *parent) const | - |
51 | { | - |
52 | QItemEditorCreatorBase *creator = creatorMap.value(userType, 0); | - |
53 | if (!creator) { evaluated: !creator yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
54 | const QItemEditorFactory *dfactory = defaultFactory(); | - |
55 | return dfactory == this ? 0 : dfactory->createEditor(userType, parent); executed: return dfactory == this ? 0 : dfactory->createEditor(userType, parent); Execution Count:2 | 2 |
56 | } | - |
57 | return creator->createWidget(parent); executed: return creator->createWidget(parent); Execution Count:1 | 1 |
58 | } | - |
59 | | - |
60 | | - |
61 | | - |
62 | | - |
63 | QByteArray QItemEditorFactory::valuePropertyName(int userType) const | - |
64 | { | - |
65 | QItemEditorCreatorBase *creator = creatorMap.value(userType, 0); | - |
66 | if (!creator) { never evaluated: !creator | 0 |
67 | const QItemEditorFactory *dfactory = defaultFactory(); | - |
68 | return dfactory == this ? QByteArray() : dfactory->valuePropertyName(userType); never executed: return dfactory == this ? QByteArray() : dfactory->valuePropertyName(userType); | 0 |
69 | } | - |
70 | return creator->valuePropertyName(); never executed: return creator->valuePropertyName(); | 0 |
71 | } | - |
72 | | - |
73 | | - |
74 | | - |
75 | | - |
76 | QItemEditorFactory::~QItemEditorFactory() | - |
77 | { | - |
78 | | - |
79 | | - |
80 | QSet<QItemEditorCreatorBase*> set = creatorMap.values().toSet(); | - |
81 | qDeleteAll(set); | - |
82 | } executed: } Execution Count:11 | 11 |
83 | void QItemEditorFactory::registerEditor(int userType, QItemEditorCreatorBase *creator) | - |
84 | { | - |
85 | QHash<int, QItemEditorCreatorBase *>::iterator it = creatorMap.find(userType); | - |
86 | if (it != creatorMap.end()) { evaluated: it != creatorMap.end() yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
87 | QItemEditorCreatorBase *oldCreator = it.value(); | - |
88 | qt_noop(); | - |
89 | creatorMap.erase(it); | - |
90 | if (!creatorMap.values().contains(oldCreator)) evaluated: !creatorMap.values().contains(oldCreator) yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
91 | delete oldCreator; executed: delete oldCreator; Execution Count:1 | 1 |
92 | } executed: } Execution Count:2 | 2 |
93 | | - |
94 | creatorMap[userType] = creator; | - |
95 | } executed: } Execution Count:4 | 4 |
96 | | - |
97 | class QDefaultItemEditorFactory : public QItemEditorFactory | - |
98 | { | - |
99 | public: | - |
100 | inline QDefaultItemEditorFactory() {} | - |
101 | QWidget *createEditor(int userType, QWidget *parent) const; | - |
102 | QByteArray valuePropertyName(int) const; | - |
103 | }; | - |
104 | | - |
105 | QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) const | - |
106 | { | - |
107 | switch (userType) { | - |
108 | | - |
109 | case QVariant::Bool: { | - |
110 | QBooleanComboBox *cb = new QBooleanComboBox(parent); | - |
111 | cb->setFrame(false); | - |
112 | return cb; } executed: return cb; Execution Count:1 | 1 |
113 | | - |
114 | | - |
115 | case QVariant::UInt: { | - |
116 | QSpinBox *sb = new QUIntSpinBox(parent); | - |
117 | sb->setFrame(false); | - |
118 | sb->setMinimum(0); | - |
119 | sb->setMaximum(2147483647); | - |
120 | return sb; } executed: return sb; Execution Count:3 | 3 |
121 | case QVariant::Int: { | - |
122 | QSpinBox *sb = new QSpinBox(parent); | - |
123 | sb->setFrame(false); | - |
124 | sb->setMinimum((-2147483647 - 1)); | - |
125 | sb->setMaximum(2147483647); | - |
126 | return sb; } executed: return sb; Execution Count:3 | 3 |
127 | | - |
128 | | - |
129 | case QVariant::Date: { | - |
130 | QDateTimeEdit *ed = new QDateEdit(parent); | - |
131 | ed->setFrame(false); | - |
132 | return ed; } executed: return ed; Execution Count:2 | 2 |
133 | case QVariant::Time: { | - |
134 | QDateTimeEdit *ed = new QTimeEdit(parent); | - |
135 | ed->setFrame(false); | - |
136 | return ed; } executed: return ed; Execution Count:2 | 2 |
137 | case QVariant::DateTime: { | - |
138 | QDateTimeEdit *ed = new QDateTimeEdit(parent); | - |
139 | ed->setFrame(false); | - |
140 | return ed; } executed: return ed; Execution Count:2 | 2 |
141 | | - |
142 | case QVariant::Pixmap: | - |
143 | return new QLabel(parent); never executed: return new QLabel(parent); | 0 |
144 | | - |
145 | case QVariant::Double: { | - |
146 | QDoubleSpinBox *sb = new QDoubleSpinBox(parent); | - |
147 | sb->setFrame(false); | - |
148 | sb->setMinimum(-1.7976931348623157e+308); | - |
149 | sb->setMaximum(1.7976931348623157e+308); | - |
150 | return sb; } executed: return sb; Execution Count:1 | 1 |
151 | | - |
152 | | - |
153 | case QVariant::String: | - |
154 | default: { | - |
155 | | - |
156 | QExpandingLineEdit *le = new QExpandingLineEdit(parent); | - |
157 | le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, 0, le)); | - |
158 | if (!le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, le)) partially evaluated: !le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, le) yes Evaluation Count:85 | no Evaluation Count:0 |
| 0-85 |
159 | le->setWidgetOwnsGeometry(true); executed: le->setWidgetOwnsGeometry(true); Execution Count:85 | 85 |
160 | return le; } executed: return le; Execution Count:85 | 85 |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | } | - |
166 | return 0; never executed: return 0; | 0 |
167 | } | - |
168 | | - |
169 | QByteArray QDefaultItemEditorFactory::valuePropertyName(int userType) const | - |
170 | { | - |
171 | switch (userType) { | - |
172 | | - |
173 | case QVariant::Bool: | - |
174 | return "currentIndex"; never executed: return "currentIndex"; | 0 |
175 | | - |
176 | | - |
177 | case QVariant::UInt: | - |
178 | case QVariant::Int: | - |
179 | case QVariant::Double: | - |
180 | return "value"; never executed: return "value"; | 0 |
181 | | - |
182 | | - |
183 | case QVariant::Date: | - |
184 | return "date"; never executed: return "date"; | 0 |
185 | case QVariant::Time: | - |
186 | return "time"; never executed: return "time"; | 0 |
187 | case QVariant::DateTime: | - |
188 | return "dateTime"; never executed: return "dateTime"; | 0 |
189 | | - |
190 | case QVariant::String: | - |
191 | default: | - |
192 | | - |
193 | return "text"; executed: return "text"; Execution Count:3 | 3 |
194 | } | - |
195 | } | 0 |
196 | | - |
197 | static QItemEditorFactory *q_default_factory = 0; | - |
198 | struct QDefaultFactoryCleaner | - |
199 | { | - |
200 | inline QDefaultFactoryCleaner() {} | - |
201 | ~QDefaultFactoryCleaner() { delete q_default_factory; q_default_factory = 0; } | 0 |
202 | }; | - |
203 | | - |
204 | | - |
205 | | - |
206 | | - |
207 | | - |
208 | | - |
209 | const QItemEditorFactory *QItemEditorFactory::defaultFactory() | - |
210 | { | - |
211 | static const QDefaultItemEditorFactory factory; | - |
212 | if (q_default_factory) partially evaluated: q_default_factory no Evaluation Count:0 | yes Evaluation Count:102 |
| 0-102 |
213 | return q_default_factory; never executed: return q_default_factory; | 0 |
214 | return &factory; executed: return &factory; Execution Count:102 | 102 |
215 | } | - |
216 | | - |
217 | | - |
218 | | - |
219 | | - |
220 | | - |
221 | | - |
222 | | - |
223 | void QItemEditorFactory::setDefaultFactory(QItemEditorFactory *factory) | - |
224 | { | - |
225 | static const QDefaultFactoryCleaner cleaner; | - |
226 | delete q_default_factory; | - |
227 | q_default_factory = factory; | - |
228 | } | 0 |
229 | QItemEditorCreatorBase::~QItemEditorCreatorBase() | - |
230 | { | - |
231 | | - |
232 | } | - |
233 | QExpandingLineEdit::QExpandingLineEdit(QWidget *parent) | - |
234 | : QLineEdit(parent), originalWidth(-1), widgetOwnsGeometry(false) | - |
235 | { | - |
236 | connect(this, "2""textChanged(QString)", this, "1""resizeToContents()"); | - |
237 | updateMinimumWidth(); | - |
238 | } executed: } Execution Count:85 | 85 |
239 | | - |
240 | void QExpandingLineEdit::changeEvent(QEvent *e) | - |
241 | { | - |
242 | switch (e->type()) | - |
243 | { | - |
244 | case QEvent::FontChange: | - |
245 | case QEvent::StyleChange: | - |
246 | case QEvent::ContentsRectChange: | - |
247 | updateMinimumWidth(); | - |
248 | break; | 0 |
249 | default: | - |
250 | break; executed: break; Execution Count:1 | 1 |
251 | } | - |
252 | | - |
253 | QLineEdit::changeEvent(e); | - |
254 | } executed: } Execution Count:1 | 1 |
255 | | - |
256 | void QExpandingLineEdit::updateMinimumWidth() | - |
257 | { | - |
258 | int left, right; | - |
259 | getTextMargins(&left, 0, &right, 0); | - |
260 | int width = left + right + 4 ; | - |
261 | getContentsMargins(&left, 0, &right, 0); | - |
262 | width += left + right; | - |
263 | | - |
264 | QStyleOptionFrameV2 opt; | - |
265 | initStyleOption(&opt); | - |
266 | | - |
267 | int minWidth = style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(width, 0). | - |
268 | expandedTo(QApplication::globalStrut()), this).width(); | - |
269 | setMinimumWidth(minWidth); | - |
270 | } executed: } Execution Count:85 | 85 |
271 | | - |
272 | void QExpandingLineEdit::resizeToContents() | - |
273 | { | - |
274 | int oldWidth = width(); | - |
275 | if (originalWidth == -1) evaluated: originalWidth == -1 yes Evaluation Count:67 | yes Evaluation Count:13 |
| 13-67 |
276 | originalWidth = oldWidth; executed: originalWidth = oldWidth; Execution Count:67 | 67 |
277 | if (QWidget *parent = parentWidget()) { partially evaluated: QWidget *parent = parentWidget() yes Evaluation Count:80 | no Evaluation Count:0 |
| 0-80 |
278 | QPoint position = pos(); | - |
279 | int hintWidth = minimumWidth() + fontMetrics().width(displayText()); | - |
280 | int parentWidth = parent->width(); | - |
281 | int maxWidth = isRightToLeft() ? position.x() + oldWidth : parentWidth - position.x(); partially evaluated: isRightToLeft() no Evaluation Count:0 | yes Evaluation Count:80 |
| 0-80 |
282 | int newWidth = qBound(originalWidth, hintWidth, maxWidth); | - |
283 | if (widgetOwnsGeometry) partially evaluated: widgetOwnsGeometry yes Evaluation Count:80 | no Evaluation Count:0 |
| 0-80 |
284 | setMaximumWidth(newWidth); executed: setMaximumWidth(newWidth); Execution Count:80 | 80 |
285 | if (isRightToLeft()) partially evaluated: isRightToLeft() no Evaluation Count:0 | yes Evaluation Count:80 |
| 0-80 |
286 | move(position.x() - newWidth + oldWidth, position.y()); never executed: move(position.x() - newWidth + oldWidth, position.y()); | 0 |
287 | resize(newWidth, height()); | - |
288 | } executed: } Execution Count:80 | 80 |
289 | } executed: } Execution Count:80 | 80 |
290 | | - |
291 | | - |
292 | | - |
293 | | - |
294 | | - |
295 | QBooleanComboBox::QBooleanComboBox(QWidget *parent) | - |
296 | : QComboBox(parent) | - |
297 | { | - |
298 | addItem(QComboBox::tr("False")); | - |
299 | addItem(QComboBox::tr("True")); | - |
300 | } executed: } Execution Count:1 | 1 |
301 | | - |
302 | void QBooleanComboBox::setValue(bool value) | - |
303 | { | - |
304 | setCurrentIndex(value ? 1 : 0); | - |
305 | } executed: } Execution Count:2 | 2 |
306 | | - |
307 | bool QBooleanComboBox::value() const | - |
308 | { | - |
309 | return (currentIndex() == 1); executed: return (currentIndex() == 1); Execution Count:1 | 1 |
310 | } | - |
311 | | - |
312 | | - |
313 | | - |
314 | | - |
315 | | - |
316 | | - |
317 | | - |
| | |