aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickcombobox.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2022-08-16 20:37:43 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2022-08-16 20:37:43 +0300
commitbbd4a25e456a2922ff71d9cbe9a8b7f656e753ad (patch)
tree560da0e7bf6e3546ac4fdd9826213c8a1568d407 /src/quicktemplates2/qquickcombobox.cpp
parenta970e15d7281d2d13485a486c6debadf46ed7950 (diff)
parent05522a30193a3090dd7cae26b36d675ae1f18e08 (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.6' into tqtc/lts-5.15-opensourcev5.15.6-lts-lgpl
Diffstat (limited to 'src/quicktemplates2/qquickcombobox.cpp')
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index b715659f..e7d99a5d 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -234,6 +234,7 @@ public:
void updateCurrentText();
void updateCurrentValue();
void updateCurrentTextAndValue();
+ void updateAcceptableInput();
bool isValidIndex(int index) const;
@@ -290,6 +291,7 @@ public:
QQmlComponent *delegate = nullptr;
QQuickDeferredPointer<QQuickItem> indicator;
QQuickDeferredPointer<QQuickPopup> popup;
+ bool m_acceptableInput = true;
struct ExtraData {
bool editable = false;
@@ -478,6 +480,26 @@ void QQuickComboBoxPrivate::updateCurrentTextAndValue()
updateCurrentValue();
}
+void QQuickComboBoxPrivate::updateAcceptableInput()
+{
+ Q_Q(QQuickComboBox);
+
+ if (!contentItem)
+ return;
+
+ const QQuickTextInput *textInputContentItem = qobject_cast<QQuickTextInput *>(contentItem);
+
+ if (!textInputContentItem)
+ return;
+
+ const bool newValue = textInputContentItem->hasAcceptableInput();
+
+ if (m_acceptableInput != newValue) {
+ m_acceptableInput = newValue;
+ emit q->acceptableInputChanged();
+ }
+}
+
bool QQuickComboBoxPrivate::isValidIndex(int index) const
{
return delegateModel && index >= 0 && index < delegateModel->count();
@@ -1485,7 +1507,7 @@ bool QQuickComboBox::isInputMethodComposing() const
bool QQuickComboBox::hasAcceptableInput() const
{
Q_D(const QQuickComboBox);
- return d->contentItem && d->contentItem->property("acceptableInput").toBool();
+ return d->m_acceptableInput;
}
/*!
@@ -1926,7 +1948,7 @@ void QQuickComboBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
QObjectPrivate::disconnect(oldInput, &QQuickTextInput::accepted, d, &QQuickComboBoxPrivate::acceptInput);
QObjectPrivate::disconnect(oldInput, &QQuickTextInput::textChanged, d, &QQuickComboBoxPrivate::updateEditText);
disconnect(oldInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickComboBox::inputMethodComposingChanged);
- disconnect(oldInput, &QQuickTextInput::acceptableInputChanged, this, &QQuickComboBox::acceptableInputChanged);
+ QObjectPrivate::disconnect(oldInput, &QQuickTextInput::acceptableInputChanged, d, &QQuickComboBoxPrivate::updateAcceptableInput);
}
}
if (newItem && isEditable()) {
@@ -1935,12 +1957,14 @@ void QQuickComboBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
QObjectPrivate::connect(newInput, &QQuickTextInput::accepted, d, &QQuickComboBoxPrivate::acceptInput);
QObjectPrivate::connect(newInput, &QQuickTextInput::textChanged, d, &QQuickComboBoxPrivate::updateEditText);
connect(newInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickComboBox::inputMethodComposingChanged);
- connect(newInput, &QQuickTextInput::acceptableInputChanged, this, &QQuickComboBox::acceptableInputChanged);
+ QObjectPrivate::connect(newInput, &QQuickTextInput::acceptableInputChanged, d, &QQuickComboBoxPrivate::updateAcceptableInput);
}
#if QT_CONFIG(cursor)
newItem->setCursor(Qt::IBeamCursor);
#endif
}
+
+ d->updateAcceptableInput();
}
void QQuickComboBox::localeChange(const QLocale &newLocale, const QLocale &oldLocale)