Skip to content

Commit

Permalink
#10649 Fwk: Use collection.empty() instead of comparing with size
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Sep 27, 2023
1 parent a4def5d commit 98796b0
Show file tree
Hide file tree
Showing 41 changed files with 77 additions and 77 deletions.
4 changes: 2 additions & 2 deletions Fwk/AppFwk/CommonCode/cafColorTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace caf
ColorTable::ColorTable( const std::vector<cvf::Color3ub>& colors )
: m_colors( colors )
{
CVF_ASSERT( m_colors.size() > 0 );
CVF_ASSERT( !m_colors.empty() );
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -57,7 +57,7 @@ ColorTable::ColorTable( const std::vector<cvf::Color3ub>& colors )
ColorTable::ColorTable( const cvf::Color3ubArray& colors )
: m_colors( colors.begin(), colors.end() )
{
CVF_ASSERT( m_colors.size() > 0 );
CVF_ASSERT( !m_colors.empty() );
}

//--------------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions Fwk/AppFwk/CommonCode/cafUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ bool Utils::getSaveDirectoryAndCheckOverwriteFiles( const QString& defaultDir, s
}
}

if ( filesToOverwrite.size() == 0 )
if ( filesToOverwrite.empty() )
{
overWriteFiles = true;
return overWriteFiles;
}
else if ( filesToOverwrite.size() > 0 )
else if ( !filesToOverwrite.empty() )
{
QMessageBox msgBox;

Expand Down
6 changes: 3 additions & 3 deletions Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void CellRangeFilter::addCellExclude( size_t i, size_t j, size_t k, bool applyTo
//--------------------------------------------------------------------------------------------------
bool CellRangeFilter::isCellVisible( size_t i, size_t j, size_t k, bool isInSubGridArea ) const
{
if ( m_includeRanges.size() == 0 )
if ( m_includeRanges.empty() )
{
return false;
}
Expand Down Expand Up @@ -159,7 +159,7 @@ bool CellRangeFilter::isCellExcluded( size_t i, size_t j, size_t k, bool isInSub
//--------------------------------------------------------------------------------------------------
bool CellRangeFilter::hasIncludeRanges() const
{
if ( m_includeRanges.size() > 0 )
if ( !m_includeRanges.empty() )
return true;
else
return false;
Expand Down Expand Up @@ -411,7 +411,7 @@ void StructGridGeometryGenerator::computeArrays()
if ( isCellFaceVisible( i, j, k, StructGridInterface::POS_K ) )
visibleFaces.push_back( cvf::StructGridInterface::POS_K );

if ( visibleFaces.size() > 0 )
if ( !visibleFaces.empty() )
{
cvf::Vec3d cornerVerts[8];
m_grid->cellCornerVertices( cellIndex, cornerVerts );
Expand Down
6 changes: 3 additions & 3 deletions Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ caf::CmdFeature* CmdFeatureManager::commandFeature( const std::string& commandId
//--------------------------------------------------------------------------------------------------
void CmdFeatureManager::refreshStates( const QStringList& commandIdList )
{
if ( commandIdList.size() == 0 )
if ( commandIdList.empty() )
{
for ( size_t i = 0; i < m_commandFeatures.size(); i++ )
{
Expand Down Expand Up @@ -241,7 +241,7 @@ void CmdFeatureManager::refreshStates( const QStringList& commandIdList )
//--------------------------------------------------------------------------------------------------
void CmdFeatureManager::refreshEnabledState( const QStringList& commandIdList )
{
if ( commandIdList.size() == 0 )
if ( commandIdList.empty() )
{
for ( size_t i = 0; i < m_commandFeatures.size(); i++ )
{
Expand All @@ -267,7 +267,7 @@ void CmdFeatureManager::refreshEnabledState( const QStringList& commandIdList )
//--------------------------------------------------------------------------------------------------
void CmdFeatureManager::refreshCheckedState( const QStringList& commandIdList )
{
if ( commandIdList.size() == 0 )
if ( commandIdList.empty() )
{
for ( size_t i = 0; i < m_commandFeatures.size(); i++ )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool ToggleItemsOnOthersOffFeature::isCommandEnabled() const
caf::PdmFieldHandle* commonParent = verifySameParentForSelection( selectedObjects );
std::vector<caf::PdmObjectHandle*> children = childObjects( commonParent );

return commonParent != nullptr && children.size() > 0 && objectToggleField( children.front() ) &&
return commonParent != nullptr && !children.empty() && objectToggleField( children.front() ) &&
children.size() > selectedObjects.size();
}

Expand Down
8 changes: 4 additions & 4 deletions Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
QString iconResourceName; \
QString toolTip; \
QString whatsThis; \
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
if ( !arguments.empty() ) iconResourceName = arguments[0]; \
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
\
Expand All @@ -76,7 +76,7 @@
QString iconResourceName; \
QString toolTip; \
QString whatsThis; \
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
if ( !arguments.empty() ) iconResourceName = arguments[0]; \
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
\
Expand All @@ -95,7 +95,7 @@
QString iconResourceName; \
QString toolTip; \
QString whatsThis; \
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
if ( !arguments.empty() ) iconResourceName = arguments[0]; \
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
\
Expand All @@ -115,7 +115,7 @@
QString iconResourceName; \
QString toolTip; \
QString whatsThis; \
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
if ( !arguments.empty() ) iconResourceName = arguments[0]; \
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ NotificationCenter::NotificationCenter()
//--------------------------------------------------------------------------------------------------
NotificationCenter::~NotificationCenter()
{
CAF_ASSERT( m_observers.size() == 0 );
CAF_ASSERT( m_observers.empty() );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ QStringList PdmReferenceHelper::referenceFromRootToObjectAsStringList( PdmObject
PdmFieldHandle* PdmReferenceHelper::fieldFromReference( PdmObjectHandle* root, const QString& reference )
{
QStringList decodedReference = reference.split( " " );
if ( decodedReference.size() == 0 ) return nullptr;
if ( decodedReference.empty() ) return nullptr;

QString fieldKeyword = decodedReference[0];
decodedReference.pop_front();
Expand Down Expand Up @@ -364,7 +364,7 @@ PdmObjectHandle* PdmReferenceHelper::findRoot( PdmObjectHandle* obj )
{
std::vector<PdmObjectHandle*> path = findPathToObjectFromRoot( obj );

if ( path.size() )
if ( !path.empty() )
return path[0];
else
return nullptr;
Expand Down
6 changes: 3 additions & 3 deletions Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PdmObjectCapability;
QString iconResourceName; \
QString toolTip; \
QString whatsThis; \
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
if ( !arguments.empty() ) iconResourceName = arguments[0]; \
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
\
Expand All @@ -108,7 +108,7 @@ class PdmObjectCapability;
QString iconResourceName; \
QString toolTip; \
QString whatsThis; \
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
if ( !arguments.empty() ) iconResourceName = arguments[0]; \
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
CAF_PDM_VERIFY_XML_KEYWORD( keyword ) \
Expand Down Expand Up @@ -137,7 +137,7 @@ class PdmObjectCapability;
QString iconResourceName; \
QString toolTip; \
QString whatsThis; \
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
if ( !arguments.empty() ) iconResourceName = arguments[0]; \
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
CAF_PDM_VERIFY_XML_KEYWORD( keyword ) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void PdmFieldUiCap<FieldType>::setValueFromUiEditor( const QVariant& uiValue, bo
bool setUiValueDirectly = false;

// Check whether we are handling selections of values or actual values
if ( m_optionEntryCache.size() )
if ( !m_optionEntryCache.empty() )
{
// This has an option based GUI, the uiValue is only indexes into the m_optionEntryCache
if ( uiValue.type() == QVariant::UInt )
Expand Down Expand Up @@ -125,7 +125,7 @@ void PdmFieldUiCap<FieldType>::setValueFromUiEditor( const QVariant& uiValue, bo
template <typename FieldType>
QVariant PdmFieldUiCap<FieldType>::uiValue() const
{
if ( m_optionEntryCache.size() )
if ( !m_optionEntryCache.empty() )
{
QVariant uiBasedQVariant = toUiBasedQVariant();
std::vector<unsigned int> indexesToFoundOptions;
Expand Down Expand Up @@ -190,12 +190,12 @@ QList<PdmOptionItemInfo> PdmFieldUiCap<FieldType>::valueOptions() const

// If we got no options, use the options defined by the type. Normally only caf::AppEnum type

if ( !m_optionEntryCache.size() )
if ( m_optionEntryCache.empty() )
{
m_optionEntryCache = PdmUiFieldSpecialization<typename FieldType::FieldDataType>::valueOptions( m_field->value() );
}

if ( m_optionEntryCache.size() && isAutoAddingOptionFromValue() )
if ( !m_optionEntryCache.empty() && isAutoAddingOptionFromValue() )
{
// Make sure the options contain the field values, event though they not necessarily
// is supplied as possible options by the application. This is a convenience making sure
Expand Down
4 changes: 2 additions & 2 deletions Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ bool PdmOptionItemInfo::findValues( const QList<PdmOptionItemInfo>& optionList,
{
QList<QVariant> valuesSelectedInField = fieldValue.toList();

if ( valuesSelectedInField.size() )
if ( !valuesSelectedInField.empty() )
{
// Create a list to be able to remove items as they are matched with values
std::list<std::pair<QVariant, unsigned int>> optionVariantAndIndexPairs;
Expand Down Expand Up @@ -230,7 +230,7 @@ bool PdmOptionItemInfo::findValues( const QList<PdmOptionItemInfo>& optionList,
break;
}
}
return ( foundIndexes.size() > 0 );
return ( !foundIndexes.empty() );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ void SelectionManager::clearAll()

m_selectionPrLevel.clear();

if ( changedSelectionLevels.size() )
if ( !changedSelectionLevels.empty() )
{
notifySelectionChanged( changedSelectionLevels );
}
Expand Down
4 changes: 2 additions & 2 deletions Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void PdmSettings::readFieldsFromApplicationStore( caf::PdmObjectHandle* object,
readFieldsFromApplicationStore( child, subContext );
}

if ( children.size() == 0 )
if ( children.empty() )
{
QString key = context + fieldHandle->keyword();
if ( settings.contains( key ) )
Expand Down Expand Up @@ -116,7 +116,7 @@ void PdmSettings::writeFieldsToApplicationStore( const caf::PdmObjectHandle* obj
writeFieldsToApplicationStore( child, subContext );
}

if ( children.size() == 0 )
if ( children.empty() )
{
caf::PdmValueField* valueField = dynamic_cast<caf::PdmValueField*>( fieldHandle );
CAF_ASSERT( valueField );
Expand Down
4 changes: 2 additions & 2 deletions Fwk/AppFwk/cafUserInterface/cafAboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void AboutDialog::create()
}

// Possibly show extend version info
if ( m_showQtVersion || m_verLabels.size() > 0 )
if ( m_showQtVersion || !m_verLabels.empty() )
{
QGridLayout* verInfoLayout = new QGridLayout;
verInfoLayout->setSpacing( 0 );
Expand All @@ -227,7 +227,7 @@ void AboutDialog::create()
}

// Custom specified labels
if ( m_verLabels.size() > 0 )
if ( !m_verLabels.empty() )
{
CAF_ASSERT( m_verLabels.size() == m_verTexts.size() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ caf::PdmUiFormLayoutObjectEditor::~PdmUiFormLayoutObjectEditor()
{
// If there are field editor present, the usage of this editor has not cleared correctly
// The intended usage is to call the method setPdmObject(NULL) before closing the dialog
CAF_ASSERT( m_fieldViews.size() == 0 );
CAF_ASSERT( m_fieldViews.empty() );
}

//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ void PdmUiLineEditor::slotEditingFinished()

uiField()->enableAutoValue( false );

if ( m_optionCache.size() )
if ( !m_optionCache.empty() )
{
int index = findIndexToOption( m_lineEdit->text() );
if ( index > -1 )
Expand Down
6 changes: 3 additions & 3 deletions Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void PdmUiListEditor::configureAndUpdateUi( const QString& uiConfigName )

QList<PdmOptionItemInfo> options = uiField()->valueOptions();
m_optionItemCount = options.size();
if ( options.size() > 0 || uiField()->isUiReadOnly( uiConfigName ) )
if ( !options.empty() || uiField()->isUiReadOnly( uiConfigName ) )
{
m_isEditOperationsAvailable = false;
}
Expand Down Expand Up @@ -322,7 +322,7 @@ void PdmUiListEditor::slotSelectionChanged( const QItemSelection& selected, cons
m_listView->selectionModel()->select( m_listView->currentIndex(), QItemSelectionModel::SelectCurrent );

QModelIndexList idxList = m_listView->selectionModel()->selectedIndexes();
if ( idxList.size() >= 1 )
if ( !idxList.empty() )
{
if ( idxList[0].row() < m_optionItemCount )
{
Expand Down Expand Up @@ -471,7 +471,7 @@ bool PdmUiListEditor::eventFilter( QObject* object, QEvent* event )
{
QModelIndexList idxList = m_listView->selectionModel()->selectedIndexes();
bool isAnyDeleted = false;
while ( idxList.size() )
while ( !idxList.empty() )
{
m_model->removeRow( idxList[0].row() );
idxList = m_listView->selectionModel()->selectedIndexes();
Expand Down
4 changes: 2 additions & 2 deletions Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int UiListViewModelPdm::columnCount( const QModelIndex& parent /*= QModelIndex(
//--------------------------------------------------------------------------------------------------
void UiListViewModelPdm::computeColumnCount()
{
if ( m_editorAttribute.fieldNames.size() > 0 )
if ( !m_editorAttribute.fieldNames.empty() )
{
m_columnCount = m_editorAttribute.fieldNames.size();
}
Expand Down Expand Up @@ -139,7 +139,7 @@ QVariant caf::UiListViewModelPdm::data( const QModelIndex& index, int role /*= Q
{
size_t fieldIndex = 0;

if ( m_editorAttribute.fieldNames.size() > 0 )
if ( !m_editorAttribute.fieldNames.empty() )
{
QString fieldName = m_editorAttribute.fieldNames[index.column()];
for ( size_t i = 0; i < fields.size(); i++ )
Expand Down
2 changes: 1 addition & 1 deletion Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void PdmUiTreeView::slotOnSelectionChanged()
m_treeViewEditor->selectedUiItems( objects );
PdmObjectHandle* objHandle = nullptr;

if ( objects.size() )
if ( !objects.empty() )
{
PdmUiObjectHandle* uiObjH = dynamic_cast<PdmUiObjectHandle*>( objects[0] );
if ( uiObjH )
Expand Down
2 changes: 1 addition & 1 deletion Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void PdmUiTreeViewEditor::customMenuRequested( QPoint pos )

caf::PdmUiCommandSystemProxy::instance()->populateMenuWithDefaultCommands( "PdmUiTreeViewEditor", &menu );

if ( menu.actions().size() > 0 )
if ( !menu.actions().empty() )
{
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
QPoint globalPos = m_treeView->viewport()->mapToGlobal( pos );
Expand Down
Loading

0 comments on commit 98796b0

Please sign in to comment.