mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Qt6: Fix deprecated QVariant::type() calls.
Use recommended QMetaData::type().id() instead.
This commit is contained in:
parent
58656f900b
commit
bf1c7f4b04
@ -24,7 +24,7 @@ void PdmFieldUiCap<FieldType>::setValueFromUiEditor( const QVariant& uiValue, bo
|
||||
if ( !m_optionEntryCache.empty() )
|
||||
{
|
||||
// This has an option based GUI, the uiValue is only indexes into the m_optionEntryCache
|
||||
if ( uiValue.type() == QVariant::UInt )
|
||||
if ( uiValue.metaType().id() == QMetaType::UInt )
|
||||
{
|
||||
uint optionIndex = uiValue.toUInt();
|
||||
CAF_ASSERT( optionIndex < static_cast<unsigned int>( m_optionEntryCache.size() ) );
|
||||
@ -35,7 +35,7 @@ void PdmFieldUiCap<FieldType>::setValueFromUiEditor( const QVariant& uiValue, bo
|
||||
PdmUiFieldSpecialization<typename FieldType::FieldDataType>::setFromVariant( optionVariantValue, fieldValue );
|
||||
m_field->setValue( fieldValue );
|
||||
}
|
||||
else if ( uiValue.type() == QVariant::List )
|
||||
else if ( uiValue.metaType().id() == QMetaType::QVariantList )
|
||||
{
|
||||
QList<QVariant> selectedIndexes = uiValue.toList();
|
||||
QList<QVariant> valuesToSetInField;
|
||||
@ -48,7 +48,7 @@ void PdmFieldUiCap<FieldType>::setValueFromUiEditor( const QVariant& uiValue, bo
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( selectedIndexes.front().type() == QVariant::UInt )
|
||||
if ( selectedIndexes.front().metaType().id() == QMetaType::UInt )
|
||||
{
|
||||
for ( int i = 0; i < selectedIndexes.size(); ++i )
|
||||
{
|
||||
@ -132,7 +132,7 @@ QVariant PdmFieldUiCap<FieldType>::uiValue() const
|
||||
PdmOptionItemInfo::findValues<typename FieldType::FieldDataType>( m_optionEntryCache,
|
||||
uiBasedQVariant,
|
||||
indexesToFoundOptions );
|
||||
if ( uiBasedQVariant.type() == QVariant::List )
|
||||
if ( uiBasedQVariant.metaType().id() == QMetaType::QVariantList )
|
||||
{
|
||||
if ( isAutoAddingOptionFromValue() &&
|
||||
indexesToFoundOptions.size() != static_cast<size_t>( uiBasedQVariant.toList().size() ) )
|
||||
@ -217,7 +217,7 @@ QList<PdmOptionItemInfo> PdmFieldUiCap<FieldType>::valueOptions() const
|
||||
|
||||
if ( !foundAllFieldValues )
|
||||
{
|
||||
if ( uiBasedQVariant.type() != QVariant::List ) // Single value field
|
||||
if ( uiBasedQVariant.metaType().id() != QMetaType::QVariantList ) // Single value field
|
||||
{
|
||||
if ( !uiBasedQVariant.toString().isEmpty() )
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
/// This is needed for the lookup regarding OptionValues
|
||||
static bool isDataElementEqual( const QVariant& variantValue, const QVariant& variantValue2 )
|
||||
{
|
||||
if ( variantValue.type() == QVariant::UserType )
|
||||
if ( variantValue.typeId() > QMetaType::User )
|
||||
{
|
||||
return ( variantValue.value<T>() == variantValue2.value<T>() );
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ bool PdmOptionItemInfo::findValues( const QList<PdmOptionItemInfo>& optionList,
|
||||
// Find this fieldvalue in the optionlist if present
|
||||
|
||||
// First handle lists/arrays of values
|
||||
if ( fieldValue.type() == QVariant::List )
|
||||
if ( fieldValue.metaType().id() == QMetaType::QVariantList )
|
||||
{
|
||||
QList<QVariant> valuesSelectedInField = fieldValue.toList();
|
||||
|
||||
|
@ -81,7 +81,7 @@ void PdmUiActionPushButtonEditor::configureAndUpdateUi( const QString& uiConfigN
|
||||
|
||||
QVariant variantFieldValue = uiField()->uiValue();
|
||||
|
||||
if ( variantFieldValue.type() == QVariant::Bool )
|
||||
if ( variantFieldValue.metaType().id() == QMetaType::Bool )
|
||||
{
|
||||
m_pushButton->setChecked( uiField()->uiValue().toBool() );
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ caf::PdmUiFieldEditorHandle* caf::PdmUiFieldEditorHelper::createFieldEditorForFi
|
||||
// https://github.com/OPM/ResInsight/issues/10483
|
||||
fieldTypeName = caf::PdmUiListEditor::uiEditorTypeName();
|
||||
}
|
||||
else if ( field->toUiBasedQVariant().type() != QVariant::List )
|
||||
else if ( field->toUiBasedQVariant().metaType().id() != QMetaType::QVariantList )
|
||||
{
|
||||
// Handle a single value field with valueOptions: Make a combobox
|
||||
|
||||
|
@ -196,7 +196,7 @@ void PdmUiListEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
strListModel->setStringList( texts );
|
||||
|
||||
QVariant fieldValue = uiField()->uiValue();
|
||||
if ( fieldValue.type() == QVariant::Int || fieldValue.type() == QVariant::UInt )
|
||||
if ( fieldValue.metaType().id() == QMetaType::Int || fieldValue.metaType().id() == QMetaType::UInt )
|
||||
{
|
||||
int col = 0;
|
||||
int row = uiField()->uiValue().toInt();
|
||||
@ -217,7 +217,7 @@ void PdmUiListEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
|
||||
m_listView->selectionModel()->blockSignals( false );
|
||||
}
|
||||
else if ( fieldValue.type() == QVariant::List )
|
||||
else if ( fieldValue.metaType().id() == QMetaType::QVariantList )
|
||||
{
|
||||
QList<QVariant> valuesSelectedInField = fieldValue.toList();
|
||||
QItemSelection selection;
|
||||
@ -307,7 +307,7 @@ void PdmUiListEditor::slotSelectionChanged( const QItemSelection& selected, cons
|
||||
m_isScrollToItemAllowed = false;
|
||||
|
||||
QVariant fieldValue = uiField()->uiValue();
|
||||
if ( fieldValue.type() == QVariant::Int || fieldValue.type() == QVariant::UInt )
|
||||
if ( fieldValue.metaType().id() == QMetaType::Int || fieldValue.metaType().id() == QMetaType::UInt )
|
||||
{
|
||||
// NOTE : Workaround for update issue seen on RHEL6 with Qt 4.6.2
|
||||
// An invalid call to setSelection() from QAbstractItemView::keyPressEvent() causes the stepping using arrow
|
||||
@ -327,7 +327,7 @@ void PdmUiListEditor::slotSelectionChanged( const QItemSelection& selected, cons
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( fieldValue.type() == QVariant::List )
|
||||
else if ( fieldValue.metaType().id() == QMetaType::QVariantList )
|
||||
{
|
||||
QModelIndexList idxList = m_listView->selectionModel()->selectedIndexes();
|
||||
|
||||
|
@ -86,7 +86,7 @@ void PdmUiPushButtonEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( variantFieldValue.type() == QVariant::Bool )
|
||||
if ( variantFieldValue.metaType().id() == QMetaType::Bool )
|
||||
{
|
||||
m_pushButton->setText( variantFieldValue.toBool() ? "On" : "Off" );
|
||||
}
|
||||
@ -103,7 +103,7 @@ void PdmUiPushButtonEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
m_buttonLayout->setAlignment( m_pushButton, Qt::AlignRight );
|
||||
}
|
||||
|
||||
if ( variantFieldValue.type() == QVariant::Bool )
|
||||
if ( variantFieldValue.metaType().id() == QMetaType::Bool )
|
||||
{
|
||||
m_pushButton->setChecked( uiField()->uiValue().toBool() );
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ QVariant PdmUiTableViewQModel::data( const QModelIndex& index, int role /*= Qt::
|
||||
if ( uiFieldHandle )
|
||||
{
|
||||
QVariant fieldValue = uiFieldHandle->uiValue();
|
||||
if ( fieldValue.type() == QVariant::List )
|
||||
if ( fieldValue.metaType().id() == QMetaType::QVariantList )
|
||||
{
|
||||
QString displayText;
|
||||
QList<QVariant> valuesSelectedInField = fieldValue.toList();
|
||||
@ -621,7 +621,7 @@ bool PdmUiTableViewQModel::isRepresentingBoolean( const QModelIndex& index ) con
|
||||
}
|
||||
|
||||
QVariant val = fieldHandle->uiCapability()->uiValue();
|
||||
if ( val.type() == QVariant::Bool )
|
||||
if ( val.metaType().id() == QMetaType::Bool )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -794,7 +794,7 @@ void TableViewPushButton::slotPressed()
|
||||
if ( m_fieldHandle )
|
||||
{
|
||||
QVariant val = m_fieldHandle->uiValue();
|
||||
if ( val.type() == QVariant::Bool )
|
||||
if ( val.metaType().id() == QMetaType::Bool )
|
||||
{
|
||||
bool currentValue = val.toBool();
|
||||
caf::PdmUiCommandSystemProxy::instance()->setUiValueToField( m_fieldHandle, !currentValue );
|
||||
|
@ -146,7 +146,7 @@ void PdmUiToolBarEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
bool addSpace = false;
|
||||
if ( uiFieldHandle )
|
||||
{
|
||||
if ( uiFieldHandle->uiValue().type() == QVariant::Bool )
|
||||
if ( uiFieldHandle->uiValue().metaType().id() == QMetaType::Bool )
|
||||
{
|
||||
QString editorTypeName = caf::PdmUiToolButtonEditor::uiEditorTypeName();
|
||||
|
||||
|
@ -632,7 +632,7 @@ void caf::PdmUiTreeSelectionQModel::recursiveNotifyChildren( const QModelIndex&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::PdmUiTreeSelectionQModel::isSingleValueField( const QVariant& fieldValue )
|
||||
{
|
||||
if ( fieldValue.type() == QVariant::Int || fieldValue.type() == QVariant::UInt )
|
||||
if ( fieldValue.metaType().id() == QMetaType::Int || fieldValue.metaType().id() == QMetaType::UInt )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -645,7 +645,7 @@ bool caf::PdmUiTreeSelectionQModel::isSingleValueField( const QVariant& fieldVal
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::PdmUiTreeSelectionQModel::isMultipleValueField( const QVariant& fieldValue )
|
||||
{
|
||||
if ( fieldValue.type() == QVariant::List )
|
||||
if ( fieldValue.metaType().id() == QMetaType::QVariantList )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user