Refactor and rename QIconProvider -> IconProvider (#5893)

* Refactor and rename QIconProvider -> IconProvider
* Generate icons on demand as unique_ptrs
This commit is contained in:
Gaute Lindkvist
2020-05-09 11:25:11 +02:00
committed by GitHub
parent b84e868564
commit 2e79cf614f
42 changed files with 383 additions and 379 deletions

View File

@@ -71,9 +71,10 @@ void PdmUiActionPushButtonEditor::configureAndUpdateUi( const QString& uiConfigN
m_buttonLayout->setAlignment(Qt::AlignRight);
if( !uiField()->uiIcon( uiConfigName ).isNull() )
auto icon = uiField()->uiIcon(uiConfigName);
if( icon )
{
m_pushButton->setIcon( uiField()->uiIcon( uiConfigName ) );
m_pushButton->setIcon( *icon );
m_pushButton->setMaximumWidth(m_pushButton->sizeHint().width());
}
else

View File

@@ -211,7 +211,11 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
{
for (const auto& option : options)
{
m_comboBox->addItem(option.icon(), option.optionUiText());
auto icon = option.icon();
if (icon)
m_comboBox->addItem(*icon, option.optionUiText());
else
m_comboBox->addItem(option.optionUiText());
m_comboBox->setIconSize(m_attributes.iconSize);
}
m_comboBox->setCurrentIndex(uiField()->uiValue().toInt());

View File

@@ -184,15 +184,16 @@ void PdmUiTableViewEditor::configureAndUpdateUi(const QString& uiConfigName)
if (childArrayFH && childArrayFH->uiCapability())
{
QString text = "";
if ( childArrayFH->uiCapability()->uiIcon(uiConfigName).isNull() )
auto icon = childArrayFH->uiCapability()->uiIcon(uiConfigName);
if ( icon )
{
m_tableHeadingIcon->setText(childArrayFH->uiCapability()->uiName(uiConfigName) + QString(" (%1)").arg(childArrayFH->size()));
m_tableHeading->setText("");
m_tableHeadingIcon->setPixmap(icon->pixmap(16, 16));
m_tableHeading->setText(childArrayFH->uiCapability()->uiName(uiConfigName) + QString(" (%1)").arg(childArrayFH->size()));
}
else
{
m_tableHeadingIcon->setPixmap(childArrayFH->uiCapability()->uiIcon(uiConfigName).pixmap(16, 16));
m_tableHeading->setText(childArrayFH->uiCapability()->uiName(uiConfigName) + QString(" (%1)").arg(childArrayFH->size()));
m_tableHeadingIcon->setText(childArrayFH->uiCapability()->uiName(uiConfigName) + QString(" (%1)").arg(childArrayFH->size()));
m_tableHeading->setText("");
}
m_tableModelPdm->createPersistentPushButtonWidgets(m_tableView);
}

View File

@@ -56,10 +56,10 @@ void PdmUiToolButtonEditor::configureAndUpdateUi(const QString& uiConfigName)
{
CAF_ASSERT(!m_toolButton.isNull());
QIcon ic = uiField()->uiIcon(uiConfigName);
if (!ic.isNull())
auto ic = uiField()->uiIcon(uiConfigName);
if (ic)
{
m_toolButton->setIcon(ic);
m_toolButton->setIcon(*ic);
}
QString buttonText = uiField()->uiName(uiConfigName);

View File

@@ -356,7 +356,8 @@ QVariant caf::PdmUiTreeSelectionQModel::data(const QModelIndex &index, int role
}
else if (role == Qt::DecorationRole)
{
return optionItemInfo->icon();
auto icon = optionItemInfo->icon();
return icon ? *icon : QIcon();
}
else if (role == Qt::CheckStateRole && !optionItemInfo->isHeading())
{

View File

@@ -631,7 +631,8 @@ QVariant PdmUiTreeViewQModel::data(const QModelIndex &index, int role ) const
{
if (uitreeOrdering->activeItem())
{
return uitreeOrdering->activeItem()->uiIcon();
auto icon = uitreeOrdering->activeItem()->uiIcon();
return icon ? *icon : QIcon();
}
else
{