Skip to content

Commit

Permalink
update HTML data provider metadata (#5700)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Gustry authored and timlinux committed Dec 13, 2017
1 parent b6ddc70 commit 5c28eca
Show file tree
Hide file tree
Showing 16 changed files with 235 additions and 232 deletions.
3 changes: 3 additions & 0 deletions doc/api_break.dox
Expand Up @@ -2075,6 +2075,9 @@ QgsRasterDataProvider {#qgis_api_break_3_0_QgsRasterDataProvider}
- draw() has been removed from the interface as it was not used anywhere.
- The progress and progressUpdate signals were removed. Methods which previously emitted these
signals now accept a QgsRasterBlockFeedback argument for reporting progress updates.
- metadata() was renamed to htmlMetadata()
- makeTableCell() has been removed
- makeTableCells() has been removed, look for the new class QgsHtmlUtils


QgsRasterFileWriter {#qgis_api_break_3_0_QgsRasterFileWriter}
Expand Down
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -318,6 +318,7 @@
%Include qgsgeometryvalidator.sip
%Include qgsgml.sip
%Include qgsgmlschema.sip
%Include qgshtmlutils.sip
%Include qgsmaplayer.sip
%Include qgsmaplayerlegend.sip
%Include qgsmaplayermodel.sip
Expand Down
38 changes: 38 additions & 0 deletions python/core/qgshtmlutils.sip
@@ -0,0 +1,38 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgshtmlutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsHtmlUtils
{
%Docstring
Class for HTML utilities.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgshtmlutils.h"
%End
public:

static QString buildBulletList( const QStringList &values );
%Docstring
Build a bullet list.
This will return a HTML "ul" element.
:rtype: str
%End
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgshtmlutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
9 changes: 0 additions & 9 deletions python/core/raster/qgsrasterdataprovider.sip
Expand Up @@ -450,15 +450,6 @@ Copy member variables from other raster data provider. Useful for implementation
%End


static QString makeTableCell( const QString &value );
%Docstring
:rtype: str
%End
static QString makeTableCells( const QStringList &values );
%Docstring
:rtype: str
%End




Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -193,6 +193,7 @@ SET(QGIS_CORE_SRCS
qgsgml.cpp
qgsgmlschema.cpp
qgshistogram.cpp
qgshtmlutils.cpp
qgsinterval.cpp
qgsjsonutils.cpp
qgslabelfeature.cpp
Expand Down Expand Up @@ -616,6 +617,7 @@ SET(QGIS_CORE_MOC_HDRS
qgsgeometryvalidator.h
qgsgml.h
qgsgmlschema.h
qgshtmlutils.h
qgsmaplayer.h
qgsmaplayerlegend.h
qgsmaplayermodel.h
Expand Down
43 changes: 4 additions & 39 deletions src/core/qgsapplication.cpp
Expand Up @@ -1042,45 +1042,7 @@ QString QgsApplication::reportStyleSheet()
QColor myColor2 = myColor1;
myColor2 = myColor2.lighter( 110 ); //10% lighter
QString myStyle;
myStyle = "p.glossy{ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
" stop: 0 " + myColor1.name() + ","
" stop: 0.1 " + myColor2.name() + ","
" stop: 0.5 " + myColor1.name() + ","
" stop: 0.9 " + myColor2.name() + ","
" stop: 1 " + myColor1.name() + ");"
" color: black;"
" padding-left: 4px;"
" padding-top: 20px;"
" padding-bottom: 8px;"
" border: 1px solid #6c6c6c;"
"}"
"p.subheaderglossy{ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
" stop: 0 " + myColor1.name() + ","
" stop: 0.1 " + myColor2.name() + ","
" stop: 0.5 " + myColor1.name() + ","
" stop: 0.9 " + myColor2.name() + ","
" stop: 1 " + myColor1.name() + ");"
" font-weight: bold;"
" font-size: medium;"
" line-height: 1.1em;"
" width: 100%;"
" color: black;"
" padding-left: 4px;"
" padding-right: 4px;"
" padding-top: 20px;"
" padding-bottom: 8px;"
" border: 1px solid #6c6c6c;"
"}"
"th.glossy{ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
" stop: 0 " + myColor1.name() + ","
" stop: 0.1 " + myColor2.name() + ","
" stop: 0.5 " + myColor1.name() + ","
" stop: 0.9 " + myColor2.name() + ","
" stop: 1 " + myColor1.name() + ");"
" color: black;"
" border: 1px solid #6c6c6c;"
"}"
".overview{"
myStyle = ".overview{"
" font: 1.82em;"
" font-weight: bold;"
"}"
Expand Down Expand Up @@ -1149,6 +1111,9 @@ QString QgsApplication::reportStyleSheet()
" padding-left: 20px;"
" font-weight: bold;"
"}"
"th .strong {"
" font-weight: bold;"
"}"
".tabular-view{ "
" border-collapse: collapse;"
" width: 95%;"
Expand Down
14 changes: 14 additions & 0 deletions src/core/qgshtmlutils.cpp
@@ -0,0 +1,14 @@
#include "qgshtmlutils.h"

QString QgsHtmlUtils::buildBulletList( const QStringList &values )
{
QString s( QStringLiteral( "<ul>" ) );

for ( const QString &value : values )
{
s += QStringLiteral( "<li>%1</li>" ).arg( value );
}
s += QLatin1String( "</ul>" );

return s;
}
40 changes: 40 additions & 0 deletions src/core/qgshtmlutils.h
@@ -0,0 +1,40 @@
/***************************************************************************
qgshtmlutils.h
---------------------------
begin : November 2017
copyright : (C) 2017 by Etienne Trimaille
email : etienne dot trimaille at gmail dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSHTMLUTILS_H
#define QGSHTMLUTILS_H

#include "qgis.h"

/**
* \ingroup core
* \class QgsHtmlUtils
* \brief Class for HTML utilities.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsHtmlUtils
{
public:

/**
* Build a bullet list.
* This will return a HTML "ul" element.
*/
static QString buildBulletList( const QStringList &values );
};

#endif // QGSHTMLUTILS_H
22 changes: 0 additions & 22 deletions src/core/raster/qgsrasterdataprovider.cpp
Expand Up @@ -236,28 +236,6 @@ QStringList QgsRasterDataProvider::cStringList2Q_( char **stringList )

} // cStringList2Q_

QString QgsRasterDataProvider::makeTableCell( QString const &value )
{
return "<p>\n" + value + "</p>\n";
} // makeTableCell_

// convenience function for building metadata() HTML table cells
QString QgsRasterDataProvider::makeTableCells( QStringList const &values )
{
QString s( QStringLiteral( "<tr>" ) );

for ( QStringList::const_iterator i = values.begin();
i != values.end();
++i )
{
s += QgsRasterDataProvider::makeTableCell( *i );
}

s += QLatin1String( "</tr>" );

return s;
} // makeTableCell_

QString QgsRasterDataProvider::htmlMetadata()
{
QString s;
Expand Down
3 changes: 0 additions & 3 deletions src/core/raster/qgsrasterdataprovider.h
Expand Up @@ -510,9 +510,6 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
//! \note not available in Python bindings
static QStringList cStringList2Q_( char **stringList ) SIP_SKIP;

static QString makeTableCell( const QString &value );
static QString makeTableCells( const QStringList &values );

/**
* Dots per inch. Extended WMS (e.g. QGIS mapserver) support DPI dependent output and therefore
are suited for printing. A value of -1 means it has not been set */
Expand Down
3 changes: 3 additions & 0 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -397,6 +397,9 @@ QString QgsRasterLayer::htmlMetadata() const
}
myMetadata += QLatin1String( "</td></tr>\n" );

// Insert provider-specific (e.g. WMS-specific) metadata
myMetadata += mDataProvider->htmlMetadata();

// End Provider section
myMetadata += QLatin1String( "</table>\n<br><br>" );

Expand Down
14 changes: 9 additions & 5 deletions src/providers/arcgisrest/qgsamsprovider.cpp
Expand Up @@ -216,29 +216,33 @@ QgsRasterInterface *QgsAmsProvider::clone() const

static inline QString dumpVariantMap( const QVariantMap &variantMap, const QString &title = QString() )
{
QString result = QStringLiteral( "<table>" );
QString result;
if ( !title.isEmpty() )
{
result += QStringLiteral( "<tr><td class=\"glossy\" colspan=\"2\">%1</td></tr>" ).arg( title );
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td>" ).arg( title );
}
else
{
result += QStringLiteral( "<tr><td>" );
}
for ( auto it = variantMap.constBegin(); it != variantMap.constEnd(); ++it )
{
QVariantMap childMap = it.value().toMap();
if ( childMap.isEmpty() )
{
result += QStringLiteral( "<tr><td>%1</td><td>%2</td></tr>" ).arg( it.key(), it.value().toString() );
result += QStringLiteral( "%1:%2</td></tr>" ).arg( it.key(), it.value().toString() );
}
else
{
result += QStringLiteral( "<tr><td>%1</td><td>%2</td></tr>" ).arg( it.key(), dumpVariantMap( childMap ) );
result += QStringLiteral( "%1:<table>%2</table></td></tr>" ).arg( it.key(), dumpVariantMap( childMap ) );
}
}
result += QLatin1String( "</table>" );
return result;
}

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

Expand Down

0 comments on commit 5c28eca

Please sign in to comment.