Skip to content
Permalink
Browse files
revert r15747
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15762 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 18, 2011
1 parent 6939937 commit 6e3833675abbca738d85a9102cf822b6803c563e
@@ -60,12 +60,6 @@ class QgsDataProvider : QObject
*/
virtual QgsRectangle extent() = 0;

/**
* Set the extent of the layer
* @param extent the layer extent
* @note added in 1.8
*/
virtual void setExtent( QgsRectangle extent );

/**
* Returns true if this is a valid layer. It is up to individual providers
@@ -6278,8 +6278,7 @@ QgsRasterLayer* QgisApp::addRasterLayer(
QStringList const & layers,
QStringList const & styles,
QString const &format,
QString const &crs,
QgsRectangle extent )
QString const &crs )
{
QgsDebugMsg( "about to get library for " + providerKey );

@@ -6308,7 +6307,7 @@ QgsRasterLayer* QgisApp::addRasterLayer(
+ " and CRS of " + crs );

// TODO: Remove the 0 when the raster layer becomes a full provider gateway.
layer = new QgsRasterLayer( 0, rasterLayerPath, baseName, providerKey, layers, styles, format, crs, extent );
layer = new QgsRasterLayer( 0, rasterLayerPath, baseName, providerKey, layers, styles, format, crs );

QgsDebugMsg( "Constructed new layer." );

@@ -123,8 +123,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QStringList const & layers,
QStringList const & styles,
QString const & format,
QString const & crs,
QgsRectangle extent );
QString const & crs );

/** open a raster layer for the given file
@returns false if unable to open a raster layer for rasterFile
@@ -111,7 +111,7 @@ QgsRasterLayer* QgisAppInterface::addRasterLayer( QString rasterLayerPath, QStri
QgsRasterLayer* QgisAppInterface::addRasterLayer( const QString& url, const QString& baseName, const QString& providerKey,
const QStringList& layers, const QStringList& styles, const QString& format, const QString& crs )
{
return qgis->addRasterLayer( url, baseName, providerKey, layers, styles, format, crs, QgsRectangle() );
return qgis->addRasterLayer( url, baseName, providerKey, layers, styles, format, crs );
}


@@ -53,7 +53,6 @@

QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl )
: QDialog( parent, fl )
, mWmsProvider( 0 )
, mCurrentTileset( 0 )
{
setupUi( this );
@@ -164,10 +163,9 @@ QgsWMSSourceSelect::~QgsWMSSourceSelect()
QSettings settings;
QgsDebugMsg( "saving geometry" );
settings.setValue( "/Windows/WMSSourceSelect/geometry", saveGeometry() );

delete mWmsProvider;
}


void QgsWMSSourceSelect::populateConnectionList()
{
QSettings settings;
@@ -283,20 +281,20 @@ QgsNumericSortTreeWidgetItem *QgsWMSSourceSelect::createItem(
return item;
}

bool QgsWMSSourceSelect::populateLayerList()
bool QgsWMSSourceSelect::populateLayerList( QgsWmsProvider *wmsProvider )
{
mCRSs.clear();

QVector<QgsWmsLayerProperty> layers;
if ( !mWmsProvider->supportedLayers( layers ) )
if ( !wmsProvider->supportedLayers( layers ) )
return false;

foreach( QAbstractButton *b, mImageFormatGroup->buttons() )
{
b->setHidden( true );
}

foreach( QString encoding, mWmsProvider->supportedImageEncodings() )
foreach( QString encoding, wmsProvider->supportedImageEncodings() )
{
int id = mMimeMap.value( encoding, -1 );
if ( id < 0 )
@@ -313,7 +311,7 @@ bool QgsWMSSourceSelect::populateLayerList()
QMap<int, QgsNumericSortTreeWidgetItem *> items;
QMap<int, int> layerParents;
QMap<int, QStringList> layerParentNames;
mWmsProvider->layerParents( layerParents, layerParentNames );
wmsProvider->layerParents( layerParents, layerParentNames );

lstLayers->clear();
lstLayers->setSortingEnabled( true );
@@ -350,7 +348,7 @@ bool QgsWMSSourceSelect::populateLayerList()
lstLayers->sortByColumn( 0, Qt::AscendingOrder );

QVector<QgsWmsTileSetProfile> tilesets;
mWmsProvider->supportedTileSets( tilesets );
wmsProvider->supportedTileSets( tilesets );

tabServers->setTabEnabled( tabServers->indexOf( tabTilesets ), tilesets.size() > 0 );
if ( tabServers->isTabEnabled( tabServers->indexOf( tabTilesets ) ) )
@@ -474,23 +472,24 @@ void QgsWMSSourceSelect::on_btnConnect_clicked()
// load the server data provider plugin
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();

delete mWmsProvider;

mWmsProvider = static_cast< QgsWmsProvider * >( pReg->getProvider( "wms", mConnectionInfo ) );
QgsWmsProvider *wmsProvider =
( QgsWmsProvider* ) pReg->getProvider( "wms", mConnectionInfo );

if ( mWmsProvider )
if ( wmsProvider )
{
QApplication::setOverrideCursor( Qt::WaitCursor );

connect( mWmsProvider, SIGNAL( statusChanged( QString ) ), this, SLOT( showStatusMessage( QString ) ) );
connect( wmsProvider, SIGNAL( statusChanged( QString ) ), this, SLOT( showStatusMessage( QString ) ) );

// WMS Provider all set up; let's get some layers

if ( !populateLayerList() )
if ( !populateLayerList( wmsProvider ) )
{
showError();
showError( wmsProvider );
}

delete wmsProvider;

QApplication::restoreOverrideCursor();
}
else
@@ -541,14 +540,9 @@ void QgsWMSSourceSelect::addClicked()
}
}

// set the layers to retrieve the correct extent
mWmsProvider->addLayers( layers, styles );
mWmsProvider->setImageEncoding( format );
mWmsProvider->setImageCrs( crs );

QgisApp::instance()->addRasterLayer( connInfo,
leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(),
"wms", layers, styles, format, crs, mWmsProvider->extent() );
"wms", layers, styles, format, crs );
}

void QgsWMSSourceSelect::enableLayersForCrs( QTreeWidgetItem *item )
@@ -1001,18 +995,18 @@ void QgsWMSSourceSelect::showStatusMessage( QString const &theMessage )
}


void QgsWMSSourceSelect::showError()
void QgsWMSSourceSelect::showError( QgsWmsProvider * wms )
{
QgsMessageViewer * mv = new QgsMessageViewer( this );
mv->setWindowTitle( mWmsProvider->lastErrorTitle() );
mv->setWindowTitle( wms->lastErrorTitle() );

if ( mWmsProvider->lastErrorFormat() == "text/html" )
if ( wms->lastErrorFormat() == "text/html" )
{
mv->setMessageAsHtml( mWmsProvider->lastError() );
mv->setMessageAsHtml( wms->lastError() );
}
else
{
mv->setMessageAsPlainText( tr( "Could not understand the response. The %1 provider said:\n%2" ).arg( mWmsProvider->name() ).arg( mWmsProvider->lastError() ) );
mv->setMessageAsPlainText( tr( "Could not understand the response. The %1 provider said:\n%2" ).arg( wms->name() ).arg( wms->lastError() ) );
}
mv->showMessage( true ); // Is deleted when closed
}
@@ -21,7 +21,6 @@
#include "ui_qgswmssourceselectbase.h"
#include "qgisgui.h"
#include "qgscontexthelp.h"
#include "qgsrectangle.h"

#include <QStringList>
#include <QPushButton>
@@ -85,7 +84,7 @@ class QgsWMSSourceSelect : public QDialog, private Ui::QgsWMSSourceSelectBase
void showStatusMessage( QString const &theMessage );

//! show whatever error is exposed by the QgsWmsProvider.
void showError();
void showError( QgsWmsProvider *wms );

//! Stores the selected datasource whenerver it is changed
void on_cmbConnections_activated( int );
@@ -144,7 +143,7 @@ class QgsWMSSourceSelect : public QDialog, private Ui::QgsWMSSourceSelectBase
* \retval false if the layers could not be retrieved or parsed -
* see mWmsProvider->errorString() for more info
*/
bool populateLayerList();
bool populateLayerList( QgsWmsProvider *wmsProvider );

