qitemeditorfactory.cpp

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

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