Skip to content

Commit

Permalink
revert r15747
Browse files Browse the repository at this point in the history
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 6e38336
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 91 deletions.
6 changes: 0 additions & 6 deletions python/core/qgsdataprovider.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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." );

Expand Down
3 changes: 1 addition & 2 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}


Expand Down
46 changes: 20 additions & 26 deletions src/app/qgswmssourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

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

delete mWmsProvider;
}


void QgsWMSSourceSelect::populateConnectionList()
{
QSettings settings;
Expand Down Expand Up @@ -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 )
Expand All @@ -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 );
Expand Down Expand Up @@ -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 ) ) )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 2 additions & 4 deletions src/app/qgswmssourceselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "ui_qgswmssourceselectbase.h"
#include "qgisgui.h"
#include "qgscontexthelp.h"
#include "qgsrectangle.h"

#include <QStringList>
#include <QPushButton>
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -187,7 +186,6 @@ class QgsWMSSourceSelect : public QDialog, private Ui::QgsWMSSourceSelectBase
QString selectedImageEncoding();

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

private slots:
Expand Down
12 changes: 1 addition & 11 deletions src/core/qgsdataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#include <QString>
#include <QStringList>

#include <qgsrectangle.h>

class QgsRectangle;
class QgsCoordinateReferenceSystem;


Expand Down Expand Up @@ -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
Expand Down
28 changes: 8 additions & 20 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand All @@ -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 )
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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?
Expand All @@ -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( ", " )
Expand All @@ -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();
Expand Down Expand Up @@ -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() )
{
Expand Down
6 changes: 2 additions & 4 deletions src/core/raster/qgsrasterlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 );
Expand Down
12 changes: 3 additions & 9 deletions src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -2031,11 +2028,7 @@ void QgsWmsProvider::parseServiceException( QDomElement const & e )
QgsDebugMsg( "exiting." );
}

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


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

return true;

}


Expand Down
Loading

0 comments on commit 6e38336

Please sign in to comment.