//! create an item including possible parents
QgsNumericSortTreeWidgetItem *createItem( int id,
@@ -187,7 +186,6 @@ class QgsWMSSourceSelect : public QDialog, private Ui::QgsWMSSourceSelectBase
QString selectedImageEncoding();

QList<QTreeWidgetItem*> mCurrentSelection;
QgsWmsProvider *mWmsProvider;
QTableWidgetItem* mCurrentTileset;

private slots:
@@ -22,8 +22,7 @@
#include <QString>
#include <QStringList>

#include <qgsrectangle.h>

class QgsRectangle;
class QgsCoordinateReferenceSystem;


@@ -91,15 +90,6 @@ class CORE_EXPORT QgsDataProvider : public QObject
*/
virtual QgsRectangle extent() = 0;

/**
* Set the extent of the layer
* @param extent the layer extent
* @note added in 1.8
*/
virtual void setExtent( QgsRectangle extent )
{
// NOP by default
}

/**
* Returns true if this is a valid layer. It is up to individual providers
@@ -99,7 +99,7 @@ QgsRasterLayer::QgsRasterLayer(

// TODO, call constructor with provider key for now
init();
setDataProvider( "gdal", QStringList(), QStringList(), QString(), QString(), loadDefaultStyleFlag, QgsRectangle() );
setDataProvider( "gdal", QStringList(), QStringList(), QString(), QString(), loadDefaultStyleFlag );
return;


@@ -116,8 +116,7 @@ QgsRasterLayer::QgsRasterLayer( int dummy,
QStringList const & layers,
QStringList const & styles,
QString const & format,
QString const & crs,
QgsRectangle extent )
QString const & crs )
: QgsMapLayer( RasterLayer, baseName, rasterLayerPath )
, mStandardDeviations( 0 )
, mDataProvider( 0 )
@@ -140,7 +139,7 @@ QgsRasterLayer::QgsRasterLayer( int dummy,
init();
// if we're given a provider type, try to create and bind one to this layer
bool loadDefaultStyleFlag = false ; // ???
setDataProvider( providerKey, layers, styles, format, crs, loadDefaultStyleFlag, extent );
setDataProvider( providerKey, layers, styles, format, crs, loadDefaultStyleFlag );

// Default for the popup menu
// TODO: popMenu = 0;
@@ -2251,7 +2250,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
QString const & format,
QString const & crs )
{
setDataProvider( provider, layers, styles, format, crs, false, QgsRectangle() );
setDataProvider( provider, layers, styles, format, crs, false );
}

/** Copied from QgsVectorLayer::setDataProvider
@@ -2262,8 +2261,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
QStringList const & styles,
QString const & format,
QString const & crs,
bool loadDefaultStyleFlag,
QgsRectangle extent )
bool loadDefaultStyleFlag )
{
// XXX should I check for and possibly delete any pre-existing providers?
// XXX How often will that scenario occur?
@@ -2287,6 +2285,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
return;
}


QgsDebugMsg( "Instantiated the data provider plugin"
+ QString( " with layer list of " ) + layers.join( ", " )
+ " and style list of " + styles.join( ", " )
@@ -2303,18 +2302,8 @@ void QgsRasterLayer::setDataProvider( QString const & provider,

setNoDataValue( mDataProvider->noDataValue() );

QgsRectangle mbr;
if ( mDataProvider && !extent.isEmpty() )
{
// set the extent
mDataProvider->setExtent( extent );
mbr = extent;
}
else
{
// get the extent
mbr = mDataProvider->extent();
}
// get the extent
QgsRectangle mbr = mDataProvider->extent();

// show the extent
QString s = mbr.toString();
@@ -4468,7 +4457,6 @@ double QgsRasterLayer::readValue( void *data, int type, int index )
bool QgsRasterLayer::update()
{
QgsDebugMsg( "entered." );

// Check if data changed
if ( mDataProvider->dataTimestamp() > mDataProvider->timestamp() )
{
@@ -207,8 +207,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
const QStringList & layers = QStringList(),
const QStringList & styles = QStringList(),
const QString & format = QString(),
const QString & crs = QString(),
const QgsRectangle extent = QgsRectangle() );
const QString & crs = QString() );


/** \brief The destructor */
@@ -313,8 +312,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
const QStringList & styles,
const QString & format,
const QString & crs,
bool loadDefaultStyleFlag,
QgsRectangle extent );
bool loadDefaultStyleFlag );

