Skip to content

Commit ec271ae

Browse files
committedJun 6, 2019
Fix malformed html metadata display from mapserver provider
1 parent 345f3fe commit ec271ae

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed
 

‎src/providers/arcgisrest/qgsamsprovider.cpp

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "qgsmessagelog.h"
3131
#include "qgsauthmanager.h"
3232
#include "qgstilecache.h"
33+
#include "qgsstringutils.h"
3334

3435
#ifdef HAVE_GUI
3536
#include "qgsamssourceselect.h"
@@ -298,22 +299,36 @@ static inline QString dumpVariantMap( const QVariantMap &variantMap, const QStri
298299
QString result;
299300
if ( !title.isEmpty() )
300301
{
301-
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td>" ).arg( title );
302-
}
303-
else
304-
{
305-
result += QStringLiteral( "<tr><td>" );
302+
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td></td></tr>" ).arg( title );
306303
}
307304
for ( auto it = variantMap.constBegin(); it != variantMap.constEnd(); ++it )
308305
{
309-
QVariantMap childMap = it.value().toMap();
310-
if ( childMap.isEmpty() )
306+
const QVariantMap childMap = it.value().toMap();
307+
const QVariantList childList = it.value().toList();
308+
if ( !childList.isEmpty() )
309+
{
310+
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td><ul>" ).arg( it.key() );
311+
for ( const QVariant &v : childList )
312+
{
313+
const QVariantMap grandChildMap = v.toMap();
314+
if ( !grandChildMap.isEmpty() )
315+
{
316+
result += QStringLiteral( "<li><table>%1</table></li>" ).arg( dumpVariantMap( grandChildMap ) );
317+
}
318+
else
319+
{
320+
result += QStringLiteral( "<li>%1</li>" ).arg( QgsStringUtils::insertLinks( v.toString() ) );
321+
}
322+
}
323+
result += QStringLiteral( "</ul></td></tr>" );
324+
}
325+
else if ( !childMap.isEmpty() )
311326
{
312-
result += QStringLiteral( "%1:%2</td></tr>" ).arg( it.key(), it.value().toString() );
327+
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td><table>%2</table></td></tr>" ).arg( it.key(), dumpVariantMap( childMap ) );
313328
}
314329
else
315330
{
316-
result += QStringLiteral( "%1:<table>%2</table></td></tr>" ).arg( it.key(), dumpVariantMap( childMap ) );
331+
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td>%2</td></tr>" ).arg( it.key(), QgsStringUtils::insertLinks( it.value().toString() ) );
317332
}
318333
}
319334
return result;

0 commit comments

Comments
 (0)
Please sign in to comment.