mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-02 14:14:10 +00:00
Fixed indentation, bad algebra and moved display enum to KJSDisplay
This commit is contained in:
parent
da01333817
commit
60ff2f414e
|
@ -194,7 +194,7 @@ class DocumentPrivate
|
|||
/**
|
||||
* Executes a JavaScript script from the setInterval function.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.9
|
||||
*/
|
||||
void executeScript( const QString &function );
|
||||
|
||||
|
|
17
core/form.h
17
core/form.h
|
@ -57,17 +57,6 @@ class OKULARCORE_EXPORT FormField
|
|||
FormSignature ///< A signature.
|
||||
};
|
||||
|
||||
/**
|
||||
* The display types of the field.
|
||||
*/
|
||||
enum FieldDisplay
|
||||
{
|
||||
FormVisible,
|
||||
FormHidden,
|
||||
FormNoPrint,
|
||||
FormNoView
|
||||
};
|
||||
|
||||
virtual ~FormField();
|
||||
|
||||
/**
|
||||
|
@ -124,14 +113,14 @@ class OKULARCORE_EXPORT FormField
|
|||
/**
|
||||
Whether this field is printable.
|
||||
|
||||
@since 1.7
|
||||
@since 1.9
|
||||
*/
|
||||
virtual bool isPrintable() const;
|
||||
|
||||
/**
|
||||
Set this field printable
|
||||
|
||||
@since 1.7
|
||||
@since 1.9
|
||||
*/
|
||||
virtual void setPrintable( bool value );
|
||||
|
||||
|
@ -235,7 +224,7 @@ class OKULARCORE_EXPORT FormFieldButton : public FormField
|
|||
/**
|
||||
* Sets the icon of the Button to the Icon of the field parameter.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.9
|
||||
*/
|
||||
virtual void setIcon( Okular::FormField *field );
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <qapplication.h>
|
||||
|
||||
#include <QLocale>
|
||||
#include <QTimer>
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
|
@ -26,6 +27,8 @@
|
|||
|
||||
using namespace Okular;
|
||||
|
||||
#define OKULAR_TIMERID QStringLiteral( "okular_timerID" )
|
||||
|
||||
static KJSPrototype *g_appProto;
|
||||
typedef QHash< int, QTimer * > TimerCache;
|
||||
Q_GLOBAL_STATIC( TimerCache, g_timerCache )
|
||||
|
@ -212,7 +215,7 @@ static KJSObject appSetInterval( KJSContext *ctx, void *object,
|
|||
|
||||
QTimer *timer = new QTimer();
|
||||
|
||||
QObject::connect( timer, &QTimer::timeout, [=](){ doc->executeScript( function ); } );
|
||||
QObject::connect( timer, &QTimer::timeout, doc->m_parent, [=](){ doc->executeScript( function ); } );
|
||||
|
||||
timer->start( interval );
|
||||
|
||||
|
@ -224,7 +227,7 @@ static KJSObject appClearInterval( KJSContext *ctx, void *,
|
|||
const KJSArguments &arguments )
|
||||
{
|
||||
KJSObject timerObject = arguments.at( 0 );
|
||||
const int timerId = timerObject.property( ctx, QStringLiteral("okular_timerID") ).toInt32( ctx );
|
||||
const int timerId = timerObject.property( ctx, OKULAR_TIMERID ).toInt32( ctx );
|
||||
QTimer *timer = g_timerCache->value( timerId );
|
||||
if( timer != nullptr )
|
||||
{
|
||||
|
@ -247,7 +250,7 @@ static KJSObject appSetTimeOut( KJSContext *ctx, void *object,
|
|||
QTimer *timer = new QTimer();
|
||||
timer->setSingleShot( true );
|
||||
|
||||
QObject::connect( timer, &QTimer::timeout, [=](){ doc->executeScript( function ); } );
|
||||
QObject::connect( timer, &QTimer::timeout, doc->m_parent, [=](){ doc->executeScript( function ); } );
|
||||
|
||||
timer->start( interval );
|
||||
|
||||
|
@ -259,7 +262,7 @@ static KJSObject appClearTimeOut( KJSContext *ctx, void *,
|
|||
const KJSArguments &arguments )
|
||||
{
|
||||
KJSObject timerObject = arguments.at( 0 );
|
||||
const int timerId = timerObject.property( ctx, QStringLiteral("okular_timerID") ).toInt32( ctx );
|
||||
const int timerId = timerObject.property( ctx, OKULAR_TIMERID ).toInt32( ctx );
|
||||
QTimer *timer = g_timerCache->value( timerId );
|
||||
|
||||
if( timer != nullptr )
|
||||
|
@ -311,7 +314,7 @@ KJSObject JSApp::object( KJSContext *ctx, DocumentPrivate *doc )
|
|||
KJSObject JSApp::wrapTimer( KJSContext *ctx, QTimer *timer)
|
||||
{
|
||||
KJSObject timerObject = g_appProto->constructObject( ctx, timer );
|
||||
timerObject.setProperty( ctx, QStringLiteral("okular_timerID"), timer->timerId() );
|
||||
timerObject.setProperty( ctx, OKULAR_TIMERID, timer->timerId() );
|
||||
|
||||
g_timerCache->insert( timer->timerId(), timer );
|
||||
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
|
||||
class KJSContext;
|
||||
class KJSObject;
|
||||
|
||||
#include <QTimer>
|
||||
class QTimer;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
static KJSPrototype *g_displayProto;
|
||||
|
@ -24,25 +22,25 @@ static KJSPrototype *g_displayProto;
|
|||
// display.hidden
|
||||
static KJSObject displayGetHidden( KJSContext *, void * )
|
||||
{
|
||||
return KJSNumber( FormField::FormHidden );
|
||||
return KJSNumber( FormDisplay::FormHidden );
|
||||
}
|
||||
|
||||
// display.visible
|
||||
static KJSObject displayGetVisible( KJSContext *, void * )
|
||||
{
|
||||
return KJSNumber( FormField::FormVisible );
|
||||
return KJSNumber( FormDisplay::FormVisible );
|
||||
}
|
||||
|
||||
// display.noView
|
||||
static KJSObject displayGetNoView( KJSContext *, void * )
|
||||
{
|
||||
return KJSNumber( FormField::FormNoView );
|
||||
return KJSNumber( FormDisplay::FormNoView );
|
||||
}
|
||||
|
||||
// display.noPrint
|
||||
static KJSObject displayGetNoPrint( KJSContext *, void * )
|
||||
{
|
||||
return KJSNumber( FormField::FormNoPrint );
|
||||
return KJSNumber( FormDisplay::FormNoPrint );
|
||||
}
|
||||
|
||||
void JSDisplay::initType( KJSContext *ctx )
|
||||
|
|
|
@ -15,6 +15,17 @@ class KJSObject;
|
|||
|
||||
namespace Okular {
|
||||
|
||||
/**
|
||||
* The display types of the field.
|
||||
*/
|
||||
enum FormDisplay
|
||||
{
|
||||
FormVisible,
|
||||
FormHidden,
|
||||
FormNoPrint,
|
||||
FormNoView
|
||||
};
|
||||
|
||||
class JSDisplay
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -17,16 +17,18 @@
|
|||
#include <qhash.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <memory>
|
||||
|
||||
#include "../debug_p.h"
|
||||
#include "../document_p.h"
|
||||
#include "../form.h"
|
||||
#include "../page.h"
|
||||
#include "../page_p.h"
|
||||
#include "kjs_display_p.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
#define OKULAR_NAME QStringLiteral("okular_name")
|
||||
|
||||
static KJSPrototype *g_fieldProto;
|
||||
|
||||
typedef QHash< FormField *, Page * > FormCache;
|
||||
|
@ -234,9 +236,9 @@ static KJSObject fieldGetDisplay( KJSContext *, void *object )
|
|||
bool visible = field->isVisible();
|
||||
if( visible )
|
||||
{
|
||||
return KJSNumber( field->isPrintable() ? FormField::FormVisible : FormField::FormNoPrint );
|
||||
return KJSNumber( field->isPrintable() ? FormDisplay::FormVisible : FormDisplay::FormNoPrint );
|
||||
}
|
||||
return KJSNumber( field->isPrintable() ? FormField::FormNoView : FormField::FormHidden );
|
||||
return KJSNumber( field->isPrintable() ? FormDisplay::FormNoView : FormDisplay::FormHidden );
|
||||
}
|
||||
|
||||
// Field.display (setter)
|
||||
|
@ -246,19 +248,19 @@ static void fieldSetDisplay( KJSContext *context, void *object, KJSObject value
|
|||
const unsigned int b = value.toInt32( context );
|
||||
switch( b )
|
||||
{
|
||||
case FormField::FormVisible:
|
||||
case FormDisplay::FormVisible:
|
||||
field->setVisible( true );
|
||||
field->setPrintable( true );
|
||||
break;
|
||||
case FormField::FormHidden:
|
||||
case FormDisplay::FormHidden:
|
||||
field->setVisible( false );
|
||||
field->setPrintable( false );
|
||||
break;
|
||||
case FormField::FormNoPrint:
|
||||
case FormDisplay::FormNoPrint:
|
||||
field->setVisible( true );
|
||||
field->setPrintable( false );
|
||||
break;
|
||||
case FormField::FormNoView:
|
||||
case FormDisplay::FormNoView:
|
||||
field->setVisible( false );
|
||||
field->setPrintable( true );
|
||||
break;
|
||||
|
@ -273,7 +275,7 @@ static KJSObject fieldButtonGetIcon( KJSContext *ctx, void *object,
|
|||
FormField *field = reinterpret_cast< FormField * >( object );
|
||||
|
||||
KJSObject fieldObject;
|
||||
fieldObject.setProperty( ctx, QStringLiteral("okular_name"), field->name() );
|
||||
fieldObject.setProperty( ctx, OKULAR_NAME, field->name() );
|
||||
g_buttonCache->insert( field->name(), field );
|
||||
|
||||
return fieldObject;
|
||||
|
@ -287,7 +289,7 @@ static KJSObject fieldButtonSetIcon( KJSContext *ctx, void *object,
|
|||
{
|
||||
FormField *field = reinterpret_cast< FormField * >( object );
|
||||
|
||||
const QString fieldName = arguments.at( 0 ).property( ctx, QStringLiteral("okular_name") ).toString( ctx );
|
||||
const QString fieldName = arguments.at( 0 ).property( ctx, OKULAR_NAME ).toString( ctx );
|
||||
|
||||
if( field->type() == Okular::FormField::FormButton )
|
||||
{
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include <QDebug>
|
||||
#include <QPair>
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
static KJSPrototype *g_OCGProto;
|
||||
|
@ -42,7 +40,7 @@ static KJSObject OCGGetState( KJSContext *, void *object )
|
|||
|
||||
// OCG.state (setter)
|
||||
static void OCGSetState( KJSContext* ctx, void* object,
|
||||
KJSObject value )
|
||||
KJSObject value )
|
||||
{
|
||||
QPair< int, int > *pair = reinterpret_cast< QPair< int, int >* > ( object );
|
||||
QAbstractItemModel *model = g_OCGCache->value( pair );
|
||||
|
@ -85,4 +83,4 @@ void JSOCG::clearCachedFields()
|
|||
{
|
||||
g_OCGCache->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,4 +27,4 @@ class JSOCG
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -110,7 +110,7 @@ bool PopplerFormFieldButton::isPrintable() const
|
|||
#ifdef HAVE_POPPLER_0_79
|
||||
return m_field->isPrintable();
|
||||
#else
|
||||
return m_field->isVisible() ? true : false;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ bool PopplerFormFieldText::isPrintable() const
|
|||
#ifdef HAVE_POPPLER_0_79
|
||||
return m_field->isPrintable();
|
||||
#else
|
||||
return m_field->isVisible() ? true : false;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ bool PopplerFormFieldChoice::isPrintable() const
|
|||
#ifdef HAVE_POPPLER_0_79
|
||||
return m_field->isPrintable();
|
||||
#else
|
||||
return m_field->isVisible() ? true : false;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class PopplerFormFieldButton : public Okular::FormFieldButton
|
|||
/*
|
||||
* Supported only in newer versions of Poppler library.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.9
|
||||
*/
|
||||
Poppler::FormFieldIcon icon() const;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue