Added new validator, userform validation
parent
5dbebcc947
commit
6f78308d7d
@ -0,0 +1,21 @@
|
||||
#include "samestringvalidator.h"
|
||||
#include <QMetaProperty>
|
||||
|
||||
SameStringValidator::SameStringValidator(QWidget *widget_1, QWidget * widget_2, const QString & errorMessage)
|
||||
:IValidator(widget_1,errorMessage)
|
||||
{
|
||||
m_widget_2 = widget_2;
|
||||
}
|
||||
|
||||
bool SameStringValidator::validate()
|
||||
{
|
||||
QString data = m_widget->property(m_widget->metaObject()->userProperty().name()).toString();
|
||||
QString data_2 = m_widget_2->property(m_widget_2->metaObject()->userProperty().name()).toString();
|
||||
if (data != data_2)
|
||||
{
|
||||
m_widget->setFocus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#ifndef SAMESTRINGVALIDATOR_H
|
||||
#define SAMESTRINGVALIDATOR_H
|
||||
#include "ivalidator.h"
|
||||
#include "core_global.h"
|
||||
|
||||
class CORESHARED_EXPORT SameStringValidator : public IValidator
|
||||
{
|
||||
public:
|
||||
SameStringValidator(QWidget * widget_1, QWidget *widget_2, const QString &errorMessage);
|
||||
bool validate();
|
||||
private:
|
||||
QWidget * m_widget_2;
|
||||
};
|
||||
|
||||
#endif // SAMESTRINGVALIDATOR_H
|
Loading…
Reference in New Issue