Forgotten modifications.
							parent
							
								
									5993193ffb
								
							
						
					
					
						commit
						21ffb16151
					
				| @ -1,7 +1,22 @@ | ||||
| #include "emptystringvalidator.h" | ||||
| 
 | ||||
| EmptyStringValidator::EmptyStringValidator() | ||||
| #include <QMetaObject> | ||||
| #include <QMetaProperty> | ||||
| 
 | ||||
| EmptyStringValidator::EmptyStringValidator(QWidget *widget, const QString &errMessage) | ||||
|     :IValidator(widget, errMessage) | ||||
| {    | ||||
| } | ||||
| 
 | ||||
| bool EmptyStringValidator::validate() | ||||
| { | ||||
|     QString data = m_widget->property(m_widget->metaObject()->userProperty().name()).toString(); | ||||
|     if (data.isEmpty()) | ||||
|     { | ||||
|         m_widget->setFocus(); | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -1,11 +1,17 @@ | ||||
| #ifndef EMPTYSTRINGVALIDATOR_H | ||||
| #define EMPTYSTRINGVALIDATOR_H | ||||
| 
 | ||||
| #include <QString> | ||||
| #include "ivalidator.h" | ||||
| 
 | ||||
| class EmptyStringValidator : public IValidator | ||||
| { | ||||
| public: | ||||
|     EmptyStringValidator(); | ||||
|     EmptyStringValidator(QWidget *widget, const QString &errMessage); | ||||
| 
 | ||||
|     // IValidator interface
 | ||||
| public: | ||||
|     bool validate(); | ||||
| }; | ||||
| 
 | ||||
| #endif // EMPTYSTRINGVALIDATOR_H
 | ||||
|  | ||||
| @ -1,5 +1,31 @@ | ||||
| #ifndef IVALIDATOR_H | ||||
| #define IVALIDATOR_H | ||||
| 
 | ||||
| #include <QWidget> | ||||
| #include <QString> | ||||
| 
 | ||||
| class IValidator | ||||
| { | ||||
| public: | ||||
|     IValidator(QWidget *widget, const QString &errMessage) | ||||
|     { | ||||
|         m_widget = widget; | ||||
|         m_errMessage = errMessage; | ||||
|     } | ||||
| 
 | ||||
|     virtual bool validate() = 0; | ||||
| 
 | ||||
|     QString errMessage() | ||||
|     { | ||||
|         return m_errMessage; | ||||
|     } | ||||
| 
 | ||||
| protected: | ||||
|     QWidget *m_widget; | ||||
| 
 | ||||
| private: | ||||
|     QString m_errMessage; | ||||
| }; | ||||
| 
 | ||||
| #endif // IVALIDATOR_H
 | ||||
| 
 | ||||
|  | ||||
					Loading…
					
					
				
		Reference in New Issue