CopperSpice API  1.7.2
QScriptExtensionPlugin Class Referenceabstract

An abstract base class for custom QScript extension plugins. More...

Inheritance diagram for QScriptExtensionPlugin:
QObject

Public Methods

 QScriptExtensionPlugin (QObject *parent=nullptr)
 
 ~QScriptExtensionPlugin ()
 
virtual void initialize (const QString &key, QScriptEngine *engine) override = 0
 
virtual QStringList keys () const override = 0
 
QScriptValue setupPackage (const QString &key, QScriptEngine *engine) const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &objName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Additional Inherited Members

- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QScriptExtensionPlugin class provides an abstract base class for custom QScript extension plugins.

QScriptExtensionPlugin is a plugin interface that makes it possible to offer extensions which can be loaded dynamically into applications using the QScriptEngine class. Writing a script extension plugin is achieved by subclassing this base class, reimplementing the pure virtual keys() and initialize() methods and then exporting the class with the CS_PLUGIN_REGISTER() macro.

See also
QScriptEngine::importExtension(), Creating CsScript Extensions, Creating Plugins

Constructor & Destructor Documentation

QScriptExtensionPlugin::QScriptExtensionPlugin ( QObject parent = nullptr)
explicit

Constructs a script extension plugin with the given parent.

QScriptExtensionPlugin::~QScriptExtensionPlugin ( )

Destroys the script extension plugin. You never have to call this explicitly as CopperSpice destroys a plugin automatically when it is no longer used.

Method Documentation

void QScriptExtensionPlugin::initialize ( const QString key,
QScriptEngine engine 
)
overridepure virtual

Initializes the extension specified by key in the given engine. The key must come from the set of keys().

See also
keys()
QStringList QScriptExtensionPlugin::keys ( ) const
overridepure virtual

Returns the list of keys this plugin supports. The keys are usually the names of the JavaScript "modules" or "packages" which are implemented in the plugin. For example, com.mycompany.MyProduct.

See also
initialize()
QScriptValue QScriptExtensionPlugin::setupPackage ( const QString key,
QScriptEngine engine 
) const

This method is provided for convenience when reimplementing initialize(). It splits the given key on '.' (dot) and ensures that there is a corresponding path of objects in the environment of the given engine, creating new objects to complete the path if necessary.

For example, if the key is "com.copperspice" after the call to setupPackage() the script expression com.copperspice will evaluate to an object. More specifically, the engine's Global Object will have a property called "com" which in turn has a property called "copperspice".

Use this method to avoid global namespace pollution when installing your extensions in the engine.

See also
initialize()