/*!
    Creates a QStyle object that matches \a key case-insensitively.
    This is either a built-in style, or a style from a style plugin.

    \sa keys()
*/
QStyle *QStyleFactory::create( const QString& key )
{
    QStyle *ret = 0;
    QString style = key.lower();
#ifndef QT_NO_STYLE_WINDOWS
    if ( style == "windows" )
        ret = new QWindowsStyle;
    else
#endif
#ifndef QT_NO_STYLE_WINDOWSXP
    if ( style == "windowsxp" )
	ret = new QWindowsXPStyle;
    else
#endif
#ifndef QT_NO_STYLE_MOTIF
    if ( style == "motif" )
        ret = new QMotifStyle;
    else
#endif
#ifndef QT_NO_STYLE_CDE
    if ( style == "cde" )
        ret = new QCDEStyle;
    else
#endif
#ifndef QT_NO_STYLE_MOTIFPLUS
    if ( style == "motifplus" )
        ret = new QMotifPlusStyle;
    else
#endif
#ifndef QT_NO_STYLE_PLATINUM
    if ( style == "platinum" )
        ret = new QPlatinumStyle;
    else
#endif
#ifndef QT_NO_STYLE_SGI
    if ( style == "sgi")
        ret = new QSGIStyle;
    else
#endif
#ifndef QT_NO_STYLE_COMPACT
    if ( style == "compact" )
        ret = new QCompactStyle;
    else
#endif
#ifndef QT_NO_STYLE_AQUA
    if ( style == "aqua" )
        ret = new QAquaStyle;
#endif
#ifndef QT_NO_STYLE_POCKETPC
    if ( style == "pocketpc" )
	ret = new QPocketPCStyle;
#endif
#if !defined( QT_NO_STYLE_MAC ) && defined( Q_WS_MAC )
    if( style.left(9) == "macintosh" )
	ret = new QMacStyle;
#endif
    { } // Keep these here - they make the #ifdefery above work

#ifndef QT_NO_COMPONENT
    if(!ret) {
	if ( !instance )
	    instance = new QStyleFactoryPrivate;

	QInterfacePtr<QStyleFactoryInterface> iface;
	QStyleFactoryPrivate::manager->queryInterface( style, &iface );

	if ( iface )
	    ret = iface->create( style );
    }
    if(ret)
	ret->setName(key);
#endif
    return ret;
}