[libcalamares] Apply coding style to PluginFactory

This commit is contained in:
Adriaan de Groot 2019-08-13 20:50:52 +02:00
parent ccd707b23a
commit f31ff8b9ea
2 changed files with 22 additions and 20 deletions

View File

@ -6,6 +6,4 @@
#include "PluginFactory.h" #include "PluginFactory.h"
CalamaresPluginFactory::~CalamaresPluginFactory() CalamaresPluginFactory::~CalamaresPluginFactory() {}
{
}

View File

@ -44,7 +44,10 @@ class CalamaresPluginFactory : public KPluginFactory
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CalamaresPluginFactory() : KPluginFactory() {} explicit CalamaresPluginFactory()
: KPluginFactory()
{
}
~CalamaresPluginFactory() override; ~CalamaresPluginFactory() override;
/** @brief Create an object from the factory. /** @brief Create an object from the factory.
@ -52,17 +55,18 @@ public:
* Ignores all the @p args since they are not used. Calls * Ignores all the @p args since they are not used. Calls
* Calamares constructors for the Jobs and ViewSteps. * Calamares constructors for the Jobs and ViewSteps.
*/ */
template<class impl, class ParentType> template < class impl, class ParentType >
static QObject *createInstance(QWidget *parentWidget, QObject *parent, const QVariantList &args) static QObject* createInstance( QWidget* parentWidget, QObject* parent, const QVariantList& args )
{ {
Q_UNUSED(parentWidget); Q_UNUSED( parentWidget );
Q_UNUSED(args); Q_UNUSED( args );
ParentType *p = nullptr; ParentType* p = nullptr;
if (parent) { if ( parent )
p = qobject_cast<ParentType *>(parent); {
Q_ASSERT(p); p = qobject_cast< ParentType* >( parent );
Q_ASSERT( p );
} }
return new impl(p); return new impl( p );
} }
/** @brief register a plugin /** @brief register a plugin
@ -71,10 +75,10 @@ public:
* the Calamares createInstance() version which ignores * the Calamares createInstance() version which ignores
* the QVariantList of arguments. * the QVariantList of arguments.
*/ */
template<class T> template < class T >
void registerPlugin() void registerPlugin()
{ {
KPluginFactory::registerPlugin<T>(QString(), &createInstance<T, QObject>); KPluginFactory::registerPlugin< T >( QString(), &createInstance< T, QObject > );
} }
}; };
@ -84,18 +88,18 @@ public:
* except that does not actually use the base factory class that is * except that does not actually use the base factory class that is
* passed in. * passed in.
*/ */
#define CALAMARES_PLUGIN_FACTORY_DECLARATION(name) \ #define CALAMARES_PLUGIN_FACTORY_DECLARATION( name ) \
class name : public CalamaresPluginFactory \ class name : public CalamaresPluginFactory \
{ \ { \
Q_OBJECT \ Q_OBJECT \
Q_INTERFACES(KPluginFactory) \ Q_INTERFACES( KPluginFactory ) \
Q_PLUGIN_METADATA(IID CalamaresPluginFactory_iid) \ Q_PLUGIN_METADATA( IID CalamaresPluginFactory_iid ) \
public: \ public: \
explicit name(); \ explicit name(); \
~name(); \ ~name(); \
}; };
#define CALAMARES_PLUGIN_FACTORY_DEFINITION(name, pluginRegistrations) \ #define CALAMARES_PLUGIN_FACTORY_DEFINITION( name, pluginRegistrations ) \
K_PLUGIN_FACTORY_DEFINITION_WITH_BASEFACTORY(name,CalamaresPluginFactory,pluginRegistrations) K_PLUGIN_FACTORY_DEFINITION_WITH_BASEFACTORY( name, CalamaresPluginFactory, pluginRegistrations )
// Q_DECLARE_INTERFACE( Calamares::PluginFactory, CalamaresPluginFactory_iid ) // Q_DECLARE_INTERFACE( Calamares::PluginFactory, CalamaresPluginFactory_iid )