Commit 9b7c55b9 authored by Julien Wintz's avatar Julien Wintz
Browse files

Refactor dtkConceptGenerator.

parent 36632259
......@@ -24,10 +24,7 @@ endif(DTK_BUILD_DISTRIBUTED AND DTK_BUILD_WIDGETS)
add_subdirectory(dtkPluginsMetaInfoFetcher)
add_subdirectory(dtkDeploy)
if(DTK_BUILD_SUPPORT_GUI)
add_subdirectory(dtkConceptGenerator)
endif(DTK_BUILD_SUPPORT_GUI)
add_subdirectory(dtkConceptGenerator)
######################################################################
### CMakeLists.txt ends here
### CMakeLists.txt ---
##
## Author: Julien Wintz
## Copyright (C) 2008 - Julien Wintz, Inria.
## Created: Mon Aug 3 17:34:51 2009 (+0200)
## Version: $Id$
## Last-Updated: Fri Apr 27 21:31:54 2012 (+0200)
## By: Julien Wintz
## Update #: 171
##
######################################################################
##
### Commentary:
##
######################################################################
##
### Change log:
### Change Log:
##
######################################################################
##
### Code:
project(dtkConceptGenerator)
......@@ -55,11 +50,8 @@ set(${PROJECT_NAME}_RESOURCES
## Build rules
## #################################################################
if(NOT MSVC)
add_definitions(-Wno-write-strings)
endif(NOT MSVC)
qt5_add_resources(${PROJECT_NAME}_SOURCES_QRC ${${PROJECT_NAME}_RESOURCES})
qt5_add_RESOURCES(${PROJECT_NAME}_SOURCES_QRC ${${PROJECT_NAME}_RESOURCES})
qt5_wrap_ui(${PROJECT_NAME}_UI_HEADERS ${${PROJECT_NAME}_UI})
add_executable(${PROJECT_NAME} MACOSX_BUNDLE WIN32
......@@ -72,10 +64,6 @@ target_link_libraries(${PROJECT_NAME}
dtkLog
dtkCore)
if(APPLE)
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
endif(APPLE)
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
......@@ -92,3 +80,6 @@ install(FILES ${${PROJECT_NAME}_MODULES} DESTINATION modules)
install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION bin
RUNTIME DESTINATION bin)
######################################################################
### CMakeLists.txt ends here
#include "dtkConceptDefinitionPage.h"
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkConceptDefinitionPage.h"
#include "ui_dtkConceptDefinitionPage.h"
dtkConceptDefinitionPage::dtkConceptDefinitionPage(QWidget *parent) :
QWizardPage(parent),
ui(new Ui::dtkConceptDefinitionPage)
dtkConceptDefinitionPage::dtkConceptDefinitionPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkConceptDefinitionPage)
{
ui->setupUi(this);
registerField("def.runnable",ui->m_runnable);
registerField("def.qObject",ui->m_qObject);
registerField("def.custom",ui->m_custom);
registerField("def.customName",ui->m_customName);
registerField("def.pluginSystem",ui->m_pluginSystem);
this->ui->setupUi(this);
this->registerField("def.runnable",ui->m_runnable);
this->registerField("def.qObject",ui->m_qObject);
this->registerField("def.custom",ui->m_custom);
this->registerField("def.customName",ui->m_customName);
this->registerField("def.pluginSystem",ui->m_pluginSystem);
}
dtkConceptDefinitionPage::~dtkConceptDefinitionPage()
dtkConceptDefinitionPage::~dtkConceptDefinitionPage(void)
{
delete ui;
delete this->ui;
}
//
// dtkConceptDefinitionPage.cpp ends here
#ifndef dtkConceptDefinitionPage_H
#define dtkConceptDefinitionPage_H
// Version: $Id$
//
//
#include <QWizardPage>
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtWidgets>
namespace Ui {
class dtkConceptDefinitionPage;
class dtkConceptDefinitionPage;
}
class dtkConceptDefinitionPage : public QWizardPage
......@@ -12,11 +25,12 @@ class dtkConceptDefinitionPage : public QWizardPage
Q_OBJECT
public:
explicit dtkConceptDefinitionPage(QWidget *parent = 0);
dtkConceptDefinitionPage(QWidget *parent = 0);
~dtkConceptDefinitionPage();
private:
Ui::dtkConceptDefinitionPage *ui;
};
#endif // dtkConceptDefinitionPage_H
//
// dtkConceptDefinitionPage.h ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkConceptDefinitionPage.h"
#include "dtkNewConceptPage.h"
#include "dtkPluginGeneratorPage.h"
#include "dtkIntroPage.h"
#include "generator.h"
#include "dtkConceptGenerator.h"
dtkConceptGenerator::dtkConceptGenerator()
dtkConceptGenerator::dtkConceptGenerator(void) : QWizard()
{
addPage(new dtkIntroPage());
addPage(new dtkNewConceptPage());
addPage(new dtkConceptDefinitionPage());
addPage(new dtkPluginGeneratorPage());
this->addPage(new dtkIntroPage);
this->addPage(new dtkNewConceptPage);
this->addPage(new dtkConceptDefinitionPage);
this->addPage(new dtkPluginGeneratorPage);
}
void dtkConceptGenerator::accept()
void dtkConceptGenerator::accept(void)
{
QString name=field("new.name" ).toString();
QString prefix=field("new.prefix" ).toString();
......@@ -21,77 +42,69 @@ void dtkConceptGenerator::accept()
QString outputFilesPath=field("intro.path" ).toString();
QMap<QString,QString> values;
//define variables required for abstraction
// define variables required for abstraction
values.insert("${ABSTRACTION}", prefix+"Abstract"+name);
values.insert("${LAYER_NAME}", prefix+layer);
values.insert("${_LAYER_NAME}", (prefix+layer).toUpper());
bool inheritsCustom,inheritsQObject,inheritsQRunnable,pluginSystem, inherits=false;
bool inheritsCustom, inheritsQObject, inheritsQRunnable, pluginSystem, inherits=false;
inheritsQRunnable=field("def.runnable" ).toBool();
inheritsQObject =field("def.qObject" ).toBool();
inheritsCustom =field("def.custom" ).toBool();
pluginSystem =field("def.pluginSystem").toBool();
if(inheritsQObject)
{
if(inheritsQObject) {
values.insert("${QOBJECT}","QObject");
values.insert("${QOBJECT_INCLUDE}","#include <QObject>");
values.insert("${QOBJECT_CTR}","QObject(parent)");
values.insert("${QOBJECT_CTR_PARAM}","QObject* parent=0");
values.insert("${Q_OBJECT_MACRO}","Q_OBJECT");
inherits=true;
}
else
{
} else {
values.insert("${QOBJECT}","");
values.insert("${QOBJECT_INCLUDE}","");
values.insert("${QOBJECT_CTR}","");
values.insert("${QOBJECT_CTR_PARAM}","");
values.insert("${Q_OBJECT_MACRO}","");
}
if(inheritsQRunnable)
{
QString separator=inherits?",": "";
if(inheritsQRunnable) {
QString separator = inherits ? "," : "";
values.insert("${QRUNNABLE}",separator+"public QRunnable");
values.insert("${QRUNNABLE_CTR}",separator+"QRunnable()");
values.insert("${QRUNNABLE_INCLUDE}","#include <QRunnable>");
inherits=true;
}
else
{
} else {
values.insert("${QRUNNABLE}","");
values.insert("${QRUNNABLE_CTR}","");
values.insert("${QRUNNABLE_INCLUDE}","");
}
if(inheritsCustom)
{
if(inheritsCustom) {
QString separator=inherits?",": "";
values.insert("${CUSTOM_ANCESTOR}",separator+customName);
values.insert("${CUSTOM_ANCESTOR_CTR}",separator+customName);
values.insert("${CUSTOM_ANCESTOR_INCLUDE}","#include \""+customName+"\"");
inherits=true;
}
else
{
} else {
values.insert("${CUSTOM_ANCESTOR}","");
values.insert("${CUSTOM_ANCESTOR_CTR}","");
values.insert("${CUSTOM_ANCESTOR_INCLUDE}","");
}
if(pluginSystem)
{
if(pluginSystem) {
QString macroParams="("+values["${ABSTRACTION}"]+", "+values["${_LAYER_NAME}"]+"_EXPORT)";
values.insert("${PLUGIN_SYSTEM}",
"DTK_DECLARE_PLUGIN "+macroParams + "\n" +
"DTK_DECLARE_PLUGIN_FACTORY"+macroParams + "\n" +
......@@ -99,18 +112,18 @@ void dtkConceptGenerator::accept()
}
//values for plugins
values.insert("${PLUGIN_CLASS_NAME}",pluginPrefix+name+pluginSuffix);
values.insert("${NAMESPACE}",namespaceText);
//values for node
values.insert("${NODE_CLASS_NAME}",prefix+name+"Node");
generate("abstraction",values,outputFilesPath);
generate("plugin",values,outputFilesPath);
generate("node",values,outputFilesPath);
QWizard::accept();
}
//
// dtkConceptGenerator.cpp ends here
#ifndef DTKCONCEPTGENERATOR_H
#define DTKCONCEPTGENERATOR_H
// Version: $Id$
//
//
#include <QWizard>
#include <QVariant>
// Commentary:
//
//
#include "dtkConceptDefinitionPage.h"
#include "dtkNewConceptPage.h"
#include "dtkPluginGeneratorPage.h"
#include "dtkIntroPage.h"
// Change Log:
//
//
#include "generator.h"
// Code:
#pragma once
#include <QtWidgets>
class dtkConceptGenerator : public QWizard
{
public:
dtkConceptGenerator();
void accept();
dtkConceptGenerator(void);
public:
void accept(void);
};
#endif // DTKCONCEPTGENERATOR_H
//
// dtkConceptGenerator.h ends here
#include "dtkIntroPage.h"
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkIntroPage.h"
#include "ui_dtkIntroPage.h"
dtkIntroPage::dtkIntroPage(QWidget *parent) :
QWizardPage(parent),
ui(new Ui::dtkIntroPage)
dtkIntroPage::dtkIntroPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkIntroPage)
{
ui->setupUi(this);
registerField("intro.path" ,ui->m_path );
connect(ui->m_browse,SIGNAL(clicked(bool)),this,SLOT(browse()));
this->ui->setupUi(this);
this->registerField("intro.path", ui->m_path);
this->connect(ui->m_browse,SIGNAL(clicked(bool)),this,SLOT(browse()));
}
void dtkIntroPage::browse()
void dtkIntroPage::browse(void)
{
ui->m_path->setText(QFileDialog::getExistingDirectory(this,"Save"));
this->ui->m_path->setText(QFileDialog::getExistingDirectory(this,"Save"));
}
dtkIntroPage::~dtkIntroPage()
dtkIntroPage::~dtkIntroPage(void)
{
delete ui;
delete this->ui;
}
//
// dtkIntroPage.cpp ends here
#ifndef DTKINTROPAGE_H
#define DTKINTROPAGE_H
// Version: $Id$
//
//
#include <QWizardPage>
#include <QFileDialog>
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtWidgets>
namespace Ui {
class dtkIntroPage;
class dtkIntroPage;
}
class dtkIntroPage : public QWizardPage
......@@ -13,11 +25,11 @@ class dtkIntroPage : public QWizardPage
Q_OBJECT
public:
explicit dtkIntroPage(QWidget *parent = 0);
~dtkIntroPage();
dtkIntroPage(QWidget *parent = 0);
~dtkIntroPage(void);
public slots:
void browse();
void browse(void);
signals:
void generatorSet(QString);
......@@ -26,4 +38,5 @@ private:
Ui::dtkIntroPage *ui;
};
#endif // dtkIntroPage_H
//
// dtkIntroPage.h ends here
#include "dtkNewConceptPage.h"
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkNewConceptPage.h"
#include "ui_dtkNewConceptPage.h"
dtkNewConceptPage::dtkNewConceptPage(QWidget *parent) :
QWizardPage(parent),
ui(new Ui::dtkNewConceptPage)
dtkNewConceptPage::dtkNewConceptPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkNewConceptPage)
{
ui->setupUi(this);
registerField("new.layer",ui->m_layer);
......@@ -17,3 +29,6 @@ dtkNewConceptPage::~dtkNewConceptPage()
{
delete ui;
}
//
// dtkNewConceptPage.cpp ends here
#ifndef DTKNEWCONCEPTPAGE_H
#define DTKNEWCONCEPTPAGE_H
// Version: $Id$
//
//
#include <QWizardPage>
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtWidgets>
namespace Ui {
class dtkNewConceptPage;
class dtkNewConceptPage;
}
class dtkNewConceptPage : public QWizardPage
......@@ -12,11 +25,12 @@ class dtkNewConceptPage : public QWizardPage
Q_OBJECT
public:
explicit dtkNewConceptPage(QWidget *parent = 0);
~dtkNewConceptPage();
dtkNewConceptPage(QWidget *parent = 0);
~dtkNewConceptPage(void);
private:
Ui::dtkNewConceptPage *ui;
};
#endif // DTKNEWCONCEPTPAGE_H
//
// dtkNewConceptPage.h ends here
#include "dtkPluginGeneratorPage.h"
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkPluginGeneratorPage.h"
#include "ui_dtkPluginGeneratorPage.h"
dtkPluginGeneratorPage::dtkPluginGeneratorPage(QWidget *parent) :
QWizardPage(parent),
ui(new Ui::dtkPluginGeneratorPage)
dtkPluginGeneratorPage::dtkPluginGeneratorPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkPluginGeneratorPage)
{
ui->setupUi(this);
registerField("plugin.prefix",ui->m_prefix);
......@@ -13,18 +25,21 @@ dtkPluginGeneratorPage::dtkPluginGeneratorPage(QWidget *parent) :
connect(ui->m_suffix,SIGNAL(textChanged(QString)),this,SLOT(refresh()));
}
void dtkPluginGeneratorPage::initializePage()
dtkPluginGeneratorPage::~dtkPluginGeneratorPage(void)
{
delete ui;
}
void dtkPluginGeneratorPage::initializePage(void)
{
ui->m_prefix->setText(field("new.prefix").toString());
ui->m_name->setText(ui->m_prefix->text()+field("new.name").toString());
}
void dtkPluginGeneratorPage::refresh()
void dtkPluginGeneratorPage::refresh(void)
{
ui->m_name->setText(ui->m_prefix->text()+field("new.name").toString()+ui->m_suffix->text());
}
dtkPluginGeneratorPage::~dtkPluginGeneratorPage()
{
delete ui;
}
//
// dtkPluginGeneratorPage.cpp ends here
#ifndef DTKPLUGINGENERATORPAGE_H
#define DTKPLUGINGENERATORPAGE_H
// Version: $Id$
//
//
#include <QWizardPage>
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtWidgets>
namespace Ui {
class dtkPluginGeneratorPage;
class dtkPluginGeneratorPage;
}
class dtkPluginGeneratorPage : public QWizardPage
......@@ -12,17 +25,19 @@ class dtkPluginGeneratorPage : public QWizardPage