mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactor and rename QIconProvider -> IconProvider (#5893)
* Refactor and rename QIconProvider -> IconProvider * Generate icons on demand as unique_ptrs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user