static QLibrary* loadProviderLibrary( QString theProviderKey );
static QgsRasterDataProvider* loadProvider( QString theProviderKey, QString theDataSource = 0 );
@@ -899,7 +899,7 @@ bool QgsWmsProvider::retrieveServerCapabilities( bool forceRefresh )

QNetworkRequest request( url );
setAuthorization( request );
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, forceRefresh ? QNetworkRequest::PreferNetwork : QNetworkRequest::PreferCache );
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork );
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );

QgsDebugMsg( QString( "getcapabilities: %1" ).arg( url ) );
@@ -978,9 +978,6 @@ void QgsWmsProvider::capabilitiesReplyFinished()
return;
}

QgsDebugMsg( QString( "getcapabilities from cache: %1" )
.arg( mCapabilitiesReply->attribute( QNetworkRequest::SourceIsFromCacheAttribute ).toBool() ? "yes" : "no" ) );

httpcapabilitiesresponse = mCapabilitiesReply->readAll();

if ( httpcapabilitiesresponse.isEmpty() )
@@ -2031,11 +2028,7 @@ void QgsWmsProvider::parseServiceException( QDomElement const & e )
QgsDebugMsg( "exiting." );
}

void QgsWmsProvider::setExtent( QgsRectangle extent )
{
layerExtent = extent;
extentDirty = false;
}


QgsRectangle QgsWmsProvider::extent()
{
@@ -2177,6 +2170,7 @@ bool QgsWmsProvider::calculateExtent()
QgsDebugMsg( "exiting with '" + layerExtent.toString() + "'." );

return true;

}


0 comments on commit 6e38336

Please sign in to comment.