Utils: Introduce a staging area for gui values

Accessing gui elements is very aspect-specific, whereas the
rules when and how values are synchronized are rather general.

Splitting the two concepts and having a permanent 'buffer' area
that is synchronized with the gui elements if and only if they
have been created helps to keep the boilerplate needed per-aspect
at a minimum.

This value could also serve as "model" in case we wanted to allow
multiple "views" in different places of the gui onto that aspect.

Change-Id: I34832512b99c53cb0e4df437ee9b4c5d17a2ad8f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-12 15:41:06 +02:00
parent 433f8a3241
commit 4ab1d75ee6
6 changed files with 211 additions and 213 deletions

View File

@@ -159,17 +159,17 @@ void SuppressionAspect::toMap(QVariantMap &map) const
BaseAspect::toMap(map);
}
void SuppressionAspect::guiToInternal()
void SuppressionAspect::guiToBuffer()
{
m_internal.clear();
m_buffer.clear();
for (int i = 0; i < d->m_model.rowCount(); ++i)
m_internal.append(FilePath::fromUserInput(d->m_model.item(i)->text()));
m_buffer.append(FilePath::fromUserInput(d->m_model.item(i)->text()));
}
void SuppressionAspect::internalToGui()
void SuppressionAspect::bufferToGui()
{
d->m_model.clear();
for (const FilePath &file : m_internal)
for (const FilePath &file : m_buffer)
d->m_model.appendRow(new QStandardItem(file.toUserOutput()));
}