242 changes: 92 additions & 150 deletions src/mapserver/qgsprojectparser.cpp

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions src/mapserver/qgsprojectparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class QgsProjectParser: public QgsConfigParser
int numberOfLayers() const;

/**Returns one or possibly several maplayers for a given layer name and style. If no layers/style are found, an empty list is returned*/
virtual QList<QgsMapLayer*> mapLayerFromStyle( const QString& lName, const QString& styleName, bool allowCaching = true ) const;
virtual QList<QgsMapLayer*> mapLayerFromStyle( const QString& lName, const QString& styleName, bool useCache = true ) const;

/**Fills a layer and a style list. The two list have the same number of entries and the style and the layer at a position belong together (similar to the HTTP parameters 'Layers' and 'Styles'. Returns 0 in case of success*/
virtual int layersAndStyles( QStringList& layers, QStringList& styles ) const;
Expand Down Expand Up @@ -102,23 +102,28 @@ class QgsProjectParser: public QgsConfigParser
void serviceCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;

private:

//forbidden
QgsProjectParser();

/**Content of project file*/
QDomDocument* mXMLDoc;

/**Absolute project file path (including file name)*/
QString mProjectPath;

/**Get all layers of the project (ordered same as in the project file)*/
QList<QDomElement> projectLayerElements() const;
/**Returns all legend group elements*/
QList<QDomElement> legendGroupElements() const;
/**Get all layers of the project, accessible by layer id*/
QMap< QString, QDomElement > projectLayerElementsById() const;
/**Get all layers of the project, accessible by layer name*/
QMap< QString, QDomElement > projectLayerElementsByName() const;
/**List of project layer (ordered same as in the project file)*/
QList<QDomElement> mProjectLayerElements;
/**List of all legend group elements*/
QList<QDomElement> mLegendGroupElements;
/**Project layer elements, accessible by layer id*/
QHash< QString, QDomElement > mProjectLayerElementsById;
/**Project layer elements, accessible by layer name*/
QHash< QString, QDomElement > mProjectLayerElementsByName;

/**Creates a maplayer object from <maplayer> element. The layer cash owns the maplayer, so don't delete it
@return the maplayer or 0 in case of error*/
QgsMapLayer* createLayerFromElement( const QDomElement& elem ) const;
QgsMapLayer* createLayerFromElement( const QDomElement& elem, bool useCache = true ) const;
/**Returns the text of the <id> element for a layer element
@return id or a null string in case of error*/
QString layerId( const QDomElement& layerElem ) const;
Expand Down
27 changes: 4 additions & 23 deletions src/mapserver/qgssldparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,6 @@ QgsSLDParser::QgsSLDParser(): mXMLDoc( 0 )

QgsSLDParser::~QgsSLDParser()
{
//remove the temporary files
for ( QList<QTemporaryFile*>::const_iterator it = mFilesToRemove.constBegin(); it != mFilesToRemove.constEnd(); ++it )
{
delete *it;
}

//and also those the temporary file paths
for ( QList<QString>::const_iterator it = mFilePathsToRemove.constBegin(); it != mFilePathsToRemove.constEnd(); ++it )
{
QFile::remove( *it );
}

//delete the layers in the list
QList<QgsMapLayer*>::iterator layer_it = mLayersToRemove.begin();
for ( ; layer_it != mLayersToRemove.end(); ++layer_it )
{
delete *layer_it;
}

delete mXMLDoc;
}

Expand Down Expand Up @@ -275,7 +256,7 @@ void QgsSLDParser::layersAndStylesCapabilities( QDomElement& parentElement, QDom
}
}

