Fixed indentation, bad algebra and moved display enum to KJSDisplay

remotes/origin/more-conventional-sidebar
João Netto 7 years ago committed by Albert Astals Cid
parent da01333817
commit 60ff2f414e
  1. 2
      core/document_p.h
  2. 17
      core/form.h
  3. 13
      core/script/kjs_app.cpp
  4. 3
      core/script/kjs_app_p.h
  5. 10
      core/script/kjs_display.cpp
  6. 11
      core/script/kjs_display_p.h
  7. 20
      core/script/kjs_field.cpp
  8. 6
      core/script/kjs_ocg.cpp
  9. 2
      core/script/kjs_ocg_p.h
  10. 6
      generators/poppler/formfields.cpp
  11. 2
      generators/poppler/formfields.h

@ -194,7 +194,7 @@ class DocumentPrivate
/** /**
* Executes a JavaScript script from the setInterval function. * Executes a JavaScript script from the setInterval function.
* *
* @since 1.7 * @since 1.9
*/ */
void executeScript( const QString &function ); void executeScript( const QString &function );

@ -57,17 +57,6 @@ class OKULARCORE_EXPORT FormField
FormSignature ///< A signature. FormSignature ///< A signature.
}; };
/**
* The display types of the field.
*/
enum FieldDisplay
{
FormVisible,
FormHidden,
FormNoPrint,
FormNoView
};
virtual ~FormField(); virtual ~FormField();
/** /**
@ -124,14 +113,14 @@ class OKULARCORE_EXPORT FormField
/** /**
Whether this field is printable. Whether this field is printable.
@since 1.7 @since 1.9
*/ */
virtual bool isPrintable() const; virtual bool isPrintable() const;
/** /**
Set this field printable Set this field printable
@since 1.7 @since 1.9
*/ */
virtual void setPrintable( bool value ); 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. * 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 ); virtual void setIcon( Okular::FormField *field );

