void QgsArcGisRestCatalogProvider::parseFolderDo()
{
  QNetworkReply* reply = qobject_cast<QNetworkReply*>( QObject::sender() );
  reply->deleteLater();
  QString path = reply->property( "path" ).toString();
  QStringList catTitles = reply->property( "catTitles" ).toStringList();

  if ( reply->error() == QNetworkReply::NoError )
  {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    QJson::Parser parser;
    QVariantMap folderData = parser.parse( reply->readAll() ).toMap();
#else
    QVariantMap folderData = QJsonDocument::fromJson( reply->readAll() ).object().toVariantMap();
#endif
    QString catName = QFileInfo( path ).baseName();
    if ( !catName.isEmpty() )
    {
      catTitles.append( catName );
    }
    foreach ( const QVariant& folderName, folderData["folders"].toList() )
    {
      parseFolder( path + "/" + folderName.toString(), catTitles );
    }
    foreach ( const QVariant& serviceData, folderData["services"].toList() )
    {
      parseService( QString( "/" ) + serviceData.toMap()["name"].toString(), catTitles );
    }
  }
示例#2
0
/*!
 * Parses a \c Services element the Amazon endpoint XML data \a xml.
 *
 * This function parses an XML element containing a list of \c Service elements.
 * See AwsEndpointPrivate::parseServices for the \c Service element format.
 *
 * The parsed entries are automatically added to AwsEndpointPrivate::services.
 *
 * \sa parseService
 */
void AwsEndpointPrivate::parseServices(QXmlStreamReader &xml)
{
    while ((!xml.atEnd()) && (xml.readNextStartElement())) {
        if (xml.name() == QLatin1String("Service")) {
            parseService(xml);
        } else {
            qDebug() << "ignoring" << xml.name();
            xml.skipCurrentElement();
        }
    }
}