Commit 80b2d317 authored by LE BRETON Come's avatar LE BRETON Come

Removes debug, shortens path, adds nested namespace parameters.

parent 3886eb82
......@@ -36,10 +36,10 @@ int main(int argc, char **argv)
QObject::connect(&real_parameter, &dtk::d_real::valueChanged, [=] (QVariant v) {
double value = v.value<dtk::d_real>().value();
qDebug() << value;
qInfo() << value;
});
dtkWidgetsAbstractParameter *real_parameter_widget = dtk::widgets::pluginFactory().create(&real_parameter, "dtkWidgetsParameterDoubleSpinBoxPlugin");
dtkWidgetsAbstractParameter *real_parameter_widget = dtk::widgets::parameters::pluginFactory().create(&real_parameter, "dtkWidgetsParameterDoubleSpinBox");
window->setCentralWidget(real_parameter_widget);
......
......@@ -23,8 +23,7 @@
void dtkWidgetsParameterDoubleSpinBoxPlugin::initialize(void)
{
qDebug() << Q_FUNC_INFO;
dtk::widgets::pluginFactory().record("dtkWidgetsParameterDoubleSpinBoxPlugin", dtkWidgetsParameterDoubleSpinBoxCreator);
dtk::widgets::parameters::pluginFactory().record("dtkWidgetsParameterDoubleSpinBox", dtkWidgetsParameterDoubleSpinBoxCreator);
}
void dtkWidgetsParameterDoubleSpinBoxPlugin::uninitialize(void)
......
......@@ -16,12 +16,12 @@
#include <QtCore>
#include <dtkWidgets/dtkWidgetsParameter>
#include <dtkWidgets/dtkWidgetsParameterFactory.h>
class dtkWidgetsParameterDoubleSpinBoxPlugin : public dtkWidgetsAbstractParameterPlugin
class dtkWidgetsParameterDoubleSpinBoxPlugin : public dtkWidgetsParameterPlugin
{
Q_OBJECT
Q_INTERFACES(dtkWidgetsAbstractParameterPlugin);
Q_INTERFACES(dtkWidgetsParameterPlugin);
Q_PLUGIN_METADATA(IID "fr.inria.dtkWidgetsParameterDoubleSpinBoxPlugin" FILE "dtkWidgetsParameterDoubleSpinBoxPlugin.json")
public:
......
{
"name" : "dtkWidgetsParameterDoubleSpinBoxPlugin",
"concept" : "dtkWidgetsAbstractParameter",
"name" : "dtkWidgetsParameterDoubleSpinBox",
"concept" : "dtkWidgetsParameter",
"version" : "0.0.1",
"dependencies" : []
}
......@@ -22,14 +22,12 @@ namespace dtk {
QSettings geo_settings;
geo_settings.beginGroup("widgets");
realpath = geo_settings.value("plugins").toString();
qDebug() << "realpath" << realpath;
geo_settings.endGroup();
if (realpath.isEmpty()) {
realpath = QDir(DTK_WIDGETS_INSTALL_PREFIX).filePath("plugins/");
dtkDebug() << "no plugin path configured for dtkWidgets, use default:" << realpath ;
}
pathslist = realpath.split(":");
qDebug() << "pathslist" << pathslist;
}
else {
pathslist = realpath.split(":");
......
......@@ -26,9 +26,6 @@ class DTKWIDGETS_EXPORT dtkWidgetsAbstractParameter : public QWidget {
public:
dtkWidgetsAbstractParameter(QWidget *parent) : QWidget(parent) {};
virtual ~dtkWidgetsAbstractParameter() = default;
/* public: */
/* virtual void connect(dtkCoreAbstractParameter *) = 0; */
};
template <typename T>
......@@ -42,19 +39,6 @@ public:
};
DTK_DECLARE_OBJECT(dtkWidgetsAbstractParameter*);
DTK_DECLARE_PLUGIN(dtkWidgetsAbstractParameter, DTKWIDGETS_EXPORT);
DTK_DECLARE_PLUGIN_FACTORY(dtkWidgetsAbstractParameter, DTKWIDGETS_EXPORT);
DTK_DECLARE_PLUGIN_MANAGER(dtkWidgetsAbstractParameter, DTKWIDGETS_EXPORT);
// /////////////////////////////////////////////////////////////////
// Register to dtkDiscretegeometry layer
// /////////////////////////////////////////////////////////////////
namespace dtk {
namespace widgets {
DTK_DECLARE_CONCEPT(dtkWidgetsAbstractParameter, DTKWIDGETS_EXPORT, parameter);
}
}
//
// dtkWidgetsParameter.h ends here
......@@ -6,26 +6,29 @@ namespace dtk
{
namespace widgets
{
namespace _private
namespace parameters
{
dtkWidgetsParameterFactory factory;
dtkWidgetsAbstractParameterPluginManager manager;
}
namespace _private
{
dtkWidgetsParameterFactory factory;
dtkWidgetsParameterPluginManager manager;
}
dtkWidgetsParameterFactory& pluginFactory()
{
return _private::factory;
}
dtkWidgetsParameterFactory& pluginFactory()
{
return _private::factory;
}
dtkWidgetsAbstractParameterPluginManager& pluginManager()
{
return _private::manager;
}
dtkWidgetsParameterPluginManager& pluginManager()
{
return _private::manager;
}
namespace _private
{
dtkCorePluginManagerRecorder mrecorder(&dtk::widgets::manager(), &pluginManager(), "dtkWidgetsParameter");
dtkCorePluginFactoryRecorder frecorder(&dtk::widgets::manager(), &pluginFactory(), "dtkWidgetsParameter");
namespace _private
{
dtkCorePluginManagerRecorder mrecorder(&dtk::widgets::manager(), &pluginManager(), "dtkWidgetsParameter");
dtkCorePluginFactoryRecorder frecorder(&dtk::widgets::manager(), &pluginFactory(), "dtkWidgetsParameter");
}
}
}
}
......@@ -4,27 +4,44 @@
#include "dtkWidgetsParameter.h"
class DTKWIDGETS_EXPORT dtkWidgetsParameterFactory : public dtkWidgetsAbstractParameterPluginFactory {
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> {
public:
template <typename T>
dtkWidgetsAbstractParameter *create(dtkCoreParameter<T> *parameter, const QString& key) {
dtkWidgetsAbstractParameter *widget = dtkWidgetsAbstractParameterPluginFactory::create(key);
dtkWidgetsAbstractParameter *widget = dtkCorePluginFactory<dtkWidgetsAbstractParameter>::create(key);
if(!widget) {
qWarning() << "The widget with key :" << key << "could not be instanciated by the factory.";
return nullptr;
}
dtkWidgetsParameter<dtkCoreParameter<T>> *t_widget = dynamic_cast<dtkWidgetsParameter<dtkCoreParameter<T>> *>(widget);
if(t_widget) {
t_widget->connect(parameter);
return t_widget;
if(!t_widget) {
qWarning() << "The type of the parameter is not compatible with the plugin.";
return nullptr;
}
return nullptr;
t_widget->connect(parameter);
return t_widget;
}
};
namespace dtk
{
namespace widgets
{
DTKWIDGETS_EXPORT dtkWidgetsParameterFactory& pluginFactory();
DTKWIDGETS_EXPORT dtkWidgetsAbstractParameterPluginManager& pluginManager();
// /////////////////////////////////////////////////////////////////
// Register to dtkDiscretegeometry layer
// /////////////////////////////////////////////////////////////////
namespace dtk {
namespace widgets {
namespace parameters {
DTKWIDGETS_EXPORT dtkWidgetsParameterFactory& pluginFactory();
DTKWIDGETS_EXPORT dtkWidgetsParameterPluginManager& pluginManager();
}
}
}
......@@ -62,17 +62,11 @@ void dtkWidgetsParameterTestCase::init(void)
void dtkWidgetsParameterTestCase::testBasic(void)
{
dtk::d_real real_parameter;
dtk::d_real real_parameter = 0.;
dtkWidgetsAbstractParameter *spin_box = dtk::widgets::pluginFactory().create(&real_parameter, "dtkWidgetsParameterDoubleSpinBoxPlugin");
dtkWidgetsAbstractParameter *spin_box = dtk::widgets::parameters::pluginFactory().create(&real_parameter, "dtkWidgetsParameterDoubleSpinBox");
qDebug() << "spin_box" << spin_box;
// QWidget *spin_box = real_parameter->create("spin_box");
// QVERIFY(spin_box);
// QVariant var = concept->output();
Q_ASSERT(spin_box);
}
void dtkWidgetsParameterTestCase::cleanup(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment