示例#1
0
文件: kjs_field.cpp 项目: KDE/okular
// Field.value (setter)
static void fieldSetValue( KJSContext *context, void *object, KJSObject value )
{
    FormField *field = reinterpret_cast< FormField * >( object );

    if ( field->isReadOnly() )
    {
        // ### throw exception?
        qCDebug(OkularCoreDebug) << "Trying to change the readonly field" << field->name() << "to" << value.toString( context );
        g_fieldCache->insert( field, value );
        return;
    }

    switch ( field->type() )
    {
        case FormField::FormButton:
        {
            FormFieldButton *button = static_cast< FormFieldButton * >( field );
            Q_UNUSED( button ); // ###
            break;
        }
        case FormField::FormText:
        {
            FormFieldText *text = static_cast< FormFieldText * >( field );
            text->setText( value.toString( context ) );
            break;
        }
        case FormField::FormChoice:
        {
            FormFieldChoice *choice = static_cast< FormFieldChoice * >( field );
            Q_UNUSED( choice ); // ###
            break;
        }
        case FormField::FormSignature:
        {
            break;
        }
    }
}