QList<QgsMapLayer*> QgsSLDParser::mapLayerFromStyle( const QString& layerName, const QString& styleName, bool allowCaching ) const
QList<QgsMapLayer*> QgsSLDParser::mapLayerFromStyle( const QString& layerName, const QString& styleName, bool useCache ) const
{
QList<QgsMapLayer*> fallbackLayerList;
QList<QgsMapLayer*> resultList;
Expand All @@ -287,7 +268,7 @@ QList<QgsMapLayer*> QgsSLDParser::mapLayerFromStyle( const QString& layerName, c
QDomElement userStyleElement = findUserStyleElement( namedLayerElemList[i], styleName );
if ( !userStyleElement.isNull() )
{
fallbackLayerList = mFallbackParser->mapLayerFromStyle( layerName, "", allowCaching );
fallbackLayerList = mFallbackParser->mapLayerFromStyle( layerName, "", false );
if ( fallbackLayerList.size() > 0 )
{
QgsVectorLayer* v = dynamic_cast<QgsVectorLayer*>( fallbackLayerList.at( 0 ) );
Expand Down Expand Up @@ -335,7 +316,7 @@ QList<QgsMapLayer*> QgsSLDParser::mapLayerFromStyle( const QString& layerName, c
//maybe named layer and named style is defined in the fallback SLD?
if ( mFallbackParser )
{
resultList = mFallbackParser->mapLayerFromStyle( layerName, styleName, allowCaching );
resultList = mFallbackParser->mapLayerFromStyle( layerName, styleName, useCache );
}

QList<QgsMapLayer*>::iterator it = resultList.begin();
Expand All @@ -349,7 +330,7 @@ QList<QgsMapLayer*> QgsSLDParser::mapLayerFromStyle( const QString& layerName, c

QDomElement userStyleElement = findUserStyleElement( userLayerElement, styleName );

QgsMapLayer* theMapLayer = mapLayerFromUserLayer( userLayerElement, layerName, allowCaching );
QgsMapLayer* theMapLayer = mapLayerFromUserLayer( userLayerElement, layerName, useCache );
if ( !theMapLayer )
{
return resultList;
Expand Down
16 changes: 1 addition & 15 deletions src/mapserver/qgssldparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class QgsRenderer;
#include <map>
#include <QList>
#include <QString>
#include <QTemporaryFile>

#ifdef DIAGRAMSERVER
#include "qgsdiagramcategory.h"
Expand All @@ -61,7 +60,7 @@ class QgsSLDParser: public QgsConfigParser
int numberOfLayers() const;

/**Returns one or possibly several maplayers for a given layer name and style. If no layers/style are found, an empty list is returned*/
QList<QgsMapLayer*> mapLayerFromStyle( const QString& layerName, const QString& styleName, bool allowCaching = true ) const;
QList<QgsMapLayer*> mapLayerFromStyle( const QString& layerName, const QString& styleName, bool useCache = true ) const;

/**Fills a layer and a style list. The two list have the same number of entries and the style and the layer at a position belong together (similar to the HTTP parameters 'Layers' and 'Styles'. Returns 0 in case of success*/
int layersAndStyles( QStringList& layers, QStringList& styles ) const;
Expand Down Expand Up @@ -144,25 +143,12 @@ class QgsSLDParser: public QgsConfigParser
double scaleFactorFromScaleTag( const QDomElement& scaleElem ) const;
#endif //DIAGRAMSERVER



/**SLD as dom document*/
QDomDocument* mXMLDoc;

/**Map containing the WMS parameters of the request*/
std::map<QString, QString> mParameterMap;

//todo: leave this to the layer cash?
/**Stores pointers to layers that have to be removed in the destructor of QgsSLDParser*/
mutable QList<QgsMapLayer*> mLayersToRemove;


/**Stores the temporary file objects. The class takes ownership of the objects and deletes them in the destructor*/
mutable QList<QTemporaryFile*> mFilesToRemove;
/**Stores paths of files that need to be removed after each request (necessary because of contours shapefiles that \
cannot be handles with QTemporaryFile*/
mutable QList<QString> mFilePathsToRemove;

QString mSLDNamespace;
};

Expand Down
3 changes: 3 additions & 0 deletions src/providers/postgres/qgspostgresdataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ QVector<QgsDataItem*> QgsPGConnectionItem::createChildren()
QgsDebugMsg( "mConnInfo = " + mConnInfo );

if ( !pgProvider->supportedLayers( mLayerProperties, true, false, false ) )
{
children.append( new QgsErrorItem( this, tr( "Failed to retrieve layers" ), mPath + "/error" ) );
return children;
}

QMap<QString, QVector<QgsPostgresLayerProperty> > schemasMap;
foreach( QgsPostgresLayerProperty layerProperty, mLayerProperties )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgswfsdataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ QVector<QgsDataItem*> QgsWFSConnectionItem::createChildren()
}
else
{
// TODO: return an "error" item
layers.append( new QgsErrorItem( this, tr( "Failed to retrieve layers" ), mPath + "/error" ) );
}

mConn->deleteLater();
Expand Down
2 changes: 2 additions & 0 deletions src/providers/wms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ SET (WMS_SRCS
qgswmsprovider.cpp
qgswmssourceselect.cpp
qgswmsconnection.cpp
qgswmsdataitems.cpp
)
SET (WMS_MOC_HDRS
qgswmsprovider.h
qgswmssourceselect.h
qgswmsconnection.h
qgswmsdataitems.h
)

QT4_WRAP_CPP (WMS_MOC_SRCS ${WMS_MOC_HDRS})
Expand Down
256 changes: 256 additions & 0 deletions src/providers/wms/qgswmsdataitems.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
#include "qgswmsdataitems.h"

#include "qgslogger.h"

#include "qgswmsconnection.h"
#include "qgswmssourceselect.h"

#include "qgsnewhttpconnection.h"

// ---------------------------------------------------------------------------
QgsWMSConnectionItem::QgsWMSConnectionItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
}

QgsWMSConnectionItem::~QgsWMSConnectionItem()
{
}

QVector<QgsDataItem*> QgsWMSConnectionItem::createChildren()
{
QgsDebugMsg( "Entered" );
QVector<QgsDataItem*> children;
QgsWMSConnection connection( mName );
QgsWmsProvider *wmsProvider = connection.provider( );
if ( !wmsProvider )
return children;

QString mConnInfo = connection.connectionInfo();
QgsDebugMsg( "mConnInfo = " + mConnInfo );

// Attention: supportedLayers() gives tree leafes, not top level
if ( !wmsProvider->supportedLayers( mLayerProperties ) )
{
children.append( new QgsErrorItem( this, tr( "Failed to retrieve layers" ), mPath + "/error" ) );
return children;
}

QgsWmsCapabilitiesProperty mCapabilitiesProperty = wmsProvider->capabilitiesProperty();
QgsWmsCapabilityProperty capabilityProperty = mCapabilitiesProperty.capability;

// Top level layer is present max once
// <element name="Capability">
// <element ref="wms:Layer" minOccurs="0"/> - default maxOccurs=1
QgsWmsLayerProperty topLayerProperty = capabilityProperty.layer;
foreach( QgsWmsLayerProperty layerProperty, topLayerProperty.layer )
{
// Attention, the name may be empty
QgsDebugMsg( QString::number( layerProperty.orderId ) + " " + layerProperty.name + " " + layerProperty.title );
QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name;

QgsWMSLayerItem * layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + "/" + pathName, mCapabilitiesProperty, mConnInfo, layerProperty );

children.append( layer );
}
return children;
}

bool QgsWMSConnectionItem::equal( const QgsDataItem *other )
{
if ( type() != other->type() )
{
return false;
}
const QgsWMSConnectionItem *o = dynamic_cast<const QgsWMSConnectionItem *>( other );
return ( mPath == o->mPath && mName == o->mName && mConnInfo == o->mConnInfo );
}

QList<QAction*> QgsWMSConnectionItem::actions()
{
QList<QAction*> lst;

QAction* actionEdit = new QAction( tr( "Edit..." ), this );
connect( actionEdit, SIGNAL( triggered() ), this, SLOT( editConnection() ) );
lst.append( actionEdit );

QAction* actionDelete = new QAction( tr( "Delete" ), this );
connect( actionDelete, SIGNAL( triggered() ), this, SLOT( deleteConnection() ) );
lst.append( actionDelete );

return lst;
}

void QgsWMSConnectionItem::editConnection()
{
QgsNewHttpConnection nc( 0, "/Qgis/connections-wms/", mName );

if ( nc.exec() )
{
// the parent should be updated
mParent->refresh();
}
}

void QgsWMSConnectionItem::deleteConnection()
{
QgsWMSConnection::deleteConnection( mName );
// the parent should be updated
mParent->refresh();
}


// ---------------------------------------------------------------------------

QgsWMSLayerItem::QgsWMSLayerItem( QgsDataItem* parent, QString name, QString path, QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperty )
: QgsLayerItem( parent, name, path, QString(), QgsLayerItem::Raster, "wms" ),
mCapabilitiesProperty( capabilitiesProperty ),
mConnInfo( connInfo ),
mLayerProperty( layerProperty )
//mProviderKey ("wms"),
//mLayerType ( QgsLayerItem::Raster )
{
mUri = createUri();
// Populate everything, it costs nothing, all info about layers is collected
foreach( QgsWmsLayerProperty layerProperty, mLayerProperty.layer )
{
// Attention, the name may be empty
QgsDebugMsg( QString::number( layerProperty.orderId ) + " " + layerProperty.name + " " + layerProperty.title );
QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name;
QgsWMSLayerItem * layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + "/" + pathName, mCapabilitiesProperty, mConnInfo, layerProperty );
mChildren.append( layer );
}

if ( mChildren.size() == 0 )
{
mIcon = QIcon( getThemePixmap( "mIconWmsLayer.png" ) );
}
mPopulated = true;
}

QgsWMSLayerItem::~QgsWMSLayerItem()
{
}

QString QgsWMSLayerItem::createUri()
{
QString uri;
if ( mLayerProperty.name.isEmpty() )
return uri; // layer collection

QString rasterLayerPath = mConnInfo;
QString baseName = mLayerProperty.name;

// Number of styles must match number of layers
QStringList layers;
layers << mLayerProperty.name;
QStringList styles;
if ( mLayerProperty.style.size() > 0 )
{
styles.append( mLayerProperty.style[0].name );
}
else
{
styles << ""; // TODO: use loadDefaultStyleFlag
}

QString format;
// get first supporte by qt and server
QVector<QgsWmsSupportedFormat> formats = QgsWmsProvider::supportedFormats();
foreach( QgsWmsSupportedFormat f, formats )
{
if ( mCapabilitiesProperty.capability.request.getMap.format.indexOf( f.format ) >= 0 )
{
format = f.format;
break;
}
}
QString crs;
// get first known if possible
QgsCoordinateReferenceSystem testCrs;
foreach( QString c, mLayerProperty.crs )
{
testCrs.createFromOgcWmsCrs( c );
if ( testCrs.isValid() )
{
crs = c;
break;
}
}
if ( crs.isEmpty() && mLayerProperty.crs.size() > 0 )
{
crs = mLayerProperty.crs[0];
}
uri = rasterLayerPath + "|layers=" + layers.join( "," ) + "|styles=" + styles.join( "," ) + "|format=" + format + "|crs=" + crs;

return uri;
}

// ---------------------------------------------------------------------------
QgsWMSRootItem::QgsWMSRootItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
mIcon = QIcon( getThemePixmap( "mIconWms.png" ) );

populate();
}

QgsWMSRootItem::~QgsWMSRootItem()
{
}

QVector<QgsDataItem*>QgsWMSRootItem::createChildren()
{
QVector<QgsDataItem*> connections;

foreach( QString connName, QgsWMSConnection::connectionList() )
{
QgsDataItem * conn = new QgsWMSConnectionItem( this, connName, mPath + "/" + connName );
connections.append( conn );
}
return connections;
}

QList<QAction*> QgsWMSRootItem::actions()
{
QList<QAction*> lst;

QAction* actionNew = new QAction( tr( "New..." ), this );
connect( actionNew, SIGNAL( triggered() ), this, SLOT( newConnection() ) );
lst.append( actionNew );

return lst;
}


QWidget * QgsWMSRootItem::paramWidget()
{
QgsWMSSourceSelect *select = new QgsWMSSourceSelect( 0, 0, true, true );
connect( select, SIGNAL( connectionsChanged() ), this, SLOT( connectionsChanged() ) );
return select;
}
void QgsWMSRootItem::connectionsChanged()
{
refresh();
}

void QgsWMSRootItem::newConnection()
{
QgsNewHttpConnection nc( 0 );

if ( nc.exec() )
{
refresh();
}
}


// ---------------------------------------------------------------------------

QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
{
Q_UNUSED( thePath );

return new QgsWMSRootItem( parentItem, "WMS", "wms:" );
}

63 changes: 63 additions & 0 deletions src/providers/wms/qgswmsdataitems.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef QGSWMSDATAITEMS_H
#define QGSWMSDATAITEMS_H

#include "qgswmsprovider.h"

class QgsWMSConnectionItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsWMSConnectionItem( QgsDataItem* parent, QString name, QString path );
~QgsWMSConnectionItem();

QVector<QgsDataItem*> createChildren();
virtual bool equal( const QgsDataItem *other );

virtual QList<QAction*> actions();

QgsWmsCapabilitiesProperty mCapabilitiesProperty;
QString mConnInfo;
QVector<QgsWmsLayerProperty> mLayerProperties;

public slots:
void editConnection();
void deleteConnection();
};

