mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Add option to keep selection when FilterComboBox entry doesn't exist
This commit is contained in:
parent
a84731b8fe
commit
c43439ee64
|
|
@ -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, "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public:
|
|||
FilterComboBox(QWidget *parent = nullptr,
|
||||
const QString &placehodler = "");
|
||||
static void SetFilterBehaviourEnabled(bool);
|
||||
void SetAllowUnmatchedSelection(bool allow);
|
||||
|
||||
void setCurrentText(const QString &text);
|
||||
void setItemText(int index, const QString &text);
|
||||
|
|
@ -27,6 +28,7 @@ private slots:
|
|||
private:
|
||||
void Emit(int index, const QString &text);
|
||||
|
||||
bool _allowUnmatchedSelection = false;
|
||||
int _lastEmittedIndex = -1;
|
||||
QString _lastEmittedText;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user