Skip to content
Permalink
Browse files

improved wms connection items comparison

  • Loading branch information
Samweli authored and nyalldawson committed Jan 14, 2020
1 parent b690528 commit 5310cb690e77e606258b2e33f662bbe134eef181
Showing with 34 additions and 3 deletions.
  1. +34 −3 src/providers/wms/qgswmsdataitems.cpp
@@ -226,13 +226,44 @@ bool QgsWMSConnectionItem::equal( const QgsDataItem *other )
{
return false;
}
const QgsWMSConnectionItem *o = dynamic_cast<const QgsWMSConnectionItem *>( other );
if ( !o )
const QgsWMSConnectionItem *otherConnectionItem = qobject_cast<const QgsWMSConnectionItem *>( other );
if ( !otherConnectionItem )
{
return false;
}

return ( mPath == o->mPath && mName == o->mName );
bool samePathAndName = ( mPath == otherConnectionItem->mPath && mName == otherConnectionItem->mName );

if ( samePathAndName )
{
// Check if the children are not the same then they are not equal
if ( mChildren.size() != otherConnectionItem->mChildren.size() )
return false;

// compare children content, if the content differs then the parents are not equal
for ( QgsDataItem *child : mChildren )
{
if ( !child )
continue;
for ( QgsDataItem *otherChild : otherConnectionItem->mChildren )
{
if ( !otherChild )
continue;
// In case they have same path, check if they have same content
if ( child->path() == otherChild->path() )
{
if ( !child->equal( otherChild ) )
return false;
}
else
{
continue;
}
}
}
}

return samePathAndName;
}

// ---------------------------------------------------------------------------

0 comments on commit 5310cb6

Please sign in to comment.
You can’t perform that action at this time.