// WMS Layers may be nested, so that they may be both QgsDataCollectionItem and QgsLayerItem
// We have to use QgsDataCollectionItem and support layer methods if necessary
class QgsWMSLayerItem : public QgsLayerItem
{
Q_OBJECT
public:
QgsWMSLayerItem( QgsDataItem* parent, QString name, QString path,
QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperties );
~QgsWMSLayerItem();

QString createUri();

QgsWmsCapabilitiesProperty mCapabilitiesProperty;
QString mConnInfo;
QgsWmsLayerProperty mLayerProperty;
};

class QgsWMSRootItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsWMSRootItem( QgsDataItem* parent, QString name, QString path );
~QgsWMSRootItem();

QVector<QgsDataItem*> createChildren();

virtual QList<QAction*> actions();

virtual QWidget * paramWidget();

public slots:
void connectionsChanged();

void newConnection();
};

#endif // QGSWMSDATAITEMS_H
185 changes: 0 additions & 185 deletions src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3165,188 +3165,3 @@ QGISEXTERN int dataCapabilities()
{
return QgsDataProvider::Net;
}
// ---------------------------------------------------------------------------
QgsWMSConnectionItem::QgsWMSConnectionItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
}

QgsWMSConnectionItem::~QgsWMSConnectionItem()
{
}