@ -17,6 +17,7 @@
#include <qapplication.h> #include <qapplication.h>
#include <QLocale> #include <QLocale>
#include <QTimer>
#include <KLocalizedString> #include <KLocalizedString>
@ -26,6 +27,8 @@
using namespace Okular; using namespace Okular;
#define OKULAR_TIMERID QStringLiteral( "okular_timerID" )
static KJSPrototype *g_appProto; static KJSPrototype *g_appProto;
typedef QHash< int, QTimer * > TimerCache; typedef QHash< int, QTimer * > TimerCache;
Q_GLOBAL_STATIC( TimerCache, g_timerCache ) Q_GLOBAL_STATIC( TimerCache, g_timerCache )
@ -212,7 +215,7 @@ static KJSObject appSetInterval( KJSContext *ctx, void *object,
QTimer *timer = new QTimer(); 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 ); timer->start( interval );
@ -224,7 +227,7 @@ static KJSObject appClearInterval( KJSContext *ctx, void *,
const KJSArguments &arguments ) const KJSArguments &arguments )
{ {
KJSObject timerObject = arguments.at( 0 ); 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 ); QTimer *timer = g_timerCache->value( timerId );
if( timer != nullptr ) if( timer != nullptr )
{ {
@ -247,7 +250,7 @@ static KJSObject appSetTimeOut( KJSContext *ctx, void *object,
QTimer *timer = new QTimer(); QTimer *timer = new QTimer();
timer->setSingleShot( true ); 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 ); timer->start( interval );
@ -259,7 +262,7 @@ static KJSObject appClearTimeOut( KJSContext *ctx, void *,
const KJSArguments &arguments ) const KJSArguments &arguments )
{ {
KJSObject timerObject = arguments.at( 0 ); 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 ); QTimer *timer = g_timerCache->value( timerId );
if( timer != nullptr ) if( timer != nullptr )
@ -311,7 +314,7 @@ KJSObject JSApp::object( KJSContext *ctx, DocumentPrivate *doc )
KJSObject JSApp::wrapTimer( KJSContext *ctx, QTimer *timer) KJSObject JSApp::wrapTimer( KJSContext *ctx, QTimer *timer)
{ {
KJSObject timerObject = g_appProto->constructObject( ctx, 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 ); g_timerCache->insert( timer->timerId(), timer );

@ -13,8 +13,7 @@
class KJSContext; class KJSContext;
class KJSObject; class KJSObject;
class QTimer;
#include <QTimer>
namespace Okular { namespace Okular {

@ -15,8 +15,6 @@
#include <QString> #include <QString>
#include <memory>
using namespace Okular; using namespace Okular;
static KJSPrototype *g_displayProto; static KJSPrototype *g_displayProto;
@ -24,25 +22,25 @@ static KJSPrototype *g_displayProto;
// display.hidden // display.hidden
static KJSObject displayGetHidden( KJSContext *, void * ) static KJSObject displayGetHidden( KJSContext *, void * )
{ {
return KJSNumber( FormField::FormHidden ); return KJSNumber( FormDisplay::FormHidden );
} }
// display.visible // display.visible
static KJSObject displayGetVisible( KJSContext *, void * ) static KJSObject displayGetVisible( KJSContext *, void * )
{ {
return KJSNumber( FormField::FormVisible ); return KJSNumber( FormDisplay::FormVisible );
} }
// display.noView // display.noView
static KJSObject displayGetNoView( KJSContext *, void * ) static KJSObject displayGetNoView( KJSContext *, void * )
{ {
return KJSNumber( FormField::FormNoView ); return KJSNumber( FormDisplay::FormNoView );
} }
// display.noPrint // display.noPrint
static KJSObject displayGetNoPrint( KJSContext *, void * ) static KJSObject displayGetNoPrint( KJSContext *, void * )
{ {
return KJSNumber( FormField::FormNoPrint ); return KJSNumber( FormDisplay::FormNoPrint );
} }
void JSDisplay::initType( KJSContext *ctx ) void JSDisplay::initType( KJSContext *ctx )

@ -15,6 +15,17 @@ class KJSObject;
namespace Okular { namespace Okular {
/**
* The display types of the field.
*/
enum FormDisplay
{
FormVisible,
FormHidden,
FormNoPrint,
FormNoView
};
class JSDisplay class JSDisplay
{ {
public: public:

@ -17,16 +17,18 @@
#include <qhash.h> #include <qhash.h>
#include <QDebug> #include <QDebug>
#include <memory>
#include "../debug_p.h" #include "../debug_p.h"
#include "../document_p.h" #include "../document_p.h"
#include "../form.h" #include "../form.h"
#include "../page.h" #include "../page.h"
#include "../page_p.h" #include "../page_p.h"
#include "kjs_display_p.h"
using namespace Okular; using namespace Okular;
#define OKULAR_NAME QStringLiteral("okular_name")
static KJSPrototype *g_fieldProto; static KJSPrototype *g_fieldProto;
typedef QHash< FormField *, Page * > FormCache; typedef QHash< FormField *, Page * > FormCache;
@ -234,9 +236,9 @@ static KJSObject fieldGetDisplay( KJSContext *, void *object )
bool visible = field->isVisible(); bool visible = field->isVisible();
if( visible ) 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) // Field.display (setter)
@ -246,19 +248,19 @@ static void fieldSetDisplay( KJSContext *context, void *object, KJSObject value
const unsigned int b = value.toInt32( context ); const unsigned int b = value.toInt32( context );
switch( b ) switch( b )
{ {
case FormField::FormVisible: case FormDisplay::FormVisible:
field->setVisible( true ); field->setVisible( true );
field->setPrintable( true ); field->setPrintable( true );
break; break;
case FormField::FormHidden: case FormDisplay::FormHidden:
field->setVisible( false ); field->setVisible( false );
field->setPrintable( false ); field->setPrintable( false );
break; break;
case FormField::FormNoPrint: case FormDisplay::FormNoPrint:
field->setVisible( true ); field->setVisible( true );
field->setPrintable( false ); field->setPrintable( false );
break; break;
case FormField::FormNoView: case FormDisplay::FormNoView:
field->setVisible( false ); field->setVisible( false );
field->setPrintable( true ); field->setPrintable( true );
break; break;
@ -273,7 +275,7 @@ static KJSObject fieldButtonGetIcon( KJSContext *ctx, void *object,
FormField *field = reinterpret_cast< FormField * >( object ); FormField *field = reinterpret_cast< FormField * >( object );
KJSObject fieldObject; KJSObject fieldObject;
fieldObject.setProperty( ctx, QStringLiteral("okular_name"), field->name() ); fieldObject.setProperty( ctx, OKULAR_NAME, field->name() );
g_buttonCache->insert( field->name(), field ); g_buttonCache->insert( field->name(), field );
return fieldObject; return fieldObject;
@ -287,7 +289,7 @@ static KJSObject fieldButtonSetIcon( KJSContext *ctx, void *object,
{ {
FormField *field = reinterpret_cast< FormField * >( 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 ) if( field->type() == Okular::FormField::FormButton )
{ {

@ -18,8 +18,6 @@
#include <QDebug> #include <QDebug>
#include <QPair> #include <QPair>
#include <memory>
using namespace Okular; using namespace Okular;
static KJSPrototype *g_OCGProto; static KJSPrototype *g_OCGProto;
@ -42,7 +40,7 @@ static KJSObject OCGGetState( KJSContext *, void *object )
// OCG.state (setter) // OCG.state (setter)
static void OCGSetState( KJSContext* ctx, void* object, static void OCGSetState( KJSContext* ctx, void* object,
KJSObject value ) KJSObject value )
{ {
QPair< int, int > *pair = reinterpret_cast< QPair< int, int >* > ( object ); QPair< int, int > *pair = reinterpret_cast< QPair< int, int >* > ( object );
QAbstractItemModel *model = g_OCGCache->value( pair ); QAbstractItemModel *model = g_OCGCache->value( pair );
@ -85,4 +83,4 @@ void JSOCG::clearCachedFields()
{ {
g_OCGCache->clear(); g_OCGCache->clear();
} }
} }

@ -27,4 +27,4 @@ class JSOCG
} }
#endif #endif

@ -110,7 +110,7 @@ bool PopplerFormFieldButton::isPrintable() const
#ifdef HAVE_POPPLER_0_79 #ifdef HAVE_POPPLER_0_79
return m_field->isPrintable(); return m_field->isPrintable();
#else #else
return m_field->isVisible() ? true : false; return true;
#endif #endif
} }
@ -244,7 +244,7 @@ bool PopplerFormFieldText::isPrintable() const
#ifdef HAVE_POPPLER_0_79 #ifdef HAVE_POPPLER_0_79
return m_field->isPrintable(); return m_field->isPrintable();
#else #else
return m_field->isVisible() ? true : false; return true;
#endif #endif
} }
@ -374,7 +374,7 @@ bool PopplerFormFieldChoice::isPrintable() const
#ifdef HAVE_POPPLER_0_79 #ifdef HAVE_POPPLER_0_79
return m_field->isPrintable(); return m_field->isPrintable();
#else #else
return m_field->isVisible() ? true : false; return true;
#endif #endif
} }

@ -43,7 +43,7 @@ class PopplerFormFieldButton : public Okular::FormFieldButton
/* /*
* Supported only in newer versions of Poppler library. * Supported only in newer versions of Poppler library.
* *
* @since 1.7 * @since 1.9
*/ */
Poppler::FormFieldIcon icon() const; Poppler::FormFieldIcon icon() const;
#endif #endif

Loading…
Cancel
Save