[QGIS Commit] r9899 - in trunk/qgis/src: app providers/wms

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Dec 26 19:37:24 EST 2008


Author: jef
Date: 2008-12-26 19:37:24 -0500 (Fri, 26 Dec 2008)
New Revision: 9899

Modified:
   trunk/qgis/src/app/qgsserversourceselect.cpp
   trunk/qgis/src/app/qgsserversourceselect.h
   trunk/qgis/src/providers/wms/qgswmsprovider.cpp
   trunk/qgis/src/providers/wms/qgswmsprovider.h
Log:
wms update:
- show nested layers in a tree
- enable sorting in the wms dialog (fixes #1387)
- use Qt instead of STL templates



Modified: trunk/qgis/src/app/qgsserversourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgsserversourceselect.cpp	2008-12-26 21:09:50 UTC (rev 9898)
+++ trunk/qgis/src/app/qgsserversourceselect.cpp	2008-12-27 00:37:24 UTC (rev 9899)
@@ -186,55 +186,87 @@
 
 }
 
-bool QgsServerSourceSelect::populateLayerList( QgsWmsProvider* wmsProvider )
+QgsNumericSortTreeWidgetItem *QgsServerSourceSelect::createItem(
+	int id, const QStringList &names, QMap<int, QgsNumericSortTreeWidgetItem *> &items, int &layerAndStyleCount,
+	const QMap<int,int> &layerParents, const QMap<int, QStringList> &layerParentNames )
+
 {
-  std::vector<QgsWmsLayerProperty> layers;
+  if( items.contains(id) )
+    return items[id];
 
+  QgsNumericSortTreeWidgetItem *item;
+  if( layerParents.contains( id ) )
+  {
+    int parent = layerParents[ id ];
+    item = new QgsNumericSortTreeWidgetItem( createItem( parent, layerParentNames[ parent ], items, layerAndStyleCount, layerParents, layerParentNames ) );
+  }
+  else
+    item = new QgsNumericSortTreeWidgetItem( lstLayers );
+
+  item->setText( 0, QString::number( ++layerAndStyleCount ) );
+  item->setText( 1, names[0].simplified() );
+  item->setText( 2, names[1].simplified() );
+  item->setText( 3, names[2].simplified() );
+
+  items[ id ] = item;
+
+  return item;
+}
+
+bool QgsServerSourceSelect::populateLayerList( QgsWmsProvider *wmsProvider )
+{
+  QVector<QgsWmsLayerProperty> layers;
+
   if ( !wmsProvider->supportedLayers( layers ) )
   {
     return FALSE;
   }
 
+  QMap<int, QgsNumericSortTreeWidgetItem *> items;
+  QMap<int, int> layerParents;
+  QMap<int, QStringList> layerParentNames;
+  wmsProvider->layerParents( layerParents, layerParentNames );
+
   lstLayers->clear();
+  lstLayers->setSortingEnabled( true );
 
-  int layerAndStyleCount = 0;
+  int layerAndStyleCount = -1;
 
-  for ( std::vector<QgsWmsLayerProperty>::iterator layer  = layers.begin();
+  for ( QVector<QgsWmsLayerProperty>::iterator layer = layers.begin();
         layer != layers.end();
         layer++ )
   {
-    // QgsDebugMsg(QString("got layer name %1 and title '%2'.").arg(layer->name).arg(layer->title));
+    QgsNumericSortTreeWidgetItem *lItem = createItem(layer->orderId, QStringList() << layer->name << layer->title << layer->abstract, items, layerAndStyleCount, layerParents, layerParentNames );
 
-    layerAndStyleCount++;
+    lItem->setData( 0, Qt::UserRole, layer->name );
+    lItem->setData( 0, Qt::UserRole+1, "" );
 
-    QgsNumericSortTreeWidgetItem *lItem = new QgsNumericSortTreeWidgetItem( lstLayers );
-    lItem->setText( 0, QString::number( layerAndStyleCount ) );
-    lItem->setText( 1, layer->name.simplified() );
-    lItem->setText( 2, layer->title.simplified() );
-    lItem->setText( 3, layer->abstract.simplified() );
-
     // Also insert the styles
     // Layer Styles
-    for ( uint j = 0; j < layer->style.size(); j++ )
+    for ( int j = 0; j < layer->style.size(); j++ )
     {
       QgsDebugMsg( QString( "got style name %1 and title '%2'." ).arg( layer->style[j].name ).arg( layer->style[j].title ) );
 
-      layerAndStyleCount++;
-
       QgsNumericSortTreeWidgetItem *lItem2 = new QgsNumericSortTreeWidgetItem( lItem );
-      lItem2->setText( 0, QString::number( layerAndStyleCount ) );
+      lItem2->setText( 0, QString::number( ++layerAndStyleCount ) );
       lItem2->setText( 1, layer->style[j].name.simplified() );
       lItem2->setText( 2, layer->style[j].title.simplified() );
       lItem2->setText( 3, layer->style[j].abstract.simplified() );
 
+      lItem2->setData( 0, Qt::UserRole, layer->name );
+      lItem2->setData( 0, Qt::UserRole+1, layer->style[j].name );
     }
-
   }
 
   // If we got some layers, let the user add them to the map
   if ( lstLayers->topLevelItemCount() > 0 )
   {
     btnAdd->setEnabled( TRUE );
+
+    if( lstLayers->topLevelItemCount()==1 )
+    {
+      lstLayers->expandItem( lstLayers->topLevelItem(0) );
+    }
   }
   else
   {
@@ -361,7 +393,7 @@
 {
   if ( m_selectedLayers.empty() == TRUE )
   {
-    QMessageBox::information( this, tr( "Select Layer" ), tr( "You must select at least one layer first." ) );
+    QMessageBox::information( this, tr( "Select Layer" ), tr( "You must select at least one leaf layer first." ) );
   }
   else if ( mWmsProvider->supportedCrsForLayers( m_selectedLayers ).size() == 0 )
   {
@@ -426,7 +458,7 @@
   QStringList newSelectedLayers;
   QStringList newSelectedStylesForSelectedLayers;
 
-  std::map<QString, QString> newSelectedStyleIdForLayer;
+  QMap<QString, QString> newSelectedStyleIdForLayer;
 
   // Iterate through the layers
   QList<QTreeWidgetItem *> selected( lstLayers->selectedItems() );
@@ -434,20 +466,14 @@
   for ( it = selected.begin(); it != selected.end(); ++it )
   {
     QTreeWidgetItem *item = *it;
-    QString layerName;
 
-    if ( item->parent() != 0 )
-    {
-      layerName = item->parent()->text( 1 );
-      newSelectedStylesForSelectedLayers += item->text( 1 );
-    }
-    else
-    {
-      layerName = item->text( 1 );
-      newSelectedStylesForSelectedLayers += "";
-    }
+    QString layerName = item->data(0, Qt::UserRole).toString();
+    if( layerName.isEmpty() )
+      continue;
 
-    newSelectedLayers += layerName;
+    newSelectedLayers << layerName;
+    newSelectedStylesForSelectedLayers << item->data( 0, Qt::UserRole+1 ).toString();
+
     newSelectedStyleIdForLayer[layerName] = item->text( 0 );
 
     // Check if multiple styles have now been selected

Modified: trunk/qgis/src/app/qgsserversourceselect.h
===================================================================
--- trunk/qgis/src/app/qgsserversourceselect.h	2008-12-26 21:09:50 UTC (rev 9898)
+++ trunk/qgis/src/app/qgsserversourceselect.h	2008-12-27 00:37:24 UTC (rev 9899)
@@ -21,13 +21,13 @@
 #include "ui_qgsserversourceselectbase.h"
 #include "qgisgui.h"
 
-#include <vector>
-#include <map>
-#include <set>
+#include <QStringList>
 
 class QgisApp;
 class QgsWmsProvider;
 class QButtonGroup;
+class QgsNumericSortTreeWidgetItem;
+
 /*!
  * \brief   Dialog to create connections and add layers from WMS, etc.
  *
@@ -140,6 +140,9 @@
     //! Populate the image encoding button group - private for now.
     void populateImageEncodingGroup( QgsWmsProvider* wmsProvider );
 
+    //! create an item including possible parents
+    QgsNumericSortTreeWidgetItem *createItem(int id, const QStringList &names, QMap<int, QgsNumericSortTreeWidgetItem *> &items, int &layerAndStyleCount, const QMap<int,int> &layerParents, const QMap<int, QStringList> &layerParentNames );
+
     //! Returns a textual description for the EpsgCrsId number
     QString descriptionForEpsg( long epsg );
 
@@ -165,7 +168,7 @@
     QStringList m_selectedStylesForSelectedLayers;
     long m_Epsg;
 
-    std::map<QString, QString> m_selectedStyleIdForLayer;
+    QMap<QString, QString> m_selectedStyleIdForLayer;
 
     //! The mime type, the text to use in the button and a unique number
     QMap<QString, QPair<QString, int> > m_PotentialFormats;

Modified: trunk/qgis/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.cpp	2008-12-26 21:09:50 UTC (rev 9898)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.cpp	2008-12-27 00:37:24 UTC (rev 9899)
@@ -59,7 +59,8 @@
     cachedPixelHeight( 0 ),
     mCoordinateTransform( 0 ),
     extentDirty( TRUE ),
-    mGetFeatureInfoUrlBase( 0 )
+    mGetFeatureInfoUrlBase( 0 ),
+    mLayerCount( -1 )
 {
   QgsDebugMsg( "QgsWmsProvider: constructing with uri '" + uri + "'." );
 
@@ -134,7 +135,7 @@
 
 
 
-bool QgsWmsProvider::supportedLayers( std::vector<QgsWmsLayerProperty> & layers )
+bool QgsWmsProvider::supportedLayers( QVector<QgsWmsLayerProperty> &layers )
 {
   QgsDebugMsg( "Entering." );
 
@@ -159,11 +160,11 @@
   QStringList::const_iterator i;
   for ( i = layers.constBegin(); i != layers.constEnd(); ++i )
   {
-    std::vector<QString> crsVector = crsForLayer[*i];
+    QVector<QString> crsVector = crsForLayer[*i];
     QSet<QString>    crsSet;
 
     // convert std::vector to std::set for set comparisons
-    for ( uint j = 0; j < crsVector.size(); j++ )
+    for ( int j = 0; j < crsVector.size(); j++ )
     {
       crsSet.insert( crsVector[j] );
     }
@@ -192,8 +193,8 @@
 } // QgsWmsProvider::layerCount()
 
 
-void QgsWmsProvider::addLayers( QStringList const &  layers,
-                                QStringList const &  styles )
+void QgsWmsProvider::addLayers( QStringList const &layers,
+                                QStringList const &styles )
 {
   QgsDebugMsg( "Entering with layer list of " + layers.join( ", " )
                + " and style list of " + styles.join( ", " ) );
@@ -220,7 +221,7 @@
 }
 
 
-void QgsWmsProvider::setLayerOrder( QStringList const &  layers )
+void QgsWmsProvider::setLayerOrder( QStringList const &layers )
 {
   QgsDebugMsg( "Entering." );
 
@@ -272,7 +273,6 @@
 
 }
 
-
 QImage* QgsWmsProvider::draw( QgsRectangle  const & viewExtent, int pixelWidth, int pixelHeight )
 {
   QgsDebugMsg( "Entering." );
@@ -335,18 +335,16 @@
   // Width in WMS format
   QString width;
   width = width.setNum( pixelWidth );
-
+  
   // Height in WMS format
   QString height;
   height = height.setNum( pixelHeight );
 
-
   // Calculate active layers that are also visible.
 
   QgsDebugMsg( "Active layer list of "  + activeSubLayers.join( ", " )
                + " and style list of "  + activeSubStyles.join( ", " ) );
 
-
   QStringList visibleLayers = QStringList();
   QStringList visibleStyles = QStringList();
 
@@ -356,7 +354,7 @@
         it != activeSubLayers.end();
         ++it )
   {
-    if ( TRUE == activeSubLayerVisibility.find( *it )->second )
+    if ( activeSubLayerVisibility.find( *it ).value() )
     {
       visibleLayers += *it;
       visibleStyles += *it2;
@@ -380,7 +378,7 @@
   }
 
   QString url;
-  std::vector<QgsWmsDcpTypeProperty> dcpType = mCapabilities.capability.request.getMap.dcpType;
+  QVector<QgsWmsDcpTypeProperty> dcpType = mCapabilities.capability.request.getMap.dcpType;
   if ( dcpType.size() < 1 )
   {
     url = baseUrl;
@@ -409,14 +407,25 @@
   url += "STYLES=" + styles;
   url += "&";
   url += "FORMAT=" + imageMimeType;
-  if ( !imageMimeType.contains( "jpeg", Qt::CaseInsensitive ) && !imageMimeType.contains( "jpg", Qt::CaseInsensitive ) ) //MH: jpeg does not support transparency and some servers complain if jpg and transparent=true
+
+  //MH: jpeg does not support transparency and some servers complain if jpg and transparent=true
+  if ( !imageMimeType.contains( "jpeg", Qt::CaseInsensitive ) && !imageMimeType.contains( "jpg", Qt::CaseInsensitive ) )
   {
     url += "&";
     url += "TRANSPARENT=TRUE";
   }
 
+  dcpType = mCapabilities.capability.request.getFeatureInfo.dcpType;
+  if ( dcpType.size() < 1 )
+  {
+    mGetFeatureInfoUrlBase = baseUrl;
+  }
+  else
+  {
+    mGetFeatureInfoUrlBase = prepareUri( dcpType.front().http.get.onlineResource.xlinkHref );
+  }
+
   // cache some details for if the user wants to do an identifyAsHtml() later
-  mGetFeatureInfoUrlBase = baseUrl;
   mGetFeatureInfoUrlBase += "SERVICE=WMS";
   mGetFeatureInfoUrlBase += "&";
   mGetFeatureInfoUrlBase += "VERSION=" + mCapabilities.version;
@@ -436,13 +445,13 @@
   mGetFeatureInfoUrlBase += "STYLES=" + styles;
   mGetFeatureInfoUrlBase += "&";
   mGetFeatureInfoUrlBase += "FORMAT=" + imageMimeType;
+
   if ( !imageMimeType.contains( "jpeg", Qt::CaseInsensitive ) && !imageMimeType.contains( "jpg", Qt::CaseInsensitive ) )
   {
     mGetFeatureInfoUrlBase += "&";
     mGetFeatureInfoUrlBase += "TRANSPARENT=TRUE";
   }
 
-
   QByteArray imagesource;
   imagesource = retrieveUrl( url );
 
@@ -904,7 +913,7 @@
     QDomElement e1 = n1.toElement(); // try to convert the node to an element.
     if ( !e1.isNull() )
     {
-      //QgsDebugMsg("  "  + e1.tagName() ); // the node really is an element.
+      QgsDebugMsg("  "  + e1.tagName() ); // the node really is an element.
 
       if ( e1.tagName() == "Request" )
       {
@@ -1303,10 +1312,7 @@
 //  layerProperty.title =       QString::null;
 //  layerProperty.abstract =    QString::null;
 //  layerProperty.keywordList.clear();
-
-  // assume true until we find a child layer
-  bool atleaf = TRUE;
-
+  layerProperty.orderId     = ++mLayerCount;
   layerProperty.queryable   = e.attribute( "queryable" ).toUInt();
   layerProperty.cascaded    = e.attribute( "cascaded" ).toUInt();
   layerProperty.opaque      = e.attribute( "opaque" ).toUInt();
@@ -1320,11 +1326,11 @@
     QDomElement e1 = n1.toElement(); // try to convert the node to an element.
     if ( !e1.isNull() )
     {
-      // QgsDebugMsg( "    "  + e1.tagName() ); // the node really is an element.
+      QgsDebugMsg( "    "  + e1.tagName() ); // the node really is an element.
 
       if ( e1.tagName() == "Layer" )
       {
-        // QgsDebugMsg( "      Nested layer." );
+        QgsDebugMsg( "      Nested layer." );
 
         QgsWmsLayerProperty subLayerProperty;
 
@@ -1339,8 +1345,6 @@
         parseLayer( e1, subLayerProperty, &layerProperty );
 
         layerProperty.layer.push_back( subLayerProperty );
-
-        atleaf = FALSE;
       }
       else if ( e1.tagName() == "Name" )
       {
@@ -1469,8 +1473,13 @@
     n1 = n1.nextSibling();
   }
 
-  if ( atleaf )
+  if(parentProperty)
   {
+    mLayerParents[ layerProperty.orderId ] = parentProperty->orderId;
+  }
+
+  if ( layerProperty.layer.empty() )
+  {
     // We have all the information we need to properly evaluate a layer definition
     // TODO: Save this somewhere
 
@@ -1488,7 +1497,7 @@
     extentForLayer[ layerProperty.name ] = layerProperty.ex_GeographicBoundingBox;
 
     // see if we can refine the bounding box with the CRS-specific bounding boxes
-    for ( uint i = 0; i < layerProperty.boundingBox.size(); i++ )
+    for ( int i = 0; i < layerProperty.boundingBox.size(); i++ )
     {
       QgsDebugMsg( "testing bounding box CRS which is "
                    + layerProperty.boundingBox[i].crs + "." );
@@ -1508,15 +1517,24 @@
     layersSupported.push_back( layerProperty );
 
     //if there are several <Layer> elements without a parent layer, the style list needs to be cleared
-    if ( atleaf )
+    if ( layerProperty.layer.empty() )
     {
       layerProperty.style.clear();
     }
   }
+  else
+  {
+    mLayerParentNames[ layerProperty.orderId ] = QStringList() << layerProperty.name << layerProperty.title << layerProperty.abstract;
+  }
 
 //  QgsDebugMsg("exiting.");
 }
 
+void QgsWmsProvider::layerParents( QMap<int, int> &parents, QMap<int, QStringList> &parentNames ) const
+{
+  parents = mLayerParents;
+  parentNames = mLayerParentNames;
+}
 
 bool QgsWmsProvider::parseServiceExceptionReportDom( QByteArray const & xml )
 {
@@ -1744,7 +1762,7 @@
   {
     QgsDebugMsg( "Sublayer Iterator: " + *it );
     // This is the extent for the layer name in *it
-    QgsRectangle extent = extentForLayer.find( *it )->second;
+    QgsRectangle extent = extentForLayer.find( *it ).value();
 
     // Convert to the user's CRS as required
     try
@@ -1800,10 +1818,10 @@
         ++it )
   {
     // Is sublayer visible?
-    if ( TRUE == activeSubLayerVisibility.find( *it )->second )
+    if ( activeSubLayerVisibility.find( *it ).value() )
     {
       // Is sublayer queryable?
-      if ( TRUE == mQueryableForLayer.find( *it )->second )
+      if ( mQueryableForLayer.find( *it ).value() )
       {
         QgsDebugMsg( "'"  + ( *it )  + "' is queryable." );
         canIdentify = TRUE;
@@ -1843,7 +1861,7 @@
   myMetadataQString += "</th>";
   myMetadataQString += "<th bgcolor=\"black\">";
   myMetadataQString += "<font color=\"white\">" + tr( "Value" ) + "</font>";
-  myMetadataQString += "</th><tr>";
+  myMetadataQString += "</th></tr>";
 
   // WMS Version
   myMetadataQString += "<tr><td bgcolor=\"gray\">";
@@ -1937,21 +1955,33 @@
   myMetadataQString += QString::number( layersSupported.size() );
   myMetadataQString += "</td></tr>";
 
+  // Base URL
+  myMetadataQString += "<tr><td bgcolor=\"gray\">";
+  myMetadataQString += tr( "GetFeatureInfoUrl" );
+  myMetadataQString += "</td>";
+  myMetadataQString += "<td bgcolor=\"gray\">";
+  myMetadataQString += mGetFeatureInfoUrlBase;
+  myMetadataQString += "</td></tr>";
+
   // Close the nested table
   myMetadataQString += "</table>";
   myMetadataQString += "</td></tr>";
 
+  // Layer properties
+  myMetadataQString += "<tr><td bgcolor=\"gray\">";
+  myMetadataQString += tr( "Layer Properties:" );
+  myMetadataQString += "</td></tr>";
+
   // Iterate through layers
 
-  for ( uint i = 0; i < layersSupported.size(); i++ )
+  for ( int i = 0; i < layersSupported.size(); i++ )
   {
 
     // TODO: Handle nested layers
     QString layerName = layersSupported[i].name;   // for aesthetic convenience
 
     // Layer Properties section
-    myMetadataQString += "<tr><td bgcolor=\"gray\">";
-    myMetadataQString += tr( "Layer Properties: " );
+    myMetadataQString += "<tr><td bgcolor=\"white\">";
     myMetadataQString += layerName;
     myMetadataQString += "</td></tr>";
 
@@ -1965,7 +1995,7 @@
     myMetadataQString += "</th>";
     myMetadataQString += "<th bgcolor=\"black\">";
     myMetadataQString += "<font color=\"white\">" + tr( "Value" ) + "</font>";
-    myMetadataQString += "</th><tr>";
+    myMetadataQString += "</th></tr>";
 
     // Layer Selectivity (as managed by this provider)
     myMetadataQString += "<tr><td bgcolor=\"gray\">";
@@ -1983,7 +2013,7 @@
     myMetadataQString += "<td bgcolor=\"gray\">";
     myMetadataQString += ( activeSubLayers.indexOf( layerName ) >= 0 ) ?
                          (
-                           ( activeSubLayerVisibility.find( layerName )->second ) ?
+                           ( activeSubLayerVisibility.find( layerName ).value() ) ?
                            tr( "Visible" ) : tr( "Hidden" )
                          ) :
                              tr( "n/a" );
@@ -2062,8 +2092,8 @@
     myMetadataQString += "</td></tr>";
 
     // Layer Coordinate Reference Systems
-    for ( uint j = 0; j < layersSupported[i].crs.size(); j++ )
-{
+    for ( int j = 0; j < layersSupported[i].crs.size(); j++ )
+    {
       myMetadataQString += "<tr><td bgcolor=\"gray\">";
       myMetadataQString += tr( "Available in CRS" );
       myMetadataQString += "</td>";
@@ -2073,7 +2103,7 @@
     }
 
     // Layer Styles
-    for ( uint j = 0; j < layersSupported[i].style.size(); j++ )
+    for ( int j = 0; j < layersSupported[i].style.size(); j++ )
     {
       myMetadataQString += "<tr><td bgcolor=\"gray\">";
       myMetadataQString += tr( "Available in style" );
@@ -2140,10 +2170,10 @@
         ++it )
   {
     // Is sublayer visible?
-    if ( TRUE == activeSubLayerVisibility.find( *it )->second )
+    if ( activeSubLayerVisibility.find( *it ).value() )
     {
       // Is sublayer queryable?
-      if ( TRUE == mQueryableForLayer.find( *it )->second )
+      if ( mQueryableForLayer.find( *it ).value() )
       {
         QgsDebugMsg( "Layer '" + *it + "' is queryable." );
         // Compose request to WMS server

Modified: trunk/qgis/src/providers/wms/qgswmsprovider.h
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.h	2008-12-26 21:09:50 UTC (rev 9898)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.h	2008-12-27 00:37:24 UTC (rev 9899)
@@ -21,15 +21,14 @@
 #ifndef QGSWMSPROVIDER_H
 #define QGSWMSPROVIDER_H
 
-#include <map>
-#include <vector>
-
 #include "qgsrasterdataprovider.h"
 #include "qgsrectangle.h"
 
 #include <QString>
 #include <QStringList>
 #include <QDomElement>
+#include <QMap>
+#include <QVector>
 
 class QgsCoordinateTransform;
 
@@ -78,8 +77,8 @@
 // TODO: Fill to WMS specifications
 struct QgsWmsOperationType
 {
-  QStringList                          format;
-  std::vector<QgsWmsDcpTypeProperty>   dcpType;
+  QStringList                      format;
+  QVector<QgsWmsDcpTypeProperty>   dcpType;
 };
 
 /** Request Property structure */
@@ -220,12 +219,12 @@
 // TODO: Fill to WMS specifications
 struct QgsWmsStyleProperty
 {
-  QString                               name;
-  QString                               title;
-  QString                               abstract;
-  std::vector<QgsWmsLegendUrlProperty>  legendUrl;
-  QgsWmsStyleSheetUrlProperty           styleSheetUrl;
-  QgsWmsStyleUrlProperty                styleUrl;
+  QString                           name;
+  QString                           title;
+  QString                           abstract;
+  QVector<QgsWmsLegendUrlProperty>  legendUrl;
+  QgsWmsStyleSheetUrlProperty       styleSheetUrl;
+  QgsWmsStyleUrlProperty            styleUrl;
 };
 
 /** Authority URL Property structure */
@@ -273,24 +272,25 @@
 struct QgsWmsLayerProperty
 {
   // WMS layer properties
-  QString                                     name;
-  QString                                     title;
-  QString                                     abstract;
-  QStringList                                 keywordList;
-  std::vector<QString>                        crs;        // coord ref sys
-  QgsRectangle                                     ex_GeographicBoundingBox;
-  std::vector<QgsWmsBoundingBoxProperty>      boundingBox;
-  std::vector<QgsWmsDimensionProperty>        dimension;
-  QgsWmsAttributionProperty                   attribution;
-  std::vector<QgsWmsAuthorityUrlProperty>     authorityUrl;
-  std::vector<QgsWmsIdentifierProperty>       identifier;
-  std::vector<QgsWmsMetadataUrlProperty>      metadataUrl;
-  std::vector<QgsWmsDataListUrlProperty>      dataListUrl;
-  std::vector<QgsWmsFeatureListUrlProperty>   featureListUrl;
-  std::vector<QgsWmsStyleProperty>            style;
-  double                                      minimumScaleDenominator;
-  double                                      maximumScaleDenominator;
-  std::vector<QgsWmsLayerProperty>            layer;      // nested layers
+  int					  orderId;
+  QString                                 name;
+  QString                                 title;
+  QString                                 abstract;
+  QStringList                             keywordList;
+  QVector<QString>                        crs;        // coord ref sys
+  QgsRectangle                            ex_GeographicBoundingBox;
+  QVector<QgsWmsBoundingBoxProperty>      boundingBox;
+  QVector<QgsWmsDimensionProperty>        dimension;
+  QgsWmsAttributionProperty               attribution;
+  QVector<QgsWmsAuthorityUrlProperty>     authorityUrl;
+  QVector<QgsWmsIdentifierProperty>       identifier;
+  QVector<QgsWmsMetadataUrlProperty>      metadataUrl;
+  QVector<QgsWmsDataListUrlProperty>      dataListUrl;
+  QVector<QgsWmsFeatureListUrlProperty>   featureListUrl;
+  QVector<QgsWmsStyleProperty>            style;
+  double                                  minimumScaleDenominator;
+  double                                  maximumScaleDenominator;
+  QVector<QgsWmsLayerProperty>            layer;      // nested layers
 
   // WMS layer attributes
   bool               queryable;
@@ -331,12 +331,9 @@
 */
 class QgsWmsProvider : public QgsRasterDataProvider
 {
-
     Q_OBJECT
 
   public:
-
-
     /**
     * Constructor for the provider.
     *
@@ -359,8 +356,13 @@
      *
      * \todo Document this better, make static
      */
-    virtual bool supportedLayers( std::vector<QgsWmsLayerProperty> & layers );
+    virtual bool supportedLayers( QVector<QgsWmsLayerProperty> & layers );
 
+    /**
+     * \brief   Returns a map for the hierachy of layers 
+     */
+    virtual void layerParents( QMap<int, int> &parents, QMap<int, QStringList> &parentNames ) const;
+
     // TODO: Document this better
     /** \brief   Returns a list of the supported CRSs of the given layers
      *  \note    Since WMS can specify CRSs per layer, this may change depending
@@ -735,23 +737,23 @@
     /**
      * layers hosted by the WMS Server
      */
-    std::vector<QgsWmsLayerProperty> layersSupported;
+    QVector<QgsWmsLayerProperty> layersSupported;
 
     /**
      * extents per layer (in WMS CRS:84 datum)
      */
-    std::map<QString, QgsRectangle> extentForLayer;
+    QMap<QString, QgsRectangle> extentForLayer;
 
     /**
      * available CRSs per layer
      */
-    std::map<QString, std::vector<QString> > crsForLayer;
+    QMap<QString, QVector<QString> > crsForLayer;
 
     /**
      * WMS "queryable" per layer
      * Used in determining if the Identify map tool can be useful on the rendered WMS map layer.
      */
-    std::map<QString, bool> mQueryableForLayer;
+    QMap<QString, bool> mQueryableForLayer;
 
     /**
      * Active sublayers managed by this provider in a draw function, in order from bottom to top
@@ -764,7 +766,7 @@
     /**
      * Visibility status of the given active sublayer
      */
-    std::map<QString, bool> activeSubLayerVisibility;
+    QMap<QString, bool> activeSubLayerVisibility;
 
     /**
      * MIME type of the image encoding used from the WMS server
@@ -816,6 +818,11 @@
 
     //! Base URL for WMS GetFeatureInfo requests
     QString mGetFeatureInfoUrlBase;
+
+    int mLayerCount;
+    QMap<int, int> mLayerParents;
+    QMap<int, QStringList> mLayerParentNames;
+
 };
 
 #endif



More information about the QGIS-commit mailing list