コード例 #1
0
ファイル: property.cpp プロジェクト: cbevins/BehavePlus5
bool PropertyParser::startElement( const QString & /* namespaceUrl */,
    const QString & /* localName */, const QString& elementName,
    const QXmlAttributes& attribute )
{
    // If debugging, print each element and its attributes as encountered.
    m_indent += "    ";
    if ( m_debug )
    {
        std::cout << m_indent << "<" << elementName;
        for ( int id = 0;
              id < attribute.length();
              id++ )
        {
            std::cout << " " << attribute.localName(id) << "=\""
              << attribute.value(id) << "\"";
        }
        std::cout << " >" << std::endl;
    }
    // Skip all elements until <BehavePlus> is found.
    if ( ! m_elements )
    {
        if ( elementName == "BehavePlus" )
        {
            push( elementName );
            return( true );
        }
        trError( "PropertyParser:unknownDocument" );
        return( false );
    }
    // <property> elements
    if ( elementName == "property" )
    {
        push( elementName );
        if ( ! handleProperty( elementName, attribute ) )
        {
            return( false );
        }
    }
    // Ignore all other tags
    else
    {
        trError( "PropertyParser:unknownElement", elementName );
        return( false );
    }
    return( true );
}
コード例 #2
0
/*!
 \fn void ApplicationSettings::refresh()
 Refreshes all properties defined by the QML interface with those from QSettings
 */
void ApplicationSettings::refresh() {
    if(!isSettingsValid())
        return;

    const QMetaObject* myMetaObj = metaObject();
    for(int i = 0; i < myMetaObj->propertyCount();i++) {
        QMetaProperty property = myMetaObj->property(i);
        if(m_existingProperties->contains(property.name())) continue;

        handleProperty(QQmlProperty(this, property.name()));

        for(int i = 0; i < ApplicationSettings::s_allSettings.length(); ++i) {
            ApplicationSettings* appSettings = s_allSettings.at(i);

            if(appSettings != this && appSettings->applicationName() == m_applicationName && appSettings->fileName() == m_fileName) {
                appSettings->handleProperty(QQmlProperty(appSettings, property.name()));
            }
        }
    }
}