QVector<QgsDataItem*> QgsWMSConnectionItem::createChildren()
{
QgsDebugMsg( "Entered" );
QVector<QgsDataItem*> children;
QgsWMSConnection connection( mName );
QgsWmsProvider *wmsProvider = connection.provider( );
if ( !wmsProvider )
return children;

QString mConnInfo = connection.connectionInfo();
QgsDebugMsg( "mConnInfo = " + mConnInfo );

// Attention: supportedLayers() gives tree leafes, not top level
if ( !wmsProvider->supportedLayers( mLayerProperties ) )
return children;

QgsWmsCapabilitiesProperty mCapabilitiesProperty = wmsProvider->capabilitiesProperty();
QgsWmsCapabilityProperty capabilityProperty = mCapabilitiesProperty.capability;

// Top level layer is present max once
// <element name="Capability">
// <element ref="wms:Layer" minOccurs="0"/> - default maxOccurs=1
QgsWmsLayerProperty topLayerProperty = capabilityProperty.layer;
foreach( QgsWmsLayerProperty layerProperty, topLayerProperty.layer )
{
// Attention, the name may be empty
QgsDebugMsg( QString::number( layerProperty.orderId ) + " " + layerProperty.name + " " + layerProperty.title );
QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name;

QgsWMSLayerItem * layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + "/" + pathName, mCapabilitiesProperty, mConnInfo, layerProperty );

children.append( layer );
}
return children;
}

