Gui: allow to set ranges for property item editors when used as sub-items

This commit is contained in:
wmayer
2024-02-19 00:07:29 +01:00
committed by wwmayer
parent b85aabcc88
commit 906e163e12
2 changed files with 59 additions and 7 deletions

View File

@@ -976,9 +976,11 @@ void PropertyIntegerConstraintItem::setEditorData(QWidget *editor, const QVarian
sb->setSingleStep(c->StepSize);
}
else {
sb->setMinimum(INT_MIN);
sb->setMaximum(INT_MAX);
sb->setMinimum(min);
sb->setMaximum(max);
sb->setSingleStep(steps);
}
sb->setValue(data.toInt());
}
@@ -1167,8 +1169,9 @@ void PropertyUnitConstraintItem::setEditorData(QWidget *editor, const QVariant&
infield->setSingleStep(c->StepSize);
}
else {
infield->setMinimum((double)INT_MIN);
infield->setMaximum((double)INT_MAX);
infield->setMinimum(min);
infield->setMaximum(max);
infield->setSingleStep(steps);
}
}
@@ -1238,10 +1241,11 @@ void PropertyFloatConstraintItem::setEditorData(QWidget *editor, const QVariant&
sb->setSingleStep(c->StepSize);
}
else {
sb->setMinimum((double)INT_MIN);
sb->setMaximum((double)INT_MAX);
sb->setSingleStep(0.1);
sb->setMinimum(min);
sb->setMaximum(max);
sb->setSingleStep(steps);
}
sb->setValue(data.toDouble());
}

View File

@@ -316,6 +316,17 @@ class GuiExport PropertyIntegerConstraintItem: public PropertyItem
void setEditorData(QWidget *editor, const QVariant& data) const override;
QVariant editorData(QWidget *editor) const override;
void setRange(int min, int max)
{
this->min = min;
this->max = max;
}
void setStepSize(int steps)
{
this->steps = steps;
}
protected:
QVariant toString(const QVariant&) const override;
QVariant value(const App::Property*) const override;
@@ -323,6 +334,11 @@ protected:
protected:
PropertyIntegerConstraintItem();
private:
int min = INT_MIN;
int max = INT_MAX;
int steps = 1;
};
/**
@@ -379,8 +395,24 @@ class GuiExport PropertyUnitConstraintItem: public PropertyUnitItem
void setEditorData(QWidget *editor, const QVariant& data) const override;
void setRange(double min, double max)
{
this->min = min;
this->max = max;
}
void setStepSize(double steps)
{
this->steps = steps;
}
protected:
PropertyUnitConstraintItem();
private:
double min = double(INT_MIN);
double max = double(INT_MAX);
double steps = 0.1;
};
/**
@@ -396,6 +428,17 @@ class GuiExport PropertyFloatConstraintItem: public PropertyItem
void setEditorData(QWidget *editor, const QVariant& data) const override;
QVariant editorData(QWidget *editor) const override;
void setRange(double min, double max)
{
this->min = min;
this->max = max;
}
void setStepSize(double steps)
{
this->steps = steps;
}
protected:
QVariant toString(const QVariant&) const override;
QVariant value(const App::Property*) const override;
@@ -403,6 +446,11 @@ protected:
protected:
PropertyFloatConstraintItem();
private:
double min = double(INT_MIN);
double max = double(INT_MAX);
double steps = 0.1;
};
/**