diff --git a/core/document_p.h b/core/document_p.h index 2a977f6b6..770a71f01 100644 --- a/core/document_p.h +++ b/core/document_p.h @@ -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 ); diff --git a/core/form.h b/core/form.h index cd395dd4f..65f946869 100644 --- a/core/form.h +++ b/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 ); diff --git a/core/script/kjs_app.cpp b/core/script/kjs_app.cpp index 3534906ec..c17acd13f 100644 --- a/core/script/kjs_app.cpp +++ b/core/script/kjs_app.cpp @@ -17,6 +17,7 @@ #include #include +#include #include @@ -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 ); diff --git a/core/script/kjs_app_p.h b/core/script/kjs_app_p.h index 64d996bca..06a79276c 100644 --- a/core/script/kjs_app_p.h +++ b/core/script/kjs_app_p.h @@ -13,8 +13,7 @@ class KJSContext; class KJSObject; - -#include +class QTimer; namespace Okular { diff --git a/core/script/kjs_display.cpp b/core/script/kjs_display.cpp index d7ed212b6..5fd758e81 100644 --- a/core/script/kjs_display.cpp +++ b/core/script/kjs_display.cpp @@ -15,8 +15,6 @@ #include -#include - 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 ) diff --git a/core/script/kjs_display_p.h b/core/script/kjs_display_p.h index bc28faf29..20a85bab9 100644 --- a/core/script/kjs_display_p.h +++ b/core/script/kjs_display_p.h @@ -15,6 +15,17 @@ class KJSObject; namespace Okular { +/** + * The display types of the field. +*/ +enum FormDisplay +{ + FormVisible, + FormHidden, + FormNoPrint, + FormNoView +}; + class JSDisplay { public: diff --git a/core/script/kjs_field.cpp b/core/script/kjs_field.cpp index 8a5e5eef6..bb7b6b5d9 100644 --- a/core/script/kjs_field.cpp +++ b/core/script/kjs_field.cpp @@ -17,16 +17,18 @@ #include #include -#include #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 ) { diff --git a/core/script/kjs_ocg.cpp b/core/script/kjs_ocg.cpp index d7061f066..9c1c1fee6 100644 --- a/core/script/kjs_ocg.cpp +++ b/core/script/kjs_ocg.cpp @@ -18,8 +18,6 @@ #include #include -#include - 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(); } -} \ No newline at end of file +} diff --git a/core/script/kjs_ocg_p.h b/core/script/kjs_ocg_p.h index dcfcebdca..894757df7 100644 --- a/core/script/kjs_ocg_p.h +++ b/core/script/kjs_ocg_p.h @@ -27,4 +27,4 @@ class JSOCG } -#endif \ No newline at end of file +#endif diff --git a/generators/poppler/formfields.cpp b/generators/poppler/formfields.cpp index 869d2cc3a..2092c5220 100644 --- a/generators/poppler/formfields.cpp +++ b/generators/poppler/formfields.cpp @@ -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 } diff --git a/generators/poppler/formfields.h b/generators/poppler/formfields.h index 56d23580e..fab0e1393 100644 --- a/generators/poppler/formfields.h +++ b/generators/poppler/formfields.h @@ -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