bool QgsWMSConnectionItem::equal( const QgsDataItem *other )
{
if ( type() != other->type() )
{
return false;
}
const QgsWMSConnectionItem *o = dynamic_cast<const QgsWMSConnectionItem *>( other );
return ( mPath == o->mPath && mName == o->mName && mConnInfo == o->mConnInfo );
}
// ---------------------------------------------------------------------------
QgsWMSLayerItem::QgsWMSLayerItem( QgsDataItem* parent, QString name, QString path, QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperty )
: QgsLayerItem( parent, name, path, QString(), QgsLayerItem::Raster, "wms" ),
mCapabilitiesProperty( capabilitiesProperty ),
mConnInfo( connInfo ),
mLayerProperty( layerProperty )
//mProviderKey ("wms"),
//mLayerType ( QgsLayerItem::Raster )
{
mUri = createUri();
// Populate everything, it costs nothing, all info about layers is collected
foreach( QgsWmsLayerProperty layerProperty, mLayerProperty.layer )
{
// Attention, the name may be empty
QgsDebugMsg( QString::number( layerProperty.orderId ) + " " + layerProperty.name + " " + layerProperty.title );
QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name;
QgsWMSLayerItem * layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + "/" + pathName, mCapabilitiesProperty, mConnInfo, layerProperty );
mChildren.append( layer );
}

