Object editation bugfixing and finishing

This commit is contained in:
Jakub Melka
2020-12-23 17:46:25 +01:00
parent 96ae91b36d
commit 5c7c0a5898
5 changed files with 211 additions and 2 deletions

View File

@ -197,6 +197,7 @@ void PDFObjectEditorAbstractModel::setEditedObject(PDFObject object)
if (m_editedObject != object)
{
m_editedObject = qMove(object);
updateSelectorValues();
emit editedObjectChanged();
}
}
@ -240,6 +241,34 @@ QVariant PDFObjectEditorAbstractModel::getMaximumValue(size_t index) const
return m_attributes.at(index).maxValue;
}
void PDFObjectEditorAbstractModel::updateSelectorValues()
{
// Turn on selectors, which have some dependent attribute,
// which have value in the persisted object.
for (size_t index = 0; index < getAttributeCount(); ++index)
{
if (!queryAttribute(index, Question::IsSelector))
{
continue;
}
bool hasPersistedAttribute = false;
for (size_t dependentAttribute : getSelectorDependentAttributes(index))
{
if (!getValue(dependentAttribute).isNull())
{
hasPersistedAttribute = true;
break;
}
}
if (hasPersistedAttribute)
{
setSelectorValue(index, true);
}
}
}
size_t PDFObjectEditorAbstractModel::createAttribute(ObjectEditorAttributeType type,
QByteArray attributeName,
QString category,