summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-05-26 13:36:28 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-05-26 15:56:17 +0200
commit9bd2e8f1cc1f98a0fb613e20a971e9eee22e19ae (patch)
tree57b52f0b499c93ebbd0b4b68cdd0e826df0eddcd
parent1680caca6240665519659a502f9c30327374050a (diff)
Brush up the QAxFactory macros
Streamline code, fix indentation errors. Change-Id: I7f16ac912bb5ec7d6f25f11cd2e1ae81a0db2196 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/activeqt/control/qaxfactory.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/activeqt/control/qaxfactory.h b/src/activeqt/control/qaxfactory.h
index 76be9d5..ce2fcbd 100644
--- a/src/activeqt/control/qaxfactory.h
+++ b/src/activeqt/control/qaxfactory.h
@@ -142,8 +142,7 @@ inline bool QAxFactory::stopServer()
QT_BEGIN_NAMESPACE \
QAxFactory *qax_instantiate() \
{ \
- IMPL *impl = new IMPL(QUuid(TYPELIB), QUuid(APPID)); \
- return impl; \
+ return new IMPL(QUuid(TYPELIB), QUuid(APPID)); \
} \
QT_END_NAMESPACE
@@ -152,18 +151,16 @@ inline bool QAxFactory::stopServer()
class QAxDefaultFactory : public QAxFactory \
{ \
public: \
- QAxDefaultFactory(const QUuid &app, const QUuid &lib) \
+ explicit QAxDefaultFactory(const QUuid &app, const QUuid &lib) \
: QAxFactory(app, lib), className(QLatin1String(#Class)) {} \
QStringList featureList() const override \
{ \
- QStringList list; \
- list << className; \
- return list; \
+ return {className}; \
} \
const QMetaObject *metaObject(const QString &key) const override \
{ \
if (key == className) \
- return &Class::staticMetaObject; \
+ return &Class::staticMetaObject; \
return nullptr; \
} \
QObject *createObject(const QString &key) override \
@@ -200,12 +197,16 @@ template<class T>
class QAxClass : public QAxFactory
{
public:
- QAxClass(const QString &libId, const QString &appId)
+ explicit QAxClass(const QString &libId, const QString &appId)
: QAxFactory(libId, appId)
{}
const QMetaObject *metaObject(const QString &) const override { return &T::staticMetaObject; }
- QStringList featureList() const override { return QStringList(QLatin1String(T::staticMetaObject.className())); }
+ QStringList featureList() const override
+ {
+ return {QLatin1String(T::staticMetaObject.className())};
+ }
+
QObject *createObject(const QString &key) override
{
const QMetaObject &mo = T::staticMetaObject;
@@ -285,14 +286,15 @@ private:
} \
~QAxFactoryList() override { qDeleteAll(factories); } \
QStringList featureList() const override { return factoryKeys; } \
- const QMetaObject *metaObject(const QString&key) const override { \
- QAxFactory *f = factories[key]; \
+ const QMetaObject *metaObject(const QString&key) const override \
+ { \
+ QAxFactory *f = factories.value(key); \
return f ? f->metaObject(key) : nullptr; \
} \
QObject *createObject(const QString &key) override { \
if (!creatable.value(key)) \
return nullptr; \
- QAxFactory *f = factories[key]; \
+ QAxFactory *f = factories.value(key); \
return f ? f->createObject(key) : nullptr; \
} \
QUuid classID(const QString &key) const override { \
@@ -308,12 +310,12 @@ private:
return f ? f->eventsID(key) : QUuid(); \
} \
void registerClass(const QString &key, QSettings *s) const override { \
- QAxFactory *f = factories.value(key); \
- if (f) f->registerClass(key, s); \
+ if (QAxFactory *f = factories.value(key)) \
+ f->registerClass(key, s); \
} \
void unregisterClass(const QString &key, QSettings *s) const override { \
- QAxFactory *f = factories.value(key); \
- if (f) f->unregisterClass(key, s); \
+ if (QAxFactory *f = factories.value(key)) \
+ f->unregisterClass(key, s); \
} \
QString exposeToSuperClass(const QString &key) const override { \
QAxFactory *f = factories.value(key); \
@@ -329,9 +331,8 @@ private:
} \
}; \
QAxFactory *qax_instantiate() \
- { \
- QAxFactoryList *impl = new QAxFactoryList(); \
- return impl; \
+ { \
+ return new QAxFactoryList(); \
} \
QT_END_NAMESPACE