mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
improve wms error and progress reporting (fixes #1576)
git-svn-id: http://svn.osgeo.org/qgis/trunk@15763 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
173037d6c9
commit
d0e5af4cb1
@ -5522,7 +5522,15 @@ void QgisApp::layerWasAdded( QgsMapLayer *layer )
|
||||
|
||||
QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer );
|
||||
if ( rlayer )
|
||||
{
|
||||
// connect up any request the raster may make to update the app progress
|
||||
connect( rlayer, SIGNAL( drawingProgress( int, int ) ), this, SLOT( showProgress( int, int ) ) );
|
||||
|
||||
// connect up any request the raster may make to update the statusbar message
|
||||
connect( rlayer, SIGNAL( statusChanged( QString ) ), this, SLOT( showStatusMessage( QString ) ) );
|
||||
|
||||
provider = rlayer->dataProvider();
|
||||
}
|
||||
|
||||
if ( provider )
|
||||
{
|
||||
@ -6196,14 +6204,6 @@ bool QgisApp::addRasterLayer( QgsRasterLayer *theRasterLayer )
|
||||
// register this layer with the central layers registry
|
||||
QgsMapLayerRegistry::instance()->addMapLayer( theRasterLayer );
|
||||
|
||||
// connect up any request the raster may make to update the app progress
|
||||
connect( theRasterLayer, SIGNAL( drawingProgress( int, int ) ),
|
||||
this, SLOT( showProgress( int, int ) ) );
|
||||
|
||||
// connect up any request the raster may make to update the statusbar message
|
||||
connect( theRasterLayer, SIGNAL( statusChanged( QString ) ),
|
||||
this, SLOT( showStatusMessage( QString ) ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -155,13 +155,6 @@ QgsRasterLayer::QgsRasterLayer( int dummy,
|
||||
|
||||
// TODO: Connect signals from the dataprovider to the qgisapp
|
||||
|
||||
// Do a passthrough for the status bar text
|
||||
#if 0
|
||||
connect(
|
||||
mDataProvider, SIGNAL( statusChanged( QString ) ),
|
||||
this, SLOT( showStatusMessage( QString ) )
|
||||
);
|
||||
#endif
|
||||
QgsDebugMsg( "(8 arguments) exiting." );
|
||||
|
||||
emit statusChanged( tr( "QgsRasterLayer created" ) );
|
||||
@ -2199,7 +2192,7 @@ QLibrary* QgsRasterLayer::loadProviderLibrary( QString theProviderKey )
|
||||
|
||||
if ( !loaded )
|
||||
{
|
||||
QgsLogger::warning( "QgsRasterLayer::setDataProvider: Failed to load " );
|
||||
QgsLogger::warning( "QgsRasterLayer::loadProviderLibrary: Failed to load " );
|
||||
return NULL;
|
||||
}
|
||||
QgsDebugMsg( "Loaded data provider library" );
|
||||
@ -2223,7 +2216,7 @@ QgsRasterDataProvider* QgsRasterLayer::loadProvider( QString theProviderKey, QSt
|
||||
|
||||
if ( !classFactory )
|
||||
{
|
||||
QgsLogger::warning( "QgsRasterLayer::setDataProvider: Cannot resolve the classFactory function" );
|
||||
QgsLogger::warning( "QgsRasterLayer::loadProvider: Cannot resolve the classFactory function" );
|
||||
return NULL;
|
||||
}
|
||||
QgsDebugMsg( "Getting pointer to a mDataProvider object from the library" );
|
||||
@ -2237,7 +2230,7 @@ QgsRasterDataProvider* QgsRasterLayer::loadProvider( QString theProviderKey, QSt
|
||||
|
||||
if ( !myDataProvider )
|
||||
{
|
||||
QgsLogger::warning( "QgsRasterLayer::setDataProvider: Unable to instantiate the data provider plugin" );
|
||||
QgsLogger::warning( "QgsRasterLayer::loadProvider: Unable to instantiate the data provider plugin" );
|
||||
return NULL;
|
||||
}
|
||||
QgsDebugMsg( "Data driver created" );
|
||||
@ -2506,6 +2499,12 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
|
||||
this, SLOT( onProgress( int, double, QString ) )
|
||||
);
|
||||
|
||||
// Do a passthrough for the status bar text
|
||||
connect(
|
||||
mDataProvider, SIGNAL( statusChanged( QString ) ),
|
||||
this, SIGNAL( statusChanged( QString ) )
|
||||
);
|
||||
|
||||
//mark the layer as valid
|
||||
mValid = true;
|
||||
|
||||
@ -2895,6 +2894,7 @@ QStringList QgsRasterLayer::subLayers() const
|
||||
return mDataProvider->subLayers();
|
||||
}
|
||||
|
||||
|
||||
void QgsRasterLayer::thumbnailAsPixmap( QPixmap * theQPixmap )
|
||||
{
|
||||
//TODO: This should be depreciated and a new function written that just returns a new QPixmap, it will be safer
|
||||
|
@ -63,9 +63,15 @@ void QgsMessageViewer::setMessage( const QString& message, MessageType msgType )
|
||||
void QgsMessageViewer::showMessage( bool blocking )
|
||||
{
|
||||
if ( blocking )
|
||||
{
|
||||
QApplication::setOverrideCursor( Qt::ArrowCursor );
|
||||
exec();
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMessageViewer::setTitle( const QString& title )
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "qgsrectangle.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include "qgsnetworkaccessmanager.h"
|
||||
#include <qgsmessageoutput.h>
|
||||
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
@ -772,9 +773,28 @@ void QgsWmsProvider::tileReplyFinished()
|
||||
if ( !status.isNull() && status.toInt() >= 400 )
|
||||
{
|
||||
QVariant phrase = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute );
|
||||
mErrorFormat = "text/plain";
|
||||
mError = tr( "tile request err %1: %2" ).arg( status.toInt() ).arg( phrase.toString() );
|
||||
emit statusChanged( mError );
|
||||
|
||||
showMessageBox( tr( "Tile request error" ), tr( "Status: %1\nReason phrase: %2" ).arg( status.toInt() ).arg( phrase.toString() ) );
|
||||
|
||||
tileReplies.removeOne( reply );
|
||||
reply->deleteLater();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString();
|
||||
QgsDebugMsg( "contentType: " + contentType );
|
||||
if ( !contentType.startsWith( "image/" ) )
|
||||
{
|
||||
QByteArray text = reply->readAll();
|
||||
if ( contentType == "text/xml" && parseServiceExceptionReportDom( text ) )
|
||||
{
|
||||
showMessageBox( mErrorCaption, mError );
|
||||
}
|
||||
else
|
||||
{
|
||||
showMessageBox( "Tile request error", tr( "response: %1" ).arg( QString::fromUtf8( text ) ) );
|
||||
}
|
||||
|
||||
tileReplies.removeOne( reply );
|
||||
reply->deleteLater();
|
||||
@ -854,9 +874,8 @@ void QgsWmsProvider::cacheReplyFinished()
|
||||
if ( !status.isNull() && status.toInt() >= 400 )
|
||||
{
|
||||
QVariant phrase = cacheReply->attribute( QNetworkRequest::HttpReasonPhraseAttribute );
|
||||
mErrorFormat = "text/plain";
|
||||
mError = tr( "map request error %1: %2" ).arg( status.toInt() ).arg( phrase.toString() );
|
||||
emit statusChanged( mError );
|
||||
|
||||
showMessageBox( tr( "Map request error" ), tr( "Status: %1\nReason phrase: %2" ).arg( status.toInt() ).arg( phrase.toString() ) );
|
||||
|
||||
cacheReply->deleteLater();
|
||||
cacheReply = 0;
|
||||
@ -864,11 +883,31 @@ void QgsWmsProvider::cacheReplyFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
QString contentType = cacheReply->header( QNetworkRequest::ContentTypeHeader ).toString();
|
||||
QgsDebugMsg( "contentType: " + contentType );
|
||||
if ( contentType.startsWith( "image/" ) )
|
||||
{
|
||||
QImage myLocalImage = QImage::fromData( cacheReply->readAll() );
|
||||
QPainter p( cachedImage );
|
||||
p.drawImage( 0, 0, myLocalImage );
|
||||
}
|
||||
else
|
||||
{
|
||||
QByteArray text = cacheReply->readAll();
|
||||
if ( contentType == "text/xml" && parseServiceExceptionReportDom( text ) )
|
||||
{
|
||||
showMessageBox( mErrorCaption, mError );
|
||||
}
|
||||
else
|
||||
{
|
||||
showMessageBox( tr( "Map request error" ), tr( "Response: %1" ).arg( QString::fromUtf8( text ) ) );
|
||||
}
|
||||
|
||||
cacheReply->deleteLater();
|
||||
cacheReply = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
cacheReply->deleteLater();
|
||||
cacheReply = 0;
|
||||
@ -1015,12 +1054,16 @@ int QgsWmsProvider::bandCount() const
|
||||
|
||||
void QgsWmsProvider::capabilitiesReplyProgress( qint64 bytesReceived, qint64 bytesTotal )
|
||||
{
|
||||
emit statusChanged( tr( "%1 of %2 bytes of capabilities downloaded." ).arg( bytesReceived ).arg( bytesTotal < 0 ? QString( "unknown number of" ) : QString::number( bytesTotal ) ) );
|
||||
QString msg = tr( "%1 of %2 bytes of capabilities downloaded." ).arg( bytesReceived ).arg( bytesTotal < 0 ? QString( "unknown number of" ) : QString::number( bytesTotal ) );
|
||||
QgsDebugMsg( msg );
|
||||
emit statusChanged( msg );
|
||||
}
|
||||
|
||||
void QgsWmsProvider::cacheReplyProgress( qint64 bytesReceived, qint64 bytesTotal )
|
||||
{
|
||||
emit statusChanged( tr( "%1 of %2 bytes of map downloaded." ).arg( bytesReceived ).arg( bytesTotal < 0 ? QString( "unknown number of" ) : QString::number( bytesTotal ) ) );
|
||||
QString msg = tr( "%1 of %2 bytes of map downloaded." ).arg( bytesReceived ).arg( bytesTotal < 0 ? QString( "unknown number of" ) : QString::number( bytesTotal ) );
|
||||
QgsDebugMsg( msg );
|
||||
emit statusChanged( msg );
|
||||
}
|
||||
|
||||
bool QgsWmsProvider::parseCapabilitiesDom( QByteArray const &xml, QgsWmsCapabilitiesProperty& capabilitiesProperty )
|
||||
@ -2812,7 +2855,7 @@ void QgsWmsProvider::identifyReplyFinished()
|
||||
QVariant redirect = mIdentifyReply->attribute( QNetworkRequest::RedirectionTargetAttribute );
|
||||
if ( !redirect.isNull() )
|
||||
{
|
||||
emit statusChanged( QString( "identify request redirected to %1" ).arg( redirect.toString() ) );
|
||||
QgsDebugMsg( QString( "identify request redirected to %1" ).arg( redirect.toString() ) );
|
||||
emit statusChanged( tr( "identify request redirected." ) );
|
||||
|
||||
mIdentifyReply->deleteLater();
|
||||
@ -2829,7 +2872,7 @@ void QgsWmsProvider::identifyReplyFinished()
|
||||
{
|
||||
QVariant phrase = mIdentifyReply->attribute( QNetworkRequest::HttpReasonPhraseAttribute );
|
||||
mErrorFormat = "text/plain";
|
||||
mError = tr( "map request error %1: %2" ).arg( status.toInt() ).arg( phrase.toString() );
|
||||
mError = tr( "Map request error %1: %2" ).arg( status.toInt() ).arg( phrase.toString() );
|
||||
emit statusChanged( mError );
|
||||
|
||||
mIdentifyResult = "";
|
||||
@ -2895,6 +2938,14 @@ void QgsWmsProvider::setAuthorization( QNetworkRequest &request ) const
|
||||
}
|
||||
}
|
||||
|
||||
void QgsWmsProvider::showMessageBox( const QString& title, const QString& text )
|
||||
{
|
||||
QgsMessageOutput *message = QgsMessageOutput::createMessageOutput();
|
||||
message->setTitle( title );
|
||||
message->setMessage( text, QgsMessageOutput::MessageText );
|
||||
message->showMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Class factory to return a pointer to a newly created
|
||||
* QgsWmsProvider object
|
||||
|
@ -650,6 +650,8 @@ class QgsWmsProvider : public QgsRasterDataProvider
|
||||
void tileReplyFinished();
|
||||
|
||||
private:
|
||||
void showMessageBox( const QString& title, const QString& text );
|
||||
|
||||
/**
|
||||
* \brief Retrieve and parse the (cached) Capabilities document from the server
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user