fixup api

pull/148/head
Michael Zanetti 2019-03-27 01:05:59 +01:00
parent 774452ff7c
commit 6afe3e5161
5 changed files with 56 additions and 56 deletions

View File

@ -188,7 +188,7 @@ void JsonTypes::init()
s_ruleActionParam.insert("o:value", basicTypeRef()); s_ruleActionParam.insert("o:value", basicTypeRef());
s_ruleActionParam.insert("o:eventTypeId", basicTypeToString(Uuid)); s_ruleActionParam.insert("o:eventTypeId", basicTypeToString(Uuid));
s_ruleActionParam.insert("o:eventParamTypeId", basicTypeToString(Uuid)); s_ruleActionParam.insert("o:eventParamTypeId", basicTypeToString(Uuid));
s_ruleActionParam.insert("o:deviceId", basicTypeToString(Uuid)); s_ruleActionParam.insert("o:stateDeviceId", basicTypeToString(Uuid));
s_ruleActionParam.insert("o:stateTypeId", basicTypeToString(Uuid)); s_ruleActionParam.insert("o:stateTypeId", basicTypeToString(Uuid));
// ParamDescriptor // ParamDescriptor
@ -619,7 +619,7 @@ QVariantMap JsonTypes::packRuleActionParam(const RuleActionParam &ruleActionPara
variantMap.insert("eventTypeId", ruleActionParam.eventTypeId().toString()); variantMap.insert("eventTypeId", ruleActionParam.eventTypeId().toString());
variantMap.insert("eventParamTypeId", ruleActionParam.eventParamTypeId().toString()); variantMap.insert("eventParamTypeId", ruleActionParam.eventParamTypeId().toString());
} else if (ruleActionParam.isStateBased()) { } else if (ruleActionParam.isStateBased()) {
variantMap.insert("deviceId", ruleActionParam.deviceId().toString()); variantMap.insert("stateDeviceId", ruleActionParam.stateDeviceId().toString());
variantMap.insert("stateTypeId", ruleActionParam.stateTypeId().toString()); variantMap.insert("stateTypeId", ruleActionParam.stateTypeId().toString());
} else { } else {
variantMap.insert("value", ruleActionParam.value()); variantMap.insert("value", ruleActionParam.value());
@ -1444,7 +1444,7 @@ RuleActionParam JsonTypes::unpackRuleActionParam(const QVariantMap &ruleActionPa
param.setValue(ruleActionParamMap.value("value")); param.setValue(ruleActionParamMap.value("value"));
param.setEventTypeId(EventTypeId(ruleActionParamMap.value("eventTypeId").toString())); param.setEventTypeId(EventTypeId(ruleActionParamMap.value("eventTypeId").toString()));
param.setEventParamTypeId(ParamTypeId(ruleActionParamMap.value("eventParamTypeId").toString())); param.setEventParamTypeId(ParamTypeId(ruleActionParamMap.value("eventParamTypeId").toString()));
param.setDeviceId(DeviceId(ruleActionParamMap.value("deviceId").toString())); param.setStateDeviceId(DeviceId(ruleActionParamMap.value("stateDeviceId").toString()));
param.setStateTypeId(StateTypeId(ruleActionParamMap.value("stateTypeId").toString())); param.setStateTypeId(StateTypeId(ruleActionParamMap.value("stateTypeId").toString()));
return param; return param;
} }
@ -1466,7 +1466,7 @@ ParamDescriptor JsonTypes::unpackParamDescriptor(const QVariantMap &paramMap)
QMetaObject metaObject = Types::staticMetaObject; QMetaObject metaObject = Types::staticMetaObject;
int enumIndex = metaObject.indexOfEnumerator("ValueOperator"); int enumIndex = metaObject.indexOfEnumerator("ValueOperator");
QMetaEnum metaEnum = metaObject.enumerator(enumIndex); QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
Types::ValueOperator valueOperator = (Types::ValueOperator)metaEnum.keyToValue(operatorString.toLatin1().data()); Types::ValueOperator valueOperator = static_cast<Types::ValueOperator>(metaEnum.keyToValue(operatorString.toLatin1().data()));
if (paramMap.contains("paramTypeId")) { if (paramMap.contains("paramTypeId")) {
ParamDescriptor param = ParamDescriptor(ParamTypeId(paramMap.value("paramTypeId").toString()), paramMap.value("value")); ParamDescriptor param = ParamDescriptor(ParamTypeId(paramMap.value("paramTypeId").toString()), paramMap.value("value"));
@ -1507,7 +1507,7 @@ StateEvaluator JsonTypes::unpackStateEvaluator(const QVariantMap &stateEvaluator
{ {
StateEvaluator ret(unpackStateDescriptor(stateEvaluatorMap.value("stateDescriptor").toMap())); StateEvaluator ret(unpackStateDescriptor(stateEvaluatorMap.value("stateDescriptor").toMap()));
if (stateEvaluatorMap.contains("operator")) { if (stateEvaluatorMap.contains("operator")) {
ret.setOperatorType((Types::StateOperator)s_stateOperator.indexOf(stateEvaluatorMap.value("operator").toString())); ret.setOperatorType(static_cast<Types::StateOperator>(s_stateOperator.indexOf(stateEvaluatorMap.value("operator").toString())));
} else { } else {
ret.setOperatorType(Types::StateOperatorAnd); ret.setOperatorType(Types::StateOperatorAnd);
} }
@ -1528,7 +1528,7 @@ StateDescriptor JsonTypes::unpackStateDescriptor(const QVariantMap &stateDescrip
QString interface(stateDescriptorMap.value("interface").toString()); QString interface(stateDescriptorMap.value("interface").toString());
QString interfaceState(stateDescriptorMap.value("interfaceState").toString()); QString interfaceState(stateDescriptorMap.value("interfaceState").toString());
QVariant value = stateDescriptorMap.value("value"); QVariant value = stateDescriptorMap.value("value");
Types::ValueOperator operatorType = (Types::ValueOperator)s_valueOperator.indexOf(stateDescriptorMap.value("operator").toString()); Types::ValueOperator operatorType = static_cast<Types::ValueOperator>(s_valueOperator.indexOf(stateDescriptorMap.value("operator").toString()));
if (!deviceId.isNull() && !stateTypeId.isNull()) { if (!deviceId.isNull() && !stateTypeId.isNull()) {
StateDescriptor stateDescriptor(stateTypeId, deviceId, value, operatorType); StateDescriptor stateDescriptor(stateTypeId, deviceId, value, operatorType);
return stateDescriptor; return stateDescriptor;
@ -1547,10 +1547,10 @@ LogFilter JsonTypes::unpackLogFilter(const QVariantMap &logFilterMap)
QVariantMap timeFilterMap = timeFilter.toMap(); QVariantMap timeFilterMap = timeFilter.toMap();
QDateTime startDate; QDateTime endDate; QDateTime startDate; QDateTime endDate;
if (timeFilterMap.contains("startDate")) if (timeFilterMap.contains("startDate"))
startDate = QDateTime::fromTime_t(timeFilterMap.value("startDate").toInt()); startDate = QDateTime::fromTime_t(timeFilterMap.value("startDate").toUInt());
if (timeFilterMap.contains("endDate")) if (timeFilterMap.contains("endDate"))
endDate = QDateTime::fromTime_t(timeFilterMap.value("endDate").toInt()); endDate = QDateTime::fromTime_t(timeFilterMap.value("endDate").toUInt());
filter.addTimeFilter(startDate, endDate); filter.addTimeFilter(startDate, endDate);
} }
@ -1559,19 +1559,19 @@ LogFilter JsonTypes::unpackLogFilter(const QVariantMap &logFilterMap)
if (logFilterMap.contains("loggingSources")) { if (logFilterMap.contains("loggingSources")) {
QVariantList loggingSources = logFilterMap.value("loggingSources").toList(); QVariantList loggingSources = logFilterMap.value("loggingSources").toList();
foreach (const QVariant &source, loggingSources) { foreach (const QVariant &source, loggingSources) {
filter.addLoggingSource((Logging::LoggingSource)s_loggingSource.indexOf(source.toString())); filter.addLoggingSource(static_cast<Logging::LoggingSource>(s_loggingSource.indexOf(source.toString())));
} }
} }
if (logFilterMap.contains("loggingLevels")) { if (logFilterMap.contains("loggingLevels")) {
QVariantList loggingLevels = logFilterMap.value("loggingLevels").toList(); QVariantList loggingLevels = logFilterMap.value("loggingLevels").toList();
foreach (const QVariant &level, loggingLevels) { foreach (const QVariant &level, loggingLevels) {
filter.addLoggingLevel((Logging::LoggingLevel)s_loggingLevel.indexOf(level.toString())); filter.addLoggingLevel(static_cast<Logging::LoggingLevel>(s_loggingLevel.indexOf(level.toString())));
} }
} }
if (logFilterMap.contains("eventTypes")) { if (logFilterMap.contains("eventTypes")) {
QVariantList eventTypes = logFilterMap.value("eventTypes").toList(); QVariantList eventTypes = logFilterMap.value("eventTypes").toList();
foreach (const QVariant &eventType, eventTypes) { foreach (const QVariant &eventType, eventTypes) {
filter.addLoggingEventType((Logging::LoggingEventType)s_loggingEventType.indexOf(eventType.toString())); filter.addLoggingEventType(static_cast<Logging::LoggingEventType>(s_loggingEventType.indexOf(eventType.toString())));
} }
} }
if (logFilterMap.contains("typeIds")) { if (logFilterMap.contains("typeIds")) {
@ -1605,7 +1605,7 @@ LogFilter JsonTypes::unpackLogFilter(const QVariantMap &logFilterMap)
/*! Returns a \l{RepeatingOption} created from the given \a repeatingOptionMap. */ /*! Returns a \l{RepeatingOption} created from the given \a repeatingOptionMap. */
RepeatingOption JsonTypes::unpackRepeatingOption(const QVariantMap &repeatingOptionMap) RepeatingOption JsonTypes::unpackRepeatingOption(const QVariantMap &repeatingOptionMap)
{ {
RepeatingOption::RepeatingMode mode = (RepeatingOption::RepeatingMode)s_repeatingMode.indexOf(repeatingOptionMap.value("mode").toString()); RepeatingOption::RepeatingMode mode = static_cast<RepeatingOption::RepeatingMode>(s_repeatingMode.indexOf(repeatingOptionMap.value("mode").toString()));
QList<int> weekDays; QList<int> weekDays;
if (repeatingOptionMap.contains("weekDays")) { if (repeatingOptionMap.contains("weekDays")) {

View File

@ -446,9 +446,9 @@ void NymeaCore::executeRuleActions(const QList<RuleAction> ruleActions)
if (ruleActionParam.isValueBased()) { if (ruleActionParam.isValueBased()) {
params.append(Param(ruleActionParam.paramTypeId(), ruleActionParam.value())); params.append(Param(ruleActionParam.paramTypeId(), ruleActionParam.value()));
} else if (ruleActionParam.isStateBased()) { } else if (ruleActionParam.isStateBased()) {
Device *stateDevice = m_deviceManager->findConfiguredDevice(ruleActionParam.deviceId()); Device *stateDevice = m_deviceManager->findConfiguredDevice(ruleActionParam.stateDeviceId());
if (!stateDevice) { if (!stateDevice) {
qCWarning(dcRuleEngine()) << "Cannot find device" << ruleActionParam.deviceId() << "required by rule action" << ruleAction.id(); qCWarning(dcRuleEngine()) << "Cannot find device" << ruleActionParam.stateDeviceId() << "required by rule action" << ruleAction.id();
ok = false; ok = false;
break; break;
} }
@ -490,9 +490,9 @@ void NymeaCore::executeRuleActions(const QList<RuleAction> ruleActions)
if (ruleActionParam.isValueBased()) { if (ruleActionParam.isValueBased()) {
params.append(Param(paramType.id(), ruleActionParam.value())); params.append(Param(paramType.id(), ruleActionParam.value()));
} else if (ruleActionParam.isStateBased()) { } else if (ruleActionParam.isStateBased()) {
Device *stateDevice = m_deviceManager->findConfiguredDevice(ruleActionParam.deviceId()); Device *stateDevice = m_deviceManager->findConfiguredDevice(ruleActionParam.stateDeviceId());
if (!stateDevice) { if (!stateDevice) {
qCWarning(dcRuleEngine()) << "Cannot find device" << ruleActionParam.deviceId() << "required by rule action" << ruleAction.id(); qCWarning(dcRuleEngine()) << "Cannot find device" << ruleActionParam.stateDeviceId() << "required by rule action" << ruleAction.id();
ok = false; ok = false;
break; break;
} }

View File

@ -414,11 +414,11 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
} }
foreach (const ParamType &ifaceActionParamType, ifaceActionType.paramTypes()) { foreach (const ParamType &ifaceActionParamType, ifaceActionType.paramTypes()) {
if (!action.ruleActionParams().hasParam(ifaceActionParamType.name())) { if (!action.ruleActionParams().hasParam(ifaceActionParamType.name())) {
qCWarning(dcRuleEngine()) << "Cannot create rule. Interface action" << iface.name() << ":" << action.interfaceAction() << "requires a" << ifaceActionParamType.name() << "param of type" << QVariant::typeToName(ifaceActionParamType.type()); qCWarning(dcRuleEngine()) << "Cannot create rule. Interface action" << iface.name() << ":" << action.interfaceAction() << "requires a" << ifaceActionParamType.name() << "param of type" << QVariant::typeToName(static_cast<int>(ifaceActionParamType.type()));
return RuleError::RuleErrorMissingParameter; return RuleError::RuleErrorMissingParameter;
} }
if (!action.ruleActionParam(ifaceActionParamType.name()).value().canConvert(ifaceActionParamType.type())) { if (!action.ruleActionParam(ifaceActionParamType.name()).value().canConvert(static_cast<int>(ifaceActionParamType.type()))) {
qCWarning(dcRuleEngine()) << "Cannot create rule. Interface action parameter" << iface.name() << ":" << action.interfaceAction() << ":" << ifaceActionParamType.name() << "has wrong type. Expected" << QVariant::typeToName(ifaceActionParamType.type()); qCWarning(dcRuleEngine()) << "Cannot create rule. Interface action parameter" << iface.name() << ":" << action.interfaceAction() << ":" << ifaceActionParamType.name() << "has wrong type. Expected" << QVariant::typeToName(static_cast<int>(ifaceActionParamType.type()));
return RuleError::RuleErrorInvalidParameter; return RuleError::RuleErrorInvalidParameter;
} }
} }
@ -443,7 +443,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
return RuleErrorTypesNotMatching; return RuleErrorTypesNotMatching;
} }
} else if (ruleActionParam.isStateBased()) { } else if (ruleActionParam.isStateBased()) {
Device *d = NymeaCore::instance()->deviceManager()->findConfiguredDevice(ruleActionParam.deviceId()); Device *d = NymeaCore::instance()->deviceManager()->findConfiguredDevice(ruleActionParam.stateDeviceId());
if (!d) { if (!d) {
qCWarning(dcRuleEngine()) << "Cannot create Rule. DeviceId from RuleAction" << action.actionTypeId() << "not found in system."; qCWarning(dcRuleEngine()) << "Cannot create Rule. DeviceId from RuleAction" << action.actionTypeId() << "not found in system.";
return RuleErrorDeviceNotFound; return RuleErrorDeviceNotFound;
@ -512,11 +512,11 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
} }
foreach (const ParamType &ifaceActionParamType, ifaceActionType.paramTypes()) { foreach (const ParamType &ifaceActionParamType, ifaceActionType.paramTypes()) {
if (!ruleExitAction.ruleActionParams().hasParam(ifaceActionParamType.name())) { if (!ruleExitAction.ruleActionParams().hasParam(ifaceActionParamType.name())) {
qCWarning(dcRuleEngine()) << "Cannot create rule. Interface action" << iface.name() << ":" << ruleExitAction.interfaceAction() << "requires a" << ifaceActionParamType.name() << "param of type" << QVariant::typeToName(ifaceActionParamType.type()); qCWarning(dcRuleEngine()) << "Cannot create rule. Interface action" << iface.name() << ":" << ruleExitAction.interfaceAction() << "requires a" << ifaceActionParamType.name() << "param of type" << QVariant::typeToName(static_cast<int>(ifaceActionParamType.type()));
return RuleError::RuleErrorMissingParameter; return RuleError::RuleErrorMissingParameter;
} }
if (!ruleExitAction.ruleActionParam(ifaceActionParamType.name()).value().canConvert(ifaceActionParamType.type())) { if (!ruleExitAction.ruleActionParam(ifaceActionParamType.name()).value().canConvert(static_cast<int>(ifaceActionParamType.type()))) {
qCWarning(dcRuleEngine()) << "Cannot create rule. Interface action parameter" << iface.name() << ":" << ruleExitAction.interfaceAction() << ":" << ifaceActionParamType.name() << "has wrong type. Expected" << QVariant::typeToName(ifaceActionParamType.type()); qCWarning(dcRuleEngine()) << "Cannot create rule. Interface action parameter" << iface.name() << ":" << ruleExitAction.interfaceAction() << ":" << ifaceActionParamType.name() << "has wrong type. Expected" << QVariant::typeToName(static_cast<int>(ifaceActionParamType.type()));
return RuleError::RuleErrorInvalidParameter; return RuleError::RuleErrorInvalidParameter;
} }
} }
@ -528,7 +528,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
qCWarning(dcRuleEngine) << "Cannot create rule. Exit actions cannot be event based."; qCWarning(dcRuleEngine) << "Cannot create rule. Exit actions cannot be event based.";
return RuleErrorInvalidRuleActionParameter; return RuleErrorInvalidRuleActionParameter;
} else if (ruleActionParam.isStateBased()) { } else if (ruleActionParam.isStateBased()) {
Device *d = NymeaCore::instance()->deviceManager()->findConfiguredDevice(ruleActionParam.deviceId()); Device *d = NymeaCore::instance()->deviceManager()->findConfiguredDevice(ruleActionParam.stateDeviceId());
if (!d) { if (!d) {
qCWarning(dcRuleEngine()) << "Cannot create Rule. DeviceId from RuleAction" << ruleExitAction.actionTypeId() << "not found in system."; qCWarning(dcRuleEngine()) << "Cannot create Rule. DeviceId from RuleAction" << ruleExitAction.actionTypeId() << "not found in system.";
return RuleErrorDeviceNotFound; return RuleErrorDeviceNotFound;
@ -1192,7 +1192,7 @@ void RuleEngine::saveRule(const Rule &rule)
} else { } else {
settings.beginGroup("ParamDescriptor-" + paramDescriptor.paramName()); settings.beginGroup("ParamDescriptor-" + paramDescriptor.paramName());
} }
settings.setValue("valueType", (int)paramDescriptor.value().type()); settings.setValue("valueType", static_cast<int>(paramDescriptor.value().type()));
settings.setValue("value", paramDescriptor.value()); settings.setValue("value", paramDescriptor.value());
settings.setValue("operator", paramDescriptor.operatorType()); settings.setValue("operator", paramDescriptor.operatorType());
settings.endGroup(); settings.endGroup();
@ -1228,7 +1228,7 @@ void RuleEngine::saveRule(const Rule &rule)
settings.setValue("eventTypeId", param.eventTypeId().toString()); settings.setValue("eventTypeId", param.eventTypeId().toString());
settings.setValue("eventParamTypeId", param.eventParamTypeId()); settings.setValue("eventParamTypeId", param.eventParamTypeId());
} else if (param.isStateBased()) { } else if (param.isStateBased()) {
settings.setValue("deviceId", param.deviceId().toString()); settings.setValue("stateDeviceId", param.stateDeviceId().toString());
settings.setValue("stateTypeId", param.stateTypeId()); settings.setValue("stateTypeId", param.stateTypeId());
} }
settings.endGroup(); settings.endGroup();
@ -1256,7 +1256,7 @@ void RuleEngine::saveRule(const Rule &rule)
} else { } else {
settings.beginGroup("RuleActionParam-" + param.paramName()); settings.beginGroup("RuleActionParam-" + param.paramName());
} }
settings.setValue("valueType", (int)param.value().type()); settings.setValue("valueType", static_cast<int>(param.value().type()));
settings.setValue("value", param.value()); settings.setValue("value", param.value());
settings.endGroup(); settings.endGroup();
} }
@ -1383,24 +1383,24 @@ void RuleEngine::init()
QVariant value = settings.value("value"); QVariant value = settings.value("value");
if (settings.contains("valueType")) { if (settings.contains("valueType")) {
QVariant::Type valueType = (QVariant::Type)settings.value("valueType").toInt(); QVariant::Type valueType = static_cast<QVariant::Type>(settings.value("valueType").toInt());
// Note: only warn, and continue with the QVariant guessed type // Note: only warn, and continue with the QVariant guessed type
if (valueType == QVariant::Invalid) { if (valueType == QVariant::Invalid) {
qCWarning(dcRuleEngine()) << name << idString << "Could not load the value type of the param descriptor" << strippedGroupName << ". The value type will be guessed by QVariant."; qCWarning(dcRuleEngine()) << name << idString << "Could not load the value type of the param descriptor" << strippedGroupName << ". The value type will be guessed by QVariant.";
} else if (!value.canConvert(valueType)) { } else if (!value.canConvert(static_cast<int>(valueType))) {
qCWarning(dcRuleEngine()) << "Error loading rule" << name << idString << ". Could not convert the param descriptor value" << value << "to the stored type" << valueType; qCWarning(dcRuleEngine()) << "Error loading rule" << name << idString << ". Could not convert the param descriptor value" << value << "to the stored type" << valueType;
} else { } else {
value.convert(valueType); value.convert(static_cast<int>(valueType));
} }
} }
if (!ParamTypeId(strippedGroupName).isNull()) { if (!ParamTypeId(strippedGroupName).isNull()) {
ParamDescriptor paramDescriptor(ParamTypeId(strippedGroupName), value); ParamDescriptor paramDescriptor(ParamTypeId(strippedGroupName), value);
paramDescriptor.setOperatorType((Types::ValueOperator)settings.value("operator").toInt()); paramDescriptor.setOperatorType(static_cast<Types::ValueOperator>(settings.value("operator").toInt()));
params.append(paramDescriptor); params.append(paramDescriptor);
} else { } else {
ParamDescriptor paramDescriptor(strippedGroupName, value); ParamDescriptor paramDescriptor(strippedGroupName, value);
paramDescriptor.setOperatorType((Types::ValueOperator)settings.value("operator").toInt()); paramDescriptor.setOperatorType(static_cast<Types::ValueOperator>(settings.value("operator").toInt()));
params.append(paramDescriptor); params.append(paramDescriptor);
} }
settings.endGroup(); settings.endGroup();
@ -1436,18 +1436,18 @@ void RuleEngine::init()
QString strippedParamTypeIdString = paramTypeIdString.remove(QRegExp("^RuleActionParam-")); QString strippedParamTypeIdString = paramTypeIdString.remove(QRegExp("^RuleActionParam-"));
EventTypeId eventTypeId = EventTypeId(settings.value("eventTypeId", EventTypeId()).toString()); EventTypeId eventTypeId = EventTypeId(settings.value("eventTypeId", EventTypeId()).toString());
ParamTypeId eventParamTypeId = ParamTypeId(settings.value("eventParamTypeId", ParamTypeId()).toString()); ParamTypeId eventParamTypeId = ParamTypeId(settings.value("eventParamTypeId", ParamTypeId()).toString());
DeviceId deviceId = DeviceId(settings.value("deviceId", DeviceId()).toString()); DeviceId stateDeviceId = DeviceId(settings.value("stateDeviceId", DeviceId()).toString());
StateTypeId stateTypeId = StateTypeId(settings.value("stateTypeId", StateTypeId()).toString()); StateTypeId stateTypeId = StateTypeId(settings.value("stateTypeId", StateTypeId()).toString());
QVariant value = settings.value("value"); QVariant value = settings.value("value");
if (settings.contains("valueType")) { if (settings.contains("valueType")) {
QVariant::Type valueType = (QVariant::Type)settings.value("valueType").toInt(); QVariant::Type valueType = static_cast<QVariant::Type>(settings.value("valueType").toInt());
// Note: only warn, and continue with the QVariant guessed type // Note: only warn, and continue with the QVariant guessed type
if (valueType == QVariant::Invalid) { if (valueType == QVariant::Invalid) {
qCWarning(dcRuleEngine()) << name << idString << "Could not load the value type of the rule action param " << strippedParamTypeIdString << ". The value type will be guessed by QVariant."; qCWarning(dcRuleEngine()) << name << idString << "Could not load the value type of the rule action param " << strippedParamTypeIdString << ". The value type will be guessed by QVariant.";
} else if (!value.canConvert(valueType)) { } else if (!value.canConvert(static_cast<int>(valueType))) {
qCWarning(dcRuleEngine()) << "Error loading rule" << name << idString << ". Could not convert the rule action param value" << value << "to the stored type" << valueType; qCWarning(dcRuleEngine()) << "Error loading rule" << name << idString << ". Could not convert the rule action param value" << value << "to the stored type" << valueType;
} else { } else {
value.convert(valueType); value.convert(static_cast<int>(valueType));
} }
} }
@ -1461,7 +1461,7 @@ void RuleEngine::init()
} }
param.setEventTypeId(eventTypeId); param.setEventTypeId(eventTypeId);
param.setEventParamTypeId(eventParamTypeId); param.setEventParamTypeId(eventParamTypeId);
param.setDeviceId(deviceId); param.setStateDeviceId(stateDeviceId);
param.setStateTypeId(stateTypeId); param.setStateTypeId(stateTypeId);
params.append(param); params.append(param);
params.append(param); params.append(param);
@ -1496,14 +1496,14 @@ void RuleEngine::init()
QString strippedParamTypeIdString = paramTypeIdString.remove(QRegExp("^RuleActionParam-")); QString strippedParamTypeIdString = paramTypeIdString.remove(QRegExp("^RuleActionParam-"));
QVariant value = settings.value("value"); QVariant value = settings.value("value");
if (settings.contains("valueType")) { if (settings.contains("valueType")) {
QVariant::Type valueType = (QVariant::Type)settings.value("valueType").toInt(); QVariant::Type valueType = static_cast<QVariant::Type>(settings.value("valueType").toInt());
// Note: only warn, and continue with the QVariant guessed type // Note: only warn, and continue with the QVariant guessed type
if (valueType == QVariant::Invalid) { if (valueType == QVariant::Invalid) {
qCWarning(dcRuleEngine()) << name << idString << "Could not load the value type of the rule action param " << strippedParamTypeIdString << ". The value type will be guessed by QVariant."; qCWarning(dcRuleEngine()) << name << idString << "Could not load the value type of the rule action param " << strippedParamTypeIdString << ". The value type will be guessed by QVariant.";
} else if (!value.canConvert(valueType)) { } else if (!value.canConvert(static_cast<int>(valueType))) {
qCWarning(dcRuleEngine()) << "Error loading rule" << name << idString << ". Could not convert the rule action param value" << value << "to the stored type" << valueType; qCWarning(dcRuleEngine()) << "Error loading rule" << name << idString << ". Could not convert the rule action param value" << value << "to the stored type" << valueType;
} else { } else {
value.convert(valueType); value.convert(static_cast<int>(valueType));
} }
} }

View File

@ -79,11 +79,11 @@ RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const EventType
} }
/*! Constructs a \l{RuleActionParam} with the given \a paramTypeId, \a deviceId and \a stateTypeId. /*! Constructs a \l{RuleActionParam} with the given \a paramTypeId, \a stateDeviceId and \a stateTypeId.
* \sa Param, Event, */ * \sa Param, Event, */
RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const DeviceId &deviceId, const StateTypeId &stateTypeId): RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const DeviceId &stateDeviceId, const StateTypeId &stateTypeId):
m_paramTypeId(paramTypeId), m_paramTypeId(paramTypeId),
m_deviceId(deviceId), m_stateDeviceId(stateDeviceId),
m_stateTypeId(stateTypeId) m_stateTypeId(stateTypeId)
{ {
@ -108,11 +108,11 @@ RuleActionParam::RuleActionParam(const QString &paramName, const EventTypeId &ev
} }
/*! Constructs a \l{RuleActionParam} with the given \a paramName, \a deviceId and \a stateTypeId. /*! Constructs a \l{RuleActionParam} with the given \a paramName, \a stateDeviceId and \a stateTypeId.
* \sa Param, Event, */ * \sa Param, Event, */
RuleActionParam::RuleActionParam(const QString &paramName, const DeviceId &deviceId, const StateTypeId &stateTypeId): RuleActionParam::RuleActionParam(const QString &paramName, const DeviceId &stateDeviceId, const StateTypeId &stateTypeId):
m_paramName(paramName), m_paramName(paramName),
m_deviceId(deviceId), m_stateDeviceId(stateDeviceId),
m_stateTypeId(stateTypeId) m_stateTypeId(stateTypeId)
{ {
@ -167,15 +167,15 @@ void RuleActionParam::setEventParamTypeId(const ParamTypeId &eventParamTypeId)
} }
/*! Returns the deviceId identifying the device to use a state value from. */ /*! Returns the deviceId identifying the device to use a state value from. */
DeviceId RuleActionParam::deviceId() const DeviceId RuleActionParam::stateDeviceId() const
{ {
return m_deviceId; return m_stateDeviceId;
} }
/*! Sets the deviceId identifying the device to use a state value from. */ /*! Sets the deviceId identifying the device to use a state value from. */
void RuleActionParam::setDeviceId(const DeviceId &deviceId) void RuleActionParam::setStateDeviceId(const DeviceId &stateDeviceId)
{ {
m_deviceId = deviceId; m_stateDeviceId = stateDeviceId;
} }
/*! Returns the stateTypeId identifying the state to use the value. */ /*! Returns the stateTypeId identifying the state to use the value. */
@ -211,7 +211,7 @@ bool RuleActionParam::isEventBased() const
bool RuleActionParam::isStateBased() const bool RuleActionParam::isStateBased() const
{ {
return !m_deviceId.isNull() && !m_stateTypeId.isNull(); return !m_stateDeviceId.isNull() && !m_stateTypeId.isNull();
} }
/*! Writes the paramTypeId, value, eventId and eventParamTypeId of the given \a ruleActionParam to \a dbg. */ /*! Writes the paramTypeId, value, eventId and eventParamTypeId of the given \a ruleActionParam to \a dbg. */

View File

@ -38,10 +38,10 @@ public:
RuleActionParam(const Param &param = Param()); RuleActionParam(const Param &param = Param());
RuleActionParam(const ParamTypeId &paramTypeId, const QVariant &value = QVariant()); RuleActionParam(const ParamTypeId &paramTypeId, const QVariant &value = QVariant());
RuleActionParam(const ParamTypeId &paramTypeId, const EventTypeId &eventTypeId, const ParamTypeId &eventParamTypeId); RuleActionParam(const ParamTypeId &paramTypeId, const EventTypeId &eventTypeId, const ParamTypeId &eventParamTypeId);
RuleActionParam(const ParamTypeId &paramTypeId, const DeviceId &deviceId, const StateTypeId &stateTypeId); RuleActionParam(const ParamTypeId &paramTypeId, const DeviceId &stateDeviceId, const StateTypeId &stateTypeId);
RuleActionParam(const QString &paramName, const QVariant &value = QVariant()); RuleActionParam(const QString &paramName, const QVariant &value = QVariant());
RuleActionParam(const QString &paramName, const EventTypeId &eventTypeId, const ParamTypeId &eventParamTypeId); RuleActionParam(const QString &paramName, const EventTypeId &eventTypeId, const ParamTypeId &eventParamTypeId);
RuleActionParam(const QString &paramName, const DeviceId &deviceId, const StateTypeId &stateTypeId); RuleActionParam(const QString &paramName, const DeviceId &stateDeviceId, const StateTypeId &stateTypeId);
ParamTypeId paramTypeId() const; ParamTypeId paramTypeId() const;
QString paramName() const; QString paramName() const;
@ -60,8 +60,8 @@ public:
ParamTypeId eventParamTypeId() const; ParamTypeId eventParamTypeId() const;
void setEventParamTypeId(const ParamTypeId &eventParamTypeId); void setEventParamTypeId(const ParamTypeId &eventParamTypeId);
DeviceId deviceId() const; DeviceId stateDeviceId() const;
void setDeviceId(const DeviceId &deviceId); void setStateDeviceId(const DeviceId &deviceId);
StateTypeId stateTypeId() const; StateTypeId stateTypeId() const;
void setStateTypeId(const StateTypeId &stateTypeId); void setStateTypeId(const StateTypeId &stateTypeId);
@ -74,7 +74,7 @@ private:
EventTypeId m_eventTypeId; EventTypeId m_eventTypeId;
ParamTypeId m_eventParamTypeId; ParamTypeId m_eventParamTypeId;
DeviceId m_deviceId; DeviceId m_stateDeviceId;
StateTypeId m_stateTypeId; StateTypeId m_stateTypeId;
}; };