Material: Problems editing Quantity properties
There were several issues here, not just one. The following are fixed: Incorrect display of Quantity items (NaN) Editing and updating quantity items Editing and updating items on the first row. There are still issues with editing lists, but these were known issues at the time of initial merge. This has been split out into issue #13435 fixes #13020
This commit is contained in:
committed by
Chris Hennes
parent
0c25b29680
commit
8d5e2bc428
@@ -62,6 +62,15 @@ MaterialDelegate::MaterialDelegate(QObject* parent)
|
||||
: BaseDelegate(parent)
|
||||
{}
|
||||
|
||||
bool MaterialDelegate::newRow(const QAbstractItemModel* model, const QModelIndex& index) const
|
||||
{
|
||||
Q_UNUSED(model)
|
||||
Q_UNUSED(index)
|
||||
|
||||
// New rows are for lists and arrays
|
||||
return false;
|
||||
}
|
||||
|
||||
Materials::MaterialValue::ValueType MaterialDelegate::getType(const QModelIndex& index) const
|
||||
{
|
||||
auto treeModel = dynamic_cast<const QStandardItemModel*>(index.model());
|
||||
@@ -131,7 +140,6 @@ void MaterialDelegate::setValue(QAbstractItemModel* model,
|
||||
int row = index.row();
|
||||
if (group->child(row, 1)) {
|
||||
auto material = group->child(row, 1)->data().value<std::shared_ptr<Materials::Material>>();
|
||||
// auto propertyName = group->child(row, 0)->text();
|
||||
auto propertyName = group->child(row, 0)->data().toString();
|
||||
std::string _name = propertyName.toStdString();
|
||||
auto property = material->getProperty(propertyName);
|
||||
@@ -145,7 +153,6 @@ void MaterialDelegate::setValue(QAbstractItemModel* model,
|
||||
void MaterialDelegate::notifyChanged(const QAbstractItemModel* model,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
Base::Console().Log("MaterialDelegate::notifyChanged()\n");
|
||||
auto treeModel = dynamic_cast<const QStandardItemModel*>(model);
|
||||
auto item = treeModel->itemFromIndex(index);
|
||||
auto group = item->parent();
|
||||
@@ -160,10 +167,8 @@ void MaterialDelegate::notifyChanged(const QAbstractItemModel* model,
|
||||
auto propertyName = group->child(row, 0)->data().toString();
|
||||
auto propertyValue = material->getProperty(propertyName)->getValue();
|
||||
material->setEditStateAlter();
|
||||
Base::Console().Log("MaterialDelegate::notifyChanged() - marked altered\n");
|
||||
|
||||
Q_EMIT const_cast<MaterialDelegate*>(this)->propertyChange(propertyName,
|
||||
propertyValue.toString());
|
||||
Q_EMIT const_cast<MaterialDelegate*>(this)->propertyChange(propertyName, propertyValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,11 +452,12 @@ QWidget* MaterialDelegate::createWidget(QWidget* parent,
|
||||
widget = combo;
|
||||
}
|
||||
else if (type == Materials::MaterialValue::Quantity) {
|
||||
auto input = new Gui::InputField(parent);
|
||||
// auto input = new Gui::InputField(parent);
|
||||
auto input = new Gui::QuantitySpinBox(parent);
|
||||
input->setMinimum(std::numeric_limits<double>::min());
|
||||
input->setMaximum(std::numeric_limits<double>::max());
|
||||
input->setUnitText(getUnits(index));
|
||||
input->setPrecision(6);
|
||||
// input->setPrecision(6);
|
||||
input->setValue(item.value<Base::Quantity>());
|
||||
|
||||
widget = input;
|
||||
|
||||
Reference in New Issue
Block a user