Revision 8a706d3e
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
src/validators/comparevalidator.cpp | ||
---|---|---|
#include "comparevalidator.h"
|
||
|
||
using namespace CuteEntityManager;
|
||
CompareValidator::CompareValidator() : Validator() {
|
||
|
||
}
|
||
|
||
ErrorMsg CompareValidator::validateParam(QVariant value, Param param) const {
|
||
if (param.getName().isEmpty()) {
|
||
return ErrorMsg("", "No operator set.");
|
||
}
|
||
if (param.getName() == "==" && value != param.getValue()) {
|
||
return ErrorMsg(param.getName(), "<property> must be repeated exactly.");
|
||
} else if (param.getName() == "!=" && value == param.getValue()) {
|
||
... | ... | |
"<property> must be greater than " + param.getValue().toString() + ".");
|
||
} else if (param.getName() == "<" && value >= param.getValue()) {
|
||
return ErrorMsg(param.getName(),
|
||
"<property> must be greater than or equal to " + param.getValue().toString() + ".");
|
||
"<property> must be greater than or equal to " + param.getValue().toString() +
|
||
".");
|
||
} else if (param.getName() == ">=" && value < param.getValue()) {
|
||
return ErrorMsg(param.getName(),
|
||
"<property> must be less than " + param.getValue().toString() + ".");
|
||
} else if (param.getName() == "<=" && value > param.getValue()) {
|
||
return ErrorMsg(param.getName(),
|
||
"<property> must be less than or equal to " + param.getValue().toString() + ".");
|
||
"<property> must be less than or equal to " + param.getValue().toString() +
|
||
".");
|
||
}
|
||
return ErrorMsg();
|
||
}
|
||
|
||
QString CompareValidator::getDefaultOperator() const {
|
||
return defaultOperator;
|
||
}
|
||
|
||
void CompareValidator::setDefaultOperator(const QString &value) {
|
||
defaultOperator = value;
|
||
}
|
||
|
||
|
src/validators/comparevalidator.h | ||
---|---|---|
public:
|
||
CompareValidator();
|
||
ErrorMsg validateParam(QVariant value, Param param) const final override;
|
||
QString getDefaultOperator() const;
|
||
void setDefaultOperator(const QString &value);
|
||
|
||
protected:
|
||
QString defaultOperator = QStringLiteral("==");
|
||
};
|
||
}
|
||
|
Auch abrufbar als: Unified diff
...