4#include <qplatformdefs.h>
11#if QT_CONFIG(datetimeedit)
17#if QT_CONFIG(lineedit)
35#if QT_CONFIG(combobox)
43 QBooleanComboBox(
QWidget *parent);
58 explicit QUIntSpinBox(
QWidget *parent =
nullptr)
69 void setUIntValue(
uint value_)
75 void uintValueChanged();
143 return dfactory ==
this ?
nullptr : dfactory->createEditor(userType, parent);
156 return dfactory ==
this ?
QByteArray() : dfactory->valuePropertyName(userType);
168 std::vector<QItemEditorCreatorBase*> creators(creatorMap.
cbegin(), creatorMap.
cend());
169 std::sort(creators.begin(), creators.end());
170 const auto it = std::unique(creators.begin(), creators.end());
185 if (
it != creatorMap.
cend()) {
189 if (std::find(creatorMap.
cbegin(), creatorMap.
cend(), oldCreator) == creatorMap.
cend())
193 creatorMap[userType] =
creator;
207#if QT_CONFIG(combobox)
208 case QMetaType::Bool: {
209 QBooleanComboBox *
cb =
new QBooleanComboBox(parent);
214#if QT_CONFIG(spinbox)
215 case QMetaType::UInt: {
216 QSpinBox *sb =
new QUIntSpinBox(parent);
219 sb->setMaximum(INT_MAX);
222 case QMetaType::Int: {
225 sb->setMinimum(INT_MIN);
226 sb->setMaximum(INT_MAX);
230#if QT_CONFIG(datetimeedit)
231 case QMetaType::QDate: {
235 case QMetaType::QTime: {
239 case QMetaType::QDateTime: {
245 case QMetaType::QPixmap:
246 return new QLabel(parent);
248#if QT_CONFIG(spinbox)
249 case QMetaType::Double: {
252 sb->setMinimum(-DBL_MAX);
253 sb->setMaximum(DBL_MAX);
257#if QT_CONFIG(lineedit)
258 case QMetaType::QString:
261 QExpandingLineEdit *
le =
new QExpandingLineEdit(parent);
264 le->setWidgetOwnsGeometry(
true);
277#if QT_CONFIG(combobox)
278 case QMetaType::Bool:
279 return "currentIndex";
281#if QT_CONFIG(spinbox)
282 case QMetaType::UInt:
284 case QMetaType::Double:
287#if QT_CONFIG(datetimeedit)
288 case QMetaType::QDate:
290 case QMetaType::QTime:
292 case QMetaType::QDateTime:
295 case QMetaType::QString:
510#if QT_CONFIG(lineedit)
512QExpandingLineEdit::QExpandingLineEdit(
QWidget *parent)
516 updateMinimumWidth();
519void QExpandingLineEdit::changeEvent(
QEvent *e)
526 updateMinimumWidth();
535void QExpandingLineEdit::updateMinimumWidth()
538 const QMargins cm = contentsMargins();
539 const int width = tm.
left() + tm.
right() + cm.left() + cm.right() + 4 ;
542 initStyleOption(&
opt);
545 setMinimumWidth(minWidth);
548void QExpandingLineEdit::resizeToContents()
550 int oldWidth =
width();
551 if (originalWidth == -1)
552 originalWidth = oldWidth;
553 if (
QWidget *parent = parentWidget()) {
555 int hintWidth = minimumWidth() +
fontMetrics().horizontalAdvance(displayText());
556 int parentWidth = parent->
width();
558 int newWidth =
qBound(
qMin(originalWidth, maxWidth), hintWidth, maxWidth);
559 if (widgetOwnsGeometry)
560 setMaximumWidth(newWidth);
569#if QT_CONFIG(combobox)
571QBooleanComboBox::QBooleanComboBox(
QWidget *parent)
574 addItem(QComboBox::tr(
"False"));
575 addItem(QComboBox::tr(
"True"));
578void QBooleanComboBox::setValue(
bool value)
580 setCurrentIndex(
value ? 1 : 0);
583bool QBooleanComboBox::value()
const
585 return (currentIndex() == 1);
592#if QT_CONFIG(lineedit) || QT_CONFIG(combobox)
593#include "qitemeditorfactory.moc"
596#include "moc_qitemeditorfactory_p.cpp"
The QComboBox widget combines a button with a dropdown list.
The QDateEdit class provides a widget for editing dates based on the QDateTimeEdit widget.
The QDateTimeEdit class provides a widget for editing dates and times.
QWidget * createEditor(int userType, QWidget *parent) const override
Creates an editor widget with the given parent for the specified userType of data,...
QDefaultItemEditorFactory()
QByteArray valuePropertyName(int) const override
Returns the property name used to access data for the given userType of data.
The QDoubleSpinBox class provides a spin box widget that takes doubles.
Type type() const
Returns the event type.
const_iterator cbegin() const noexcept
const_iterator constFind(const Key &key) const noexcept
iterator erase(const_iterator it)
T value(const Key &key) const noexcept
const_iterator cend() const noexcept
The QItemEditorCreatorBase class provides an abstract base class that must be subclassed when impleme...
virtual QByteArray valuePropertyName() const =0
Returns the name of the property used to get and set values in the creator's editor widgets.
virtual QWidget * createWidget(QWidget *parent) const =0
Returns an editor widget with the given parent.
virtual ~QItemEditorCreatorBase()
Destroys the editor creator object.
The QItemEditorFactory class provides widgets for editing item data in views and delegates.
virtual QByteArray valuePropertyName(int userType) const
Returns the property name used to access data for the given userType of data.
virtual ~QItemEditorFactory()
Destroys the item editor factory.
void registerEditor(int userType, QItemEditorCreatorBase *creator)
Registers an item editor creator specified by creator for the given userType of data.
static void setDefaultFactory(QItemEditorFactory *factory)
[2]
static const QItemEditorFactory * defaultFactory()
Returns the default item editor factory.
virtual QWidget * createEditor(int userType, QWidget *parent) const
Creates an editor widget with the given parent for the specified userType of data,...
The QLabel widget provides a text or image display.
The QLineEdit widget is a one-line text editor.
void changeEvent(QEvent *) override
\reimp
constexpr int left() const noexcept
Returns the left margin.
constexpr int right() const noexcept
Returns the right margin.
\inmodule QtCore\reentrant
The QSpinBox class provides a spin box widget.
\macro QT_RESTRICTED_CAST_FROM_ASCII
\variable QStyleOptionFocusRect::backgroundColor
@ SH_ItemView_DrawDelegateFrame
@ SH_ItemView_ShowDecorationSelected
The QTimeEdit class provides a widget for editing times based on the QDateTimeEdit widget.
void textChanged(const QString &newText)
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static QItemEditorFactory * q_default_factory
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
GLint GLsizei GLsizei height
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
settings setValue("DataPump/bgcolor", color)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QItemEditorCreatorBase * creator
QItemEditorFactory * factory
~QDefaultFactoryCleaner()