File indexing completed on 2024-05-12 04:33:32
0001 /* 0002 SPDX-FileCopyrightText: 2008 Pino Toscano <pino@kde.org> 0003 SPDX-FileCopyrightText: 2008 Harri Porten <porten@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef OKULAR_SCRIPT_JS_FIELD_P_H 0009 #define OKULAR_SCRIPT_JS_FIELD_P_H 0010 0011 #include <QJSValue> 0012 #include <QObject> 0013 0014 namespace Okular 0015 { 0016 class FormField; 0017 class Page; 0018 0019 class JSField : public QObject 0020 { 0021 Q_OBJECT 0022 Q_PROPERTY(QJSValue doc READ doc CONSTANT) 0023 Q_PROPERTY(QString name READ name CONSTANT) 0024 Q_PROPERTY(bool readonly READ readonly WRITE setReadonly) // clazy:exclude=qproperty-without-notify 0025 Q_PROPERTY(QString type READ type CONSTANT) 0026 Q_PROPERTY(QJSValue value READ value WRITE setValue) // clazy:exclude=qproperty-without-notify 0027 Q_PROPERTY(QJSValue valueAsString READ valueAsString) // clazy:exclude=qproperty-without-notify 0028 Q_PROPERTY(bool hidden READ hidden WRITE setHidden) // clazy:exclude=qproperty-without-notify 0029 Q_PROPERTY(int display READ display WRITE setDisplay) // clazy:exclude=qproperty-without-notify 0030 0031 public: 0032 explicit JSField(FormField *field, QObject *parent = nullptr); 0033 ~JSField() override; 0034 0035 static QJSValue wrapField(QJSEngine *engine, FormField *field, Page *page); 0036 static void clearCachedFields(); 0037 0038 QJSValue doc() const; 0039 QString name() const; 0040 bool readonly() const; 0041 void setReadonly(bool readonly); 0042 int display() const; 0043 void setDisplay(int display); 0044 QString type() const; 0045 QJSValue value() const; 0046 void setValue(const QJSValue &value); 0047 QJSValue valueAsString() const; 0048 bool hidden() const; 0049 void setHidden(bool hidden); 0050 0051 Q_INVOKABLE QJSValue buttonGetIcon(int nFace = 0) const; 0052 Q_INVOKABLE void buttonSetIcon(const QJSValue &oIcon, int nFace = 0); 0053 0054 private: 0055 QJSValue fieldGetValueCore(bool asString) const; 0056 0057 FormField *m_field = nullptr; 0058 }; 0059 0060 } 0061 0062 #endif