Fix valid count range for variable fields

To allow full range of a field, the "count" of a variable field,
 * Minimum should be 1, not 0
 * Maximum should be max value of field + 1

Fixes #301
This commit is contained in:
Srivats P 2020-05-04 19:15:49 +05:30
parent bd20ec724f
commit ad38a60171

View File

@ -297,7 +297,7 @@ void VariableFieldsWidget::on_type_currentIndexChanged(int index)
bitmask->setInputMask("HH"); bitmask->setInputMask("HH");
bitmask->setText("FF"); bitmask->setText("FF");
valueRange_->setRange(0, 0xFF); valueRange_->setRange(0, 0xFF);
count->setRange(0, 0xFF); count->setRange(1, 0x100);
step->setRange(0, 0xFF); step->setRange(0, 0xFF);
break; break;
case OstProto::VariableField::kCounter16: case OstProto::VariableField::kCounter16:
@ -305,7 +305,7 @@ void VariableFieldsWidget::on_type_currentIndexChanged(int index)
bitmask->setInputMask("HHHH"); bitmask->setInputMask("HHHH");
bitmask->setText("FFFF"); bitmask->setText("FFFF");
valueRange_->setRange(0, 0xFFFF); valueRange_->setRange(0, 0xFFFF);
count->setRange(0, 0xFFFF); count->setRange(1, 0x10000);
step->setRange(0, 0xFFFF); step->setRange(0, 0xFFFF);
break; break;
case OstProto::VariableField::kCounter32: case OstProto::VariableField::kCounter32:
@ -313,7 +313,7 @@ void VariableFieldsWidget::on_type_currentIndexChanged(int index)
bitmask->setInputMask("HHHHHHHH"); bitmask->setInputMask("HHHHHHHH");
bitmask->setText("FFFFFFFF"); bitmask->setText("FFFFFFFF");
valueRange_->setRange(0, 0xFFFFFFFF); valueRange_->setRange(0, 0xFFFFFFFF);
count->setRange(0, 0x7FFFFFFF); count->setRange(1, 0x7FFFFFFF); // XXX: QSpinBox max limited to int32
step->setRange(0, 0x7FFFFFFF); step->setRange(0, 0x7FFFFFFF);
break; break;
default: default: