void QgsMapLayerStyleManager::readXml( const QDomElement &mgrElement )
{
  mCurrentStyle = mgrElement.attribute( QStringLiteral( "current" ) );
  if ( mCurrentStyle.isEmpty() )
  {
    // For old project made with QGIS 2, we migrate to "default".
    mCurrentStyle = defaultStyleName();
  }

  mStyles.clear();
  QDomElement ch = mgrElement.firstChildElement( QStringLiteral( "map-layer-style" ) );
  while ( !ch.isNull() )
  {
    QString name = ch.attribute( QStringLiteral( "name" ) );
    if ( name.isEmpty() )
    {
      // For old project made with QGIS 2, we migrate to "default".
      name = defaultStyleName();
    }
    QgsMapLayerStyle style;
    style.readXml( ch );
    mStyles.insert( name, style );

    ch = ch.nextSiblingElement( QStringLiteral( "map-layer-style" ) );
  }
}
static QString styleImportName()
{
    QString name = qgetenv("QT_QUICK_CONTROLS_STYLE");
    if (name.isEmpty())
        name = defaultStyleName();
    return QFileInfo(name).fileName();
}
QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine)
{
    // First, register all style paths in the default style location.
    QDir dir;
    const QString defaultStyle = defaultStyleName();
    dir.setPath(relativeStyleImportPath(engine, defaultStyle));
    dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
    foreach (const QString &styleDirectory, dir.entryList()) {
        findStyle(engine, styleDirectory);
    }

    m_name = styleImportName();

    // If the style name is a path..
    const QString styleNameFromEnvVar = qgetenv("QT_QUICK_CONTROLS_STYLE");
    if (QFile::exists(styleNameFromEnvVar)) {
        StyleData styleData;
        styleData.m_styleDirPath = styleNameFromEnvVar;
        m_styleMap[m_name] = styleData;
    }

    // Then check if the style the user wanted is known to us. Otherwise, use the fallback style.
    if (m_styleMap.contains(m_name)) {
        m_path = m_styleMap.value(m_name).m_styleDirPath;
    } else {
        QString unknownStyle = m_name;
        m_name = defaultStyle;
        m_path = m_styleMap.value(defaultStyle).m_styleDirPath;
        qWarning() << "WARNING: Cannot find style" << unknownStyle << "- fallback:" << styleFilePath();
    }

    // Can't really do anything about this failing here, so don't bother checking...
    resolveCurrentStylePath();

    connect(this, SIGNAL(styleNameChanged()), SIGNAL(styleChanged()));
    connect(this, SIGNAL(stylePathChanged()), SIGNAL(styleChanged()));
}
void QgsMapLayerStyleManager::reset()
{
  mStyles.insert( defaultStyleName(), QgsMapLayerStyle() ); // insert entry for the default current style
  mCurrentStyle = defaultStyleName();
}