if ( mChildren.size() == 0 )
{
mIcon = QIcon( getThemePixmap( "mIconWmsLayer.png" ) );
}
mPopulated = true;
}

QgsWMSLayerItem::~QgsWMSLayerItem()
{
}

QString QgsWMSLayerItem::createUri()
{
QString uri;
if ( mLayerProperty.name.isEmpty() )
return uri; // layer collection

QString rasterLayerPath = mConnInfo;
QString baseName = mLayerProperty.name;

// Number of styles must match number of layers
QStringList layers;
layers << mLayerProperty.name;
QStringList styles;
if ( mLayerProperty.style.size() > 0 )
{
styles.append( mLayerProperty.style[0].name );
}
else
{
styles << ""; // TODO: use loadDefaultStyleFlag
}

QString format;
// get first supporte by qt and server
QVector<QgsWmsSupportedFormat> formats = QgsWmsProvider::supportedFormats();
foreach( QgsWmsSupportedFormat f, formats )
{
if ( mCapabilitiesProperty.capability.request.getMap.format.indexOf( f.format ) >= 0 )
{
format = f.format;
break;
}
}
QString crs;
// get first known if possible
QgsCoordinateReferenceSystem testCrs;
foreach( QString c, mLayerProperty.crs )
{
testCrs.createFromOgcWmsCrs( c );
if ( testCrs.isValid() )
{
crs = c;
break;
}
}
if ( crs.isEmpty() && mLayerProperty.crs.size() > 0 )
{
crs = mLayerProperty.crs[0];
}
uri = rasterLayerPath + "|layers=" + layers.join( "," ) + "|styles=" + styles.join( "," ) + "|format=" + format + "|crs=" + crs;

return uri;
}

// ---------------------------------------------------------------------------
QgsWMSRootItem::QgsWMSRootItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
mIcon = QIcon( getThemePixmap( "mIconWms.png" ) );

populate();
}

QgsWMSRootItem::~QgsWMSRootItem()
{
}

QVector<QgsDataItem*>QgsWMSRootItem::createChildren()
{
QVector<QgsDataItem*> connections;

foreach( QString connName, QgsWMSConnection::connectionList() )
{
QgsDataItem * conn = new QgsWMSConnectionItem( this, connName, mPath + "/" + connName );
connections.append( conn );
}
return connections;
}

QWidget * QgsWMSRootItem::paramWidget()
{
QgsWMSSourceSelect *select = new QgsWMSSourceSelect( 0, 0, true, true );
connect( select, SIGNAL( connectionsChanged() ), this, SLOT( connectionsChanged() ) );
return select;
}
void QgsWMSRootItem::connectionsChanged()
{
refresh();
}

// ---------------------------------------------------------------------------

QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
{
Q_UNUSED( thePath );

return new QgsWMSRootItem( parentItem, "WMS", "wms:" );
}

45 changes: 0 additions & 45 deletions src/providers/wms/qgswmsprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -968,51 +968,6 @@ class QgsWmsProvider : public QgsRasterDataProvider
QStringList mSupportedGetFeatureFormats;
};

class QgsWMSConnectionItem : public QgsDataCollectionItem
{
public:
QgsWMSConnectionItem( QgsDataItem* parent, QString name, QString path );
~QgsWMSConnectionItem();

QVector<QgsDataItem*> createChildren();
virtual bool equal( const QgsDataItem *other );

QgsWmsCapabilitiesProperty mCapabilitiesProperty;
QString mConnInfo;
QVector<QgsWmsLayerProperty> mLayerProperties;
};

// WMS Layers may be nested, so that they may be both QgsDataCollectionItem and QgsLayerItem
// We have to use QgsDataCollectionItem and support layer methods if necessary
class QgsWMSLayerItem : public QgsLayerItem
{
Q_OBJECT
public:
QgsWMSLayerItem( QgsDataItem* parent, QString name, QString path,
QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperties );
~QgsWMSLayerItem();

QString createUri();

QgsWmsCapabilitiesProperty mCapabilitiesProperty;
QString mConnInfo;
QgsWmsLayerProperty mLayerProperty;
};

class QgsWMSRootItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsWMSRootItem( QgsDataItem* parent, QString name, QString path );
~QgsWMSRootItem();

QVector<QgsDataItem*> createChildren();

virtual QWidget * paramWidget();

public slots:
void connectionsChanged();
};

#endif

Expand Down