Add option to keep selection when FilterComboBox entry doesn't exist

This commit is contained in:
WarmUpTill
2025-05-21 14:53:12 +02:00
committed by WarmUpTill
parent a84731b8fe
commit c43439ee64
2 changed files with 8 additions and 1 deletions

View File

@@ -62,6 +62,11 @@ void FilterComboBox::SetFilterBehaviourEnabled(bool value)
FilterComboBox::_filteringEnabled = value;
}
void FilterComboBox::SetAllowUnmatchedSelection(bool allow)
{
_allowUnmatchedSelection = allow;
}
void FilterComboBox::setCurrentText(const QString &text)
{
if (_filteringEnabled) {
@@ -82,7 +87,7 @@ void FilterComboBox::setItemText(int index, const QString &text)
void FilterComboBox::focusOutEvent(QFocusEvent *event)
{
// Reset on invalid selection
if (findText(currentText()) == -1) {
if (!_allowUnmatchedSelection && findText(currentText()) == -1) {
setCurrentIndex(-1);
Emit(-1, "");
}