dtkWidgetsParameterFactory.h 1.49 KB
Newer Older
1 2 3 4 5 6
#pragma once

#include<dtkWidgetsExport.h>

#include "dtkWidgetsParameter.h"

7 8 9 10 11 12 13 14
class DTKWIDGETS_EXPORT dtkWidgetsParameterPlugin : public dtkCorePluginBase {};

Q_DECLARE_METATYPE(dtkWidgetsParameterPlugin*);
Q_DECLARE_INTERFACE(dtkWidgetsParameterPlugin, DTK_DECLARE_PLUGIN_INTERFACE(dtkWidgetsParameterPlugin));

class DTKWIDGETS_EXPORT dtkWidgetsParameterPluginManager : public dtkCorePluginManager<dtkWidgetsParameterPlugin> {};

class DTKWIDGETS_EXPORT dtkWidgetsParameterFactory : public dtkCorePluginFactory<dtkWidgetsAbstractParameter> {
15
public:
16 17
    dtkWidgetsAbstractParameter *create(dtkCoreAbstractParameter *parameter, const QString& key) {

18
        dtkWidgetsAbstractParameter *widget = dtkCorePluginFactory<dtkWidgetsAbstractParameter>::create(key);
19

20 21 22 23
        if(!widget) {
            qWarning() << "The widget with key :" << key << "could not be instanciated by the factory.";
            return nullptr;
        }
24

25 26
        if(!widget->connect(parameter)) {
            qWarning() << "The parameter could not be connected to the widget.";
27 28
        }

29
        return widget;
30 31 32
    }
};

33 34 35 36 37 38 39 40 41 42
// /////////////////////////////////////////////////////////////////
// Register to dtkDiscretegeometry layer
// /////////////////////////////////////////////////////////////////

namespace dtk {
    namespace widgets {
        namespace parameters {
            DTKWIDGETS_EXPORT dtkWidgetsParameterFactory& pluginFactory();
            DTKWIDGETS_EXPORT dtkWidgetsParameterPluginManager& pluginManager();
        }
43 44
    }
}