summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-06-06 15:34:56 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-06-15 16:23:08 +0200
commitf8c918916f9195c23c3fcf208fbf1da7e96e34b2 (patch)
treedb318b5a03c86406059224901797ba558f7007ea /src
parent75d027d27dd14ffdef6ba8f4c40516fab9a3a688 (diff)
QAxScriptManager: move private members into the private class
Remove implementation details from the public header. Use lambdas to replace the one-liner private slots. Change-Id: I1a55af6bf9e67025e656ff90545887998395d9f9 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/activeqt/container/qaxscript.cpp44
-rw-r--r--src/activeqt/container/qaxscript.h7
2 files changed, 17 insertions, 34 deletions
diff --git a/src/activeqt/container/qaxscript.cpp b/src/activeqt/container/qaxscript.cpp
index a25c1f2..cc5da7d 100644
--- a/src/activeqt/container/qaxscript.cpp
+++ b/src/activeqt/container/qaxscript.cpp
@@ -35,6 +35,9 @@ static QList<QAxEngineDescriptor> engines;
class QAxScriptManagerPrivate
{
public:
+ void updateScript(QAxScript*);
+ QAxScript *scriptForFunction(QString &function) const;
+
QHash<QString, QAxScript*> scriptDict;
QHash<QString, QAxBase*> objectDict;
};
@@ -641,8 +644,11 @@ script_engine(nullptr)
{
if (manager) {
manager->d->scriptDict.insert(name, this);
- connect(this, SIGNAL(error(int,QString,int,QString)),
- manager, SLOT(scriptError(int,QString,int,QString)));
+
+ connect(this, &QAxScript::error, script_manager,
+ [this](int code, const QString &description, int sourcePosition, const QString &sourceText){
+ emit script_manager->error(this, code, description, sourcePosition, sourceText);
+ });
}
#ifndef QT_NO_QAXSCRIPT
@@ -795,7 +801,7 @@ void QAxScript::updateObjects()
if (!script_manager)
return;
- script_manager->updateScript(this);
+ script_manager->d->updateScript(this);
}
/*! \internal
@@ -977,7 +983,9 @@ void QAxScriptManager::addObject(QAxBase *object)
return;
d->objectDict.insert(name, object);
- connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)));
+ QObject::connect(obj, &QObject::destroyed, this, [this](QObject *o){
+ d->objectDict.take(o->objectName());
+ });
}
/*! \fn void QAxScriptManager::addObject(QObject *object)
@@ -1126,7 +1134,7 @@ QVariant QAxScriptManager::call(const QString &function, const QVariant &var1,
QVariant QAxScriptManager::call(const QString &function, QList<QVariant> &arguments)
{
QString signature = function;
- QAxScript *s = scriptForFunction(signature);
+ QAxScript *s = d->scriptForFunction(signature);
if (!s) {
#ifdef QT_CHECK_STATE
qWarning("QAxScriptManager::call: No script provides function %s, or this function\n"
@@ -1207,18 +1215,17 @@ QString QAxScriptManager::scriptFileFilter()
*/
/*!
- \fn QAxScript *QAxScriptManager::scriptForFunction(QString &function) const
\internal
Returns a pointer to the first QAxScript that knows
about \a function, or nullptr if this function is unknown. \a function
is changed to the callable signature.
*/
-QAxScript *QAxScriptManager::scriptForFunction(QString &function) const
+QAxScript *QAxScriptManagerPrivate::scriptForFunction(QString &function) const
{
const auto startPrototype = function.indexOf(u'(');
- for (const auto &script : d->scriptDict) {
+ for (const auto &script : scriptDict) {
const QMetaObject *mo = script->scriptEngine()->metaObject();
for (int i = mo->methodOffset(); i < mo->methodCount(); ++i) {
const QMetaMethod slot(mo->method(i));
@@ -1247,29 +1254,12 @@ QAxScript *QAxScriptManager::scriptForFunction(QString &function) const
/*!
\internal
*/
-void QAxScriptManager::updateScript(QAxScript *script)
+void QAxScriptManagerPrivate::updateScript(QAxScript *script)
{
if (QAxScriptEngine *engine = script->scriptEngine()) {
- for (auto it = d->objectDict.constBegin(), end = d->objectDict.constEnd(); it != end; ++it)
+ for (auto it = objectDict.constBegin(), end = objectDict.constEnd(); it != end; ++it)
engine->addItem(it.key());
}
}
-/*!
- \internal
-*/
-void QAxScriptManager::objectDestroyed(QObject *o)
-{
- d->objectDict.take(o->objectName());
-}
-
-/*!
- \internal
-*/
-void QAxScriptManager::scriptError(int code, const QString &desc, int spos, const QString &stext)
-{
- QAxScript *source = qobject_cast<QAxScript*>(sender());
- emit error(source, code, desc, spos, stext);
-}
-
QT_END_NAMESPACE
diff --git a/src/activeqt/container/qaxscript.h b/src/activeqt/container/qaxscript.h
index e35f2dd..f40262d 100644
--- a/src/activeqt/container/qaxscript.h
+++ b/src/activeqt/container/qaxscript.h
@@ -141,16 +141,9 @@ public:
Q_SIGNALS:
void error(QAxScript *script, int code, const QString &description, int sourcePosition, const QString &sourceText);
-private Q_SLOTS:
- void objectDestroyed(QObject *o);
- void scriptError(int code, const QString &description, int sourcePosition, const QString &sourceText);
-
private:
friend class QAxScript;
QAxScriptManagerPrivate *d;
-
- void updateScript(QAxScript*);
- QAxScript *scriptForFunction(QString &function) const;
};