Skip to content

Commit

Permalink
Fix malformed html metadata display from mapserver provider
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 6, 2019
1 parent 345f3fe commit ec271ae
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/providers/arcgisrest/qgsamsprovider.cpp
Expand Up @@ -30,6 +30,7 @@
#include "qgsmessagelog.h"
#include "qgsauthmanager.h"
#include "qgstilecache.h"
#include "qgsstringutils.h"

#ifdef HAVE_GUI
#include "qgsamssourceselect.h"
Expand Down Expand Up @@ -298,22 +299,36 @@ static inline QString dumpVariantMap( const QVariantMap &variantMap, const QStri
QString result;
if ( !title.isEmpty() )
{
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td>" ).arg( title );
}
else
{
result += QStringLiteral( "<tr><td>" );
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td></td></tr>" ).arg( title );
}
for ( auto it = variantMap.constBegin(); it != variantMap.constEnd(); ++it )
{
QVariantMap childMap = it.value().toMap();
if ( childMap.isEmpty() )
const QVariantMap childMap = it.value().toMap();
const QVariantList childList = it.value().toList();
if ( !childList.isEmpty() )
{
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td><ul>" ).arg( it.key() );
for ( const QVariant &v : childList )
{
const QVariantMap grandChildMap = v.toMap();
if ( !grandChildMap.isEmpty() )
{
result += QStringLiteral( "<li><table>%1</table></li>" ).arg( dumpVariantMap( grandChildMap ) );
}
else
{
result += QStringLiteral( "<li>%1</li>" ).arg( QgsStringUtils::insertLinks( v.toString() ) );
}
}
result += QStringLiteral( "</ul></td></tr>" );
}
else if ( !childMap.isEmpty() )
{
result += QStringLiteral( "%1:%2</td></tr>" ).arg( it.key(), it.value().toString() );
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td><table>%2</table></td></tr>" ).arg( it.key(), dumpVariantMap( childMap ) );
}
else
{
result += QStringLiteral( "%1:<table>%2</table></td></tr>" ).arg( it.key(), dumpVariantMap( childMap ) );
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td>%2</td></tr>" ).arg( it.key(), QgsStringUtils::insertLinks( it.value().toString() ) );
}
}
return result;
Expand Down

0 comments on commit ec271ae

Please sign in to comment.