CSoftValidatorLineEdit: Make use of Qt 5 signals and slots

This commit is contained in:
Lioncash 2020-07-03 07:12:41 -04:00
parent 9fac1a8b00
commit 57e1b272e9
1 changed files with 5 additions and 8 deletions

View File

@ -14,13 +14,13 @@ class CSoftValidatorLineEdit : public CTimedLineEdit
Q_OBJECT Q_OBJECT
/** The validator that input is checked against */ /** The validator that input is checked against */
QValidator* mpSoftValidator; QValidator* mpSoftValidator = nullptr;
/** Whether to only validate when the user stops typing. Good for slow validators. */ /** Whether to only validate when the user stops typing. Good for slow validators. */
bool mOnlyValidateOnFinishedTyping; bool mOnlyValidateOnFinishedTyping = false;
/** Whether the current input is valid */ /** Whether the current input is valid */
bool mInputIsValid; bool mInputIsValid = true;
signals: signals:
/** Emitted when the validity of the input changes */ /** Emitted when the validity of the input changes */
@ -62,11 +62,8 @@ protected slots:
} }
public: public:
CSoftValidatorLineEdit(QWidget *pParent = 0) explicit CSoftValidatorLineEdit(QWidget *pParent = nullptr)
: CTimedLineEdit(pParent) : CTimedLineEdit(pParent)
, mpSoftValidator(nullptr)
, mOnlyValidateOnFinishedTyping(false)
, mInputIsValid(true)
{} {}
/** Set the soft validator to use */ /** Set the soft validator to use */
@ -81,7 +78,7 @@ public:
if (pValidator) if (pValidator)
{ {
mpSoftValidator = pValidator; mpSoftValidator = pValidator;
connect(mpSoftValidator, SIGNAL(changed()), this, SLOT(InternalUpdate())); connect(mpSoftValidator, &QValidator::changed, this, &CSoftValidatorLineEdit::InternalUpdate);
} }
InternalUpdate(); InternalUpdate();