@ -119,8 +119,7 @@ static KJSObject fieldGetType(KJSContext *, void *object)
return KJSString ( fieldGetTypeHelper ( field ) ) ;
return KJSString ( fieldGetTypeHelper ( field ) ) ;
}
}
// Field.value (getter)
static KJSObject fieldGetValueCore ( KJSContext * context , bool asString , void * object )
static KJSObject fieldGetValue ( KJSContext * context , void * object )
{
{
FormField * field = reinterpret_cast < FormField * > ( object ) ;
FormField * field = reinterpret_cast < FormField * > ( object ) ;
KJSObject result = KJSUndefined ( ) ;
KJSObject result = KJSUndefined ( ) ;
@ -140,7 +139,7 @@ static KJSObject fieldGetValue(KJSContext *context, void *object)
const QLocale locale ;
const QLocale locale ;
bool ok ;
bool ok ;
const double textAsNumber = locale . toDouble ( text - > text ( ) , & ok ) ;
const double textAsNumber = locale . toDouble ( text - > text ( ) , & ok ) ;
if ( ok ) {
if ( ok & & ! asString ) {
result = KJSNumber ( textAsNumber ) ;
result = KJSNumber ( textAsNumber ) ;
} else {
} else {
result = KJSString ( text - > text ( ) ) ;
result = KJSString ( text - > text ( ) ) ;
@ -160,9 +159,15 @@ static KJSObject fieldGetValue(KJSContext *context, void *object)
}
}
}
}
qCDebug ( OkularCoreDebug ) < < " fieldGetValue: Field: " < < field - > fullyQualifiedName ( ) < < " Type: " < < fieldGetTypeHelper ( field ) < < " Value: " < < result . toString ( context ) < < ( result . isString ( ) ? " (as string) " : " " ) ;
qCDebug ( OkularCoreDebug ) < < " fieldGetValueCore: "
< < " Field: " < < field - > fullyQualifiedName ( ) < < " Type: " < < fieldGetTypeHelper ( field ) < < " Value: " < < result . toString ( context ) < < ( result . isString ( ) ? " (as string) " : " " ) ;
return result ;
return result ;
}
}
// Field.value (getter)
static KJSObject fieldGetValue ( KJSContext * context , void * object )
{
return fieldGetValueCore ( context , /*asString*/ false , object ) ;
}
// Field.value (setter)
// Field.value (setter)
static void fieldSetValue ( KJSContext * context , void * object , KJSObject value )
static void fieldSetValue ( KJSContext * context , void * object , KJSObject value )
@ -203,6 +208,12 @@ static void fieldSetValue(KJSContext *context, void *object, KJSObject value)
}
}
}
}
// Field.valueAsString (getter)
static KJSObject fieldGetValueAsString ( KJSContext * context , void * object )
{
return fieldGetValueCore ( context , /*asString*/ true , object ) ;
}
// Field.hidden (getter)
// Field.hidden (getter)
static KJSObject fieldGetHidden ( KJSContext * , void * object )
static KJSObject fieldGetHidden ( KJSContext * , void * object )
{
{
@ -305,6 +316,7 @@ void JSField::initType(KJSContext *ctx)
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " readonly " ) , fieldGetReadOnly , fieldSetReadOnly ) ;
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " readonly " ) , fieldGetReadOnly , fieldSetReadOnly ) ;
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " type " ) , fieldGetType ) ;
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " type " ) , fieldGetType ) ;
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " value " ) , fieldGetValue , fieldSetValue ) ;
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " value " ) , fieldGetValue , fieldSetValue ) ;
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " valueAsString " ) , fieldGetValueAsString ) ;
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " hidden " ) , fieldGetHidden , fieldSetHidden ) ;
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " hidden " ) , fieldGetHidden , fieldSetHidden ) ;
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " display " ) , fieldGetDisplay , fieldSetDisplay ) ;
g_fieldProto - > defineProperty ( ctx , QStringLiteral ( " display " ) , fieldGetDisplay , fieldSetDisplay ) ;