Skip to content

Commit 5c28eca

Browse files
Gustrytimlinux
authored andcommittedDec 13, 2017
update HTML data provider metadata (#5700)
* update HTML data provider metadata for grass, gdal and ams * update HTML data provider metadata for WMS and WCS * move HTML bullet list to QgsHtmlUtils
1 parent b6ddc70 commit 5c28eca

16 files changed

+235
-232
lines changed
 

‎doc/api_break.dox

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,9 @@ QgsRasterDataProvider {#qgis_api_break_3_0_QgsRasterDataProvider}
20752075
- draw() has been removed from the interface as it was not used anywhere.
20762076
- The progress and progressUpdate signals were removed. Methods which previously emitted these
20772077
signals now accept a QgsRasterBlockFeedback argument for reporting progress updates.
2078+
- metadata() was renamed to htmlMetadata()
2079+
- makeTableCell() has been removed
2080+
- makeTableCells() has been removed, look for the new class QgsHtmlUtils
20782081

20792082

20802083
QgsRasterFileWriter {#qgis_api_break_3_0_QgsRasterFileWriter}

‎python/core/core_auto.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@
318318
%Include qgsgeometryvalidator.sip
319319
%Include qgsgml.sip
320320
%Include qgsgmlschema.sip
321+
%Include qgshtmlutils.sip
321322
%Include qgsmaplayer.sip
322323
%Include qgsmaplayerlegend.sip
323324
%Include qgsmaplayermodel.sip

‎python/core/qgshtmlutils.sip

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgshtmlutils.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
class QgsHtmlUtils
13+
{
14+
%Docstring
15+
Class for HTML utilities.
16+
.. versionadded:: 3.0
17+
%End
18+
19+
%TypeHeaderCode
20+
#include "qgshtmlutils.h"
21+
%End
22+
public:
23+
24+
static QString buildBulletList( const QStringList &values );
25+
%Docstring
26+
Build a bullet list.
27+
This will return a HTML "ul" element.
28+
:rtype: str
29+
%End
30+
};
31+
32+
/************************************************************************
33+
* This file has been generated automatically from *
34+
* *
35+
* src/core/qgshtmlutils.h *
36+
* *
37+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
38+
************************************************************************/

‎python/core/raster/qgsrasterdataprovider.sip

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,6 @@ Copy member variables from other raster data provider. Useful for implementation
450450
%End
451451

452452

453-
static QString makeTableCell( const QString &value );
454-
%Docstring
455-
:rtype: str
456-
%End
457-
static QString makeTableCells( const QStringList &values );
458-
%Docstring
459-
:rtype: str
460-
%End
461-
462453

463454

464455

‎src/core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ SET(QGIS_CORE_SRCS
193193
qgsgml.cpp
194194
qgsgmlschema.cpp
195195
qgshistogram.cpp
196+
qgshtmlutils.cpp
196197
qgsinterval.cpp
197198
qgsjsonutils.cpp
198199
qgslabelfeature.cpp
@@ -616,6 +617,7 @@ SET(QGIS_CORE_MOC_HDRS
616617
qgsgeometryvalidator.h
617618
qgsgml.h
618619
qgsgmlschema.h
620+
qgshtmlutils.h
619621
qgsmaplayer.h
620622
qgsmaplayerlegend.h
621623
qgsmaplayermodel.h

‎src/core/qgsapplication.cpp

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,45 +1042,7 @@ QString QgsApplication::reportStyleSheet()
10421042
QColor myColor2 = myColor1;
10431043
myColor2 = myColor2.lighter( 110 ); //10% lighter
10441044
QString myStyle;
1045-
myStyle = "p.glossy{ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
1046-
" stop: 0 " + myColor1.name() + ","
1047-
" stop: 0.1 " + myColor2.name() + ","
1048-
" stop: 0.5 " + myColor1.name() + ","
1049-
" stop: 0.9 " + myColor2.name() + ","
1050-
" stop: 1 " + myColor1.name() + ");"
1051-
" color: black;"
1052-
" padding-left: 4px;"
1053-
" padding-top: 20px;"
1054-
" padding-bottom: 8px;"
1055-
" border: 1px solid #6c6c6c;"
1056-
"}"
1057-
"p.subheaderglossy{ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
1058-
" stop: 0 " + myColor1.name() + ","
1059-
" stop: 0.1 " + myColor2.name() + ","
1060-
" stop: 0.5 " + myColor1.name() + ","
1061-
" stop: 0.9 " + myColor2.name() + ","
1062-
" stop: 1 " + myColor1.name() + ");"
1063-
" font-weight: bold;"
1064-
" font-size: medium;"
1065-
" line-height: 1.1em;"
1066-
" width: 100%;"
1067-
" color: black;"
1068-
" padding-left: 4px;"
1069-
" padding-right: 4px;"
1070-
" padding-top: 20px;"
1071-
" padding-bottom: 8px;"
1072-
" border: 1px solid #6c6c6c;"
1073-
"}"
1074-
"th.glossy{ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
1075-
" stop: 0 " + myColor1.name() + ","
1076-
" stop: 0.1 " + myColor2.name() + ","
1077-
" stop: 0.5 " + myColor1.name() + ","
1078-
" stop: 0.9 " + myColor2.name() + ","
1079-
" stop: 1 " + myColor1.name() + ");"
1080-
" color: black;"
1081-
" border: 1px solid #6c6c6c;"
1082-
"}"
1083-
".overview{"
1045+
myStyle = ".overview{"
10841046
" font: 1.82em;"
10851047
" font-weight: bold;"
10861048
"}"
@@ -1149,6 +1111,9 @@ QString QgsApplication::reportStyleSheet()
11491111
" padding-left: 20px;"
11501112
" font-weight: bold;"
11511113
"}"
1114+
"th .strong {"
1115+
" font-weight: bold;"
1116+
"}"
11521117
".tabular-view{ "
11531118
" border-collapse: collapse;"
11541119
" width: 95%;"

‎src/core/qgshtmlutils.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "qgshtmlutils.h"
2+
3+
QString QgsHtmlUtils::buildBulletList( const QStringList &values )
4+
{
5+
QString s( QStringLiteral( "<ul>" ) );
6+
7+
for ( const QString &value : values )
8+
{
9+
s += QStringLiteral( "<li>%1</li>" ).arg( value );
10+
}
11+
s += QLatin1String( "</ul>" );
12+
13+
return s;
14+
}

‎src/core/qgshtmlutils.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/***************************************************************************
2+
qgshtmlutils.h
3+
---------------------------
4+
begin : November 2017
5+
copyright : (C) 2017 by Etienne Trimaille
6+
email : etienne dot trimaille at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSHTMLUTILS_H
19+
#define QGSHTMLUTILS_H
20+
21+
#include "qgis.h"
22+
23+
/**
24+
* \ingroup core
25+
* \class QgsHtmlUtils
26+
* \brief Class for HTML utilities.
27+
* \since QGIS 3.0
28+
*/
29+
class CORE_EXPORT QgsHtmlUtils
30+
{
31+
public:
32+
33+
/**
34+
* Build a bullet list.
35+
* This will return a HTML "ul" element.
36+
*/
37+
static QString buildBulletList( const QStringList &values );
38+
};
39+
40+
#endif // QGSHTMLUTILS_H

‎src/core/raster/qgsrasterdataprovider.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -236,28 +236,6 @@ QStringList QgsRasterDataProvider::cStringList2Q_( char **stringList )
236236

237237
} // cStringList2Q_
238238

239-
QString QgsRasterDataProvider::makeTableCell( QString const &value )
240-
{
241-
return "<p>\n" + value + "</p>\n";
242-
} // makeTableCell_
243-
244-
// convenience function for building metadata() HTML table cells
245-
QString QgsRasterDataProvider::makeTableCells( QStringList const &values )
246-
{
247-
QString s( QStringLiteral( "<tr>" ) );
248-
249-
for ( QStringList::const_iterator i = values.begin();
250-
i != values.end();
251-
++i )
252-
{
253-
s += QgsRasterDataProvider::makeTableCell( *i );
254-
}
255-
256-
s += QLatin1String( "</tr>" );
257-
258-
return s;
259-
} // makeTableCell_
260-
261239
QString QgsRasterDataProvider::htmlMetadata()
262240
{
263241
QString s;

‎src/core/raster/qgsrasterdataprovider.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,6 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
510510
//! \note not available in Python bindings
511511
static QStringList cStringList2Q_( char **stringList ) SIP_SKIP;
512512

513-
static QString makeTableCell( const QString &value );
514-
static QString makeTableCells( const QStringList &values );
515-
516513
/**
517514
* Dots per inch. Extended WMS (e.g. QGIS mapserver) support DPI dependent output and therefore
518515
are suited for printing. A value of -1 means it has not been set */

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ QString QgsRasterLayer::htmlMetadata() const
397397
}
398398
myMetadata += QLatin1String( "</td></tr>\n" );
399399

400+
// Insert provider-specific (e.g. WMS-specific) metadata
401+
myMetadata += mDataProvider->htmlMetadata();
402+
400403
// End Provider section
401404
myMetadata += QLatin1String( "</table>\n<br><br>" );
402405

‎src/providers/arcgisrest/qgsamsprovider.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,29 +216,33 @@ QgsRasterInterface *QgsAmsProvider::clone() const
216216

217217
static inline QString dumpVariantMap( const QVariantMap &variantMap, const QString &title = QString() )
218218
{
219-
QString result = QStringLiteral( "<table>" );
219+
QString result;
220220
if ( !title.isEmpty() )
221221
{
222-
result += QStringLiteral( "<tr><td class=\"glossy\" colspan=\"2\">%1</td></tr>" ).arg( title );
222+
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td>" ).arg( title );
223+
}
224+
else
225+
{
226+
result += QStringLiteral( "<tr><td>" );
223227
}
224228
for ( auto it = variantMap.constBegin(); it != variantMap.constEnd(); ++it )
225229
{
226230
QVariantMap childMap = it.value().toMap();
227231
if ( childMap.isEmpty() )
228232
{
229-
result += QStringLiteral( "<tr><td>%1</td><td>%2</td></tr>" ).arg( it.key(), it.value().toString() );
233+
result += QStringLiteral( "%1:%2</td></tr>" ).arg( it.key(), it.value().toString() );
230234
}
231235
else
232236
{
233-
result += QStringLiteral( "<tr><td>%1</td><td>%2</td></tr>" ).arg( it.key(), dumpVariantMap( childMap ) );
237+
result += QStringLiteral( "%1:<table>%2</table></td></tr>" ).arg( it.key(), dumpVariantMap( childMap ) );
234238
}
235239
}
236-
result += QLatin1String( "</table>" );
237240
return result;
238241
}
239242

240243
QString QgsAmsProvider::htmlMetadata()
241244
{
245+
// This must return the content of a HTML table starting by tr and ending by tr
242246
return dumpVariantMap( mServiceInfo, tr( "Service Info" ) ) + dumpVariantMap( mLayerInfo, tr( "Layer Info" ) );
243247
}
244248

0 commit comments

Comments
 (0)
Please sign in to comment.