Projekt

Allgemein

Profil

Herunterladen als
Herunterladen (1,63 KB) Statistiken
| Zweig: | Revision:
ec6a9500 Christian Ehringfeld
#include "comparevalidator.h"
using namespace CuteEntityManager;
CompareValidator::CompareValidator() : Validator() {
}

ErrorMsg CompareValidator::validateParam(QVariant value, Param param) const {
34233707 Christian Ehringfeld
if (param.getName() == "==" && value != param.getValue()) {
return ErrorMsg(param.getName(), "<property> must be repeated exactly.");
} else if (param.getName() == "!=" && value == param.getValue()) {
return ErrorMsg(param.getName(),
"<property> must not be equal to " + param.getValue().toString() + ".");
} else if (param.getName() == ">" && value <= param.getValue()) {
return ErrorMsg(param.getName(),
"<property> must be greater than " + param.getValue().toString() + ".");
} else if (param.getName() == "<" && value >= param.getValue()) {
return ErrorMsg(param.getName(),
8a706d3e Christian Ehringfeld
"<property> must be greater than or equal to " + param.getValue().toString() +
".");
34233707 Christian Ehringfeld
} 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(),
8a706d3e Christian Ehringfeld
"<property> must be less than or equal to " + param.getValue().toString() +
".");
34233707 Christian Ehringfeld
}
return ErrorMsg();
ec6a9500 Christian Ehringfeld
}

8a706d3e Christian Ehringfeld
QString CompareValidator::getDefaultOperator() const {
return defaultOperator;
}

void CompareValidator::setDefaultOperator(const QString &value) {
defaultOperator = value;
}