Commit 95b60c89 authored by Julien Wintz's avatar Julien Wintz

Formatting code following our latest conventions.

parent 545dc980
...@@ -78,15 +78,21 @@ int main(int argc, char **argv) ...@@ -78,15 +78,21 @@ int main(int argc, char **argv)
if (parser->isSet(slaveOption)) { if (parser->isSet(slaveOption)) {
dtkComposerEvaluatorSlave *slave = new dtkComposerEvaluatorSlave; dtkComposerEvaluatorSlave *slave = new dtkComposerEvaluatorSlave;
if (!parser->isSet(serverOption)) { if (!parser->isSet(serverOption)) {
qCritical() << "Error: no server set when running as slave! Use --server <url> " ; qCritical() << "Error: no server set when running as slave! Use --server <url> " ;
return 1; return 1;
} }
slave->setServer(parser->value(serverOption)); slave->setServer(parser->value(serverOption));
slave->setFactory(factory); slave->setFactory(factory);
application->spawn(); application->spawn();
do { application->exec(slave); } while (slave->status() == 0);
do {
application->exec(slave);
} while (slave->status() == 0);
application->unspawn(); application->unspawn();
} else { } else {
...@@ -103,15 +109,17 @@ int main(int argc, char **argv) ...@@ -103,15 +109,17 @@ int main(int argc, char **argv)
if (parser->isSet(pgOption)) { if (parser->isSet(pgOption)) {
evaluator->setProfiling(true); evaluator->setProfiling(true);
} }
if (!reader->read(args.first())) { if (!reader->read(args.first())) {
dtkError() << "read failure for " << args.first(); dtkError() << "read failure for " << args.first();
return 1; return 1;
} }
if (no_gui) { if (no_gui) {
evaluator->run_static(); evaluator->run_static();
return 0; return 0;
} else { } else {
QObject::connect(evaluator,SIGNAL(evaluationStopped()),qApp, SLOT(quit())); QObject::connect(evaluator, SIGNAL(evaluationStopped()), qApp, SLOT(quit()));
QtConcurrent::run(evaluator, &dtkComposerEvaluator::run_static, false); QtConcurrent::run(evaluator, &dtkComposerEvaluator::run_static, false);
return qApp->exec(); return qApp->exec();
} }
......
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
dtkConceptDefinitionPage::dtkConceptDefinitionPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkConceptDefinitionPage) dtkConceptDefinitionPage::dtkConceptDefinitionPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkConceptDefinitionPage)
{ {
this->ui->setupUi(this); this->ui->setupUi(this);
this->registerField("def.runnable",ui->m_runnable); this->registerField("def.runnable", ui->m_runnable);
this->registerField("def.qObject",ui->m_qObject); this->registerField("def.qObject", ui->m_qObject);
this->registerField("def.custom",ui->m_custom); this->registerField("def.custom", ui->m_custom);
this->registerField("def.customName",ui->m_customName); this->registerField("def.customName", ui->m_customName);
this->registerField("def.pluginSystem",ui->m_pluginSystem); this->registerField("def.pluginSystem", ui->m_pluginSystem);
} }
dtkConceptDefinitionPage::~dtkConceptDefinitionPage(void) dtkConceptDefinitionPage::~dtkConceptDefinitionPage(void)
......
...@@ -31,96 +31,96 @@ dtkConceptGenerator::dtkConceptGenerator(void) : QWizard() ...@@ -31,96 +31,96 @@ dtkConceptGenerator::dtkConceptGenerator(void) : QWizard()
void dtkConceptGenerator::accept(void) void dtkConceptGenerator::accept(void)
{ {
QString name=field("new.name" ).toString(); QString name = field("new.name" ).toString();
QString prefix=field("new.prefix" ).toString(); QString prefix = field("new.prefix" ).toString();
QString layer=field("new.layer" ).toString(); QString layer = field("new.layer" ).toString();
QString namespaceText=field("new.namespace" ).toString(); QString namespaceText = field("new.namespace" ).toString();
QString customName=field("def.customName" ).toString(); QString customName = field("def.customName" ).toString();
QString pluginPrefix=field("plugin.prefix" ).toString(); QString pluginPrefix = field("plugin.prefix" ).toString();
QString pluginSuffix=field("plugin.suffix" ).toString(); QString pluginSuffix = field("plugin.suffix" ).toString();
QString outputFilesPath=field("intro.path" ).toString(); QString outputFilesPath = field("intro.path" ).toString();
QMap<QString,QString> values; QMap<QString, QString> values;
// define variables required for abstraction // define variables required for abstraction
values.insert("${ABSTRACTION}", prefix+"Abstract"+name); values.insert("${ABSTRACTION}", prefix + "Abstract" + name);
values.insert("${LAYER_NAME}", prefix+layer); values.insert("${LAYER_NAME}", prefix + layer);
values.insert("${_LAYER_NAME}", (prefix+layer).toUpper()); 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(); inheritsQRunnable = field("def.runnable" ).toBool();
inheritsQObject =field("def.qObject" ).toBool(); inheritsQObject = field("def.qObject" ).toBool();
inheritsCustom =field("def.custom" ).toBool(); inheritsCustom = field("def.custom" ).toBool();
pluginSystem =field("def.pluginSystem").toBool(); pluginSystem = field("def.pluginSystem").toBool();
if(inheritsQObject) { if (inheritsQObject) {
values.insert("${QOBJECT}","QObject"); values.insert("${QOBJECT}", "QObject");
values.insert("${QOBJECT_INCLUDE}","#include <QObject>"); values.insert("${QOBJECT_INCLUDE}", "#include <QObject>");
values.insert("${QOBJECT_CTR}","QObject(parent)"); values.insert("${QOBJECT_CTR}", "QObject(parent)");
values.insert("${QOBJECT_CTR_PARAM}","QObject* parent=0"); values.insert("${QOBJECT_CTR_PARAM}", "QObject* parent=0");
values.insert("${Q_OBJECT_MACRO}","Q_OBJECT"); values.insert("${Q_OBJECT_MACRO}", "Q_OBJECT");
inherits=true; inherits = true;
} else { } else {
values.insert("${QOBJECT}",""); values.insert("${QOBJECT}", "");
values.insert("${QOBJECT_INCLUDE}",""); values.insert("${QOBJECT_INCLUDE}", "");
values.insert("${QOBJECT_CTR}",""); values.insert("${QOBJECT_CTR}", "");
values.insert("${QOBJECT_CTR_PARAM}",""); values.insert("${QOBJECT_CTR_PARAM}", "");
values.insert("${Q_OBJECT_MACRO}",""); values.insert("${Q_OBJECT_MACRO}", "");
} }
if(inheritsQRunnable) { if (inheritsQRunnable) {
QString separator = inherits ? "," : ""; QString separator = inherits ? "," : "";
values.insert("${QRUNNABLE}",separator+"public QRunnable"); values.insert("${QRUNNABLE}", separator + "public QRunnable");
values.insert("${QRUNNABLE_CTR}",separator+"QRunnable()"); values.insert("${QRUNNABLE_CTR}", separator + "QRunnable()");
values.insert("${QRUNNABLE_INCLUDE}","#include <QRunnable>"); values.insert("${QRUNNABLE_INCLUDE}", "#include <QRunnable>");
inherits=true; inherits = true;
} else { } else {
values.insert("${QRUNNABLE}",""); values.insert("${QRUNNABLE}", "");
values.insert("${QRUNNABLE_CTR}",""); values.insert("${QRUNNABLE_CTR}", "");
values.insert("${QRUNNABLE_INCLUDE}",""); values.insert("${QRUNNABLE_INCLUDE}", "");
} }
if(inheritsCustom) { if (inheritsCustom) {
QString separator=inherits?",": ""; QString separator = inherits ? "," : "";
values.insert("${CUSTOM_ANCESTOR}",separator+customName); values.insert("${CUSTOM_ANCESTOR}", separator + customName);
values.insert("${CUSTOM_ANCESTOR_CTR}",separator+customName); values.insert("${CUSTOM_ANCESTOR_CTR}", separator + customName);
values.insert("${CUSTOM_ANCESTOR_INCLUDE}","#include \""+customName+"\""); values.insert("${CUSTOM_ANCESTOR_INCLUDE}", "#include \"" + customName + "\"");
inherits=true; inherits = true;
} else { } else {
values.insert("${CUSTOM_ANCESTOR}",""); values.insert("${CUSTOM_ANCESTOR}", "");
values.insert("${CUSTOM_ANCESTOR_CTR}",""); values.insert("${CUSTOM_ANCESTOR_CTR}", "");
values.insert("${CUSTOM_ANCESTOR_INCLUDE}",""); values.insert("${CUSTOM_ANCESTOR_INCLUDE}", "");
} }
if(pluginSystem) { if (pluginSystem) {
QString macroParams="("+values["${ABSTRACTION}"]+", "+values["${_LAYER_NAME}"]+"_EXPORT)"; QString macroParams = "(" + values["${ABSTRACTION}"] + ", " + values["${_LAYER_NAME}"] + "_EXPORT)";
values.insert("${PLUGIN_SYSTEM}", values.insert("${PLUGIN_SYSTEM}",
"DTK_DECLARE_PLUGIN "+macroParams + "\n" + "DTK_DECLARE_PLUGIN " + macroParams + "\n" +
"DTK_DECLARE_PLUGIN_FACTORY"+macroParams + "\n" + "DTK_DECLARE_PLUGIN_FACTORY" + macroParams + "\n" +
"DTK_DECLARE_PLUGIN_MANAGER"+macroParams); "DTK_DECLARE_PLUGIN_MANAGER" + macroParams);
} }
//values for plugins //values for plugins
values.insert("${PLUGIN_CLASS_NAME}",pluginPrefix+name+pluginSuffix); values.insert("${PLUGIN_CLASS_NAME}", pluginPrefix + name + pluginSuffix);
values.insert("${NAMESPACE}",namespaceText); values.insert("${NAMESPACE}", namespaceText);
//values for node //values for node
values.insert("${NODE_CLASS_NAME}",prefix+name+"Node"); values.insert("${NODE_CLASS_NAME}", prefix + name + "Node");
generate("abstraction",values,outputFilesPath); generate("abstraction", values, outputFilesPath);
generate("plugin",values,outputFilesPath); generate("plugin", values, outputFilesPath);
generate("node",values,outputFilesPath); generate("node", values, outputFilesPath);
QWizard::accept(); QWizard::accept();
} }
......
...@@ -19,12 +19,12 @@ dtkIntroPage::dtkIntroPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dt ...@@ -19,12 +19,12 @@ dtkIntroPage::dtkIntroPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dt
{ {
this->ui->setupUi(this); this->ui->setupUi(this);
this->registerField("intro.path", ui->m_path); this->registerField("intro.path", ui->m_path);
this->connect(ui->m_browse,SIGNAL(clicked(bool)),this,SLOT(browse())); this->connect(ui->m_browse, SIGNAL(clicked(bool)), this, SLOT(browse()));
} }
void dtkIntroPage::browse(void) void dtkIntroPage::browse(void)
{ {
this->ui->m_path->setText(QFileDialog::getExistingDirectory(this,"Save")); this->ui->m_path->setText(QFileDialog::getExistingDirectory(this, "Save"));
} }
dtkIntroPage::~dtkIntroPage(void) dtkIntroPage::~dtkIntroPage(void)
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
dtkNewConceptPage::dtkNewConceptPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkNewConceptPage) dtkNewConceptPage::dtkNewConceptPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkNewConceptPage)
{ {
ui->setupUi(this); ui->setupUi(this);
registerField("new.layer",ui->m_layer); registerField("new.layer", ui->m_layer);
registerField("new.namespace",ui->m_namespace); registerField("new.namespace", ui->m_namespace);
registerField("new.prefix",ui->m_prefix); registerField("new.prefix", ui->m_prefix);
registerField("new.name",ui->m_name); registerField("new.name", ui->m_name);
} }
......
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
dtkPluginGeneratorPage::dtkPluginGeneratorPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkPluginGeneratorPage) dtkPluginGeneratorPage::dtkPluginGeneratorPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkPluginGeneratorPage)
{ {
ui->setupUi(this); ui->setupUi(this);
registerField("plugin.prefix",ui->m_prefix); registerField("plugin.prefix", ui->m_prefix);
registerField("plugin.suffix",ui->m_suffix); registerField("plugin.suffix", ui->m_suffix);
registerField("plugin.name",ui->m_name); registerField("plugin.name", ui->m_name);
connect(ui->m_prefix,SIGNAL(textChanged(QString)),this,SLOT(refresh())); connect(ui->m_prefix, SIGNAL(textChanged(QString)), this, SLOT(refresh()));
connect(ui->m_suffix,SIGNAL(textChanged(QString)),this,SLOT(refresh())); connect(ui->m_suffix, SIGNAL(textChanged(QString)), this, SLOT(refresh()));
} }
dtkPluginGeneratorPage::~dtkPluginGeneratorPage(void) dtkPluginGeneratorPage::~dtkPluginGeneratorPage(void)
...@@ -32,13 +32,13 @@ dtkPluginGeneratorPage::~dtkPluginGeneratorPage(void) ...@@ -32,13 +32,13 @@ dtkPluginGeneratorPage::~dtkPluginGeneratorPage(void)
void dtkPluginGeneratorPage::initializePage(void) void dtkPluginGeneratorPage::initializePage(void)
{ {
ui->m_prefix->setText(field("new.prefix").toString()); ui->m_prefix->setText(field("new.prefix").toString());
ui->m_name->setText(ui->m_prefix->text()+field("new.name").toString()); ui->m_name->setText(ui->m_prefix->text() + field("new.name").toString());
} }
void dtkPluginGeneratorPage::refresh(void) void dtkPluginGeneratorPage::refresh(void)
{ {
ui->m_name->setText(ui->m_prefix->text()+field("new.name").toString()+ui->m_suffix->text()); ui->m_name->setText(ui->m_prefix->text() + field("new.name").toString() + ui->m_suffix->text());
} }
// //
......
...@@ -14,26 +14,25 @@ ...@@ -14,26 +14,25 @@
#include "generator.h" #include "generator.h"
void generate(QString target, QMap<QString,QString> pairs, QString path) void generate(QString target, QMap<QString, QString> pairs, QString path)
{ {
QDir dirIn(":/templates/templates/"+target); QDir dirIn(":/templates/templates/" + target);
QDir dirOut=QDir(path); QDir dirOut = QDir(path);
dirOut.mkdir(target); dirOut.mkdir(target);
dirOut.cd(target); dirOut.cd(target);
qDebug()<<dirIn; qDebug() << dirIn;
QStringList files=dirIn.entryList(QDir::Files); QStringList files = dirIn.entryList(QDir::Files);
for(QString file : files) for (QString file : files) {
{ QString inFilePath = dirIn.absoluteFilePath(file);
QString inFilePath=dirIn.absoluteFilePath(file); QString fileOutPath = dirOut.absolutePath() + "/" + file.replace("class", pairs["${PLUGIN_CLASS_NAME}"]).replace("_", ".");
QString fileOutPath=dirOut.absolutePath()+"/"+file.replace("class",pairs["${PLUGIN_CLASS_NAME}"]).replace("_", ".");
QFile fileOut(fileOutPath); QFile fileOut(fileOutPath);
if (!fileOut.open(QIODevice::WriteOnly | QIODevice::Text)) if (!fileOut.open(QIODevice::WriteOnly | QIODevice::Text))
return; return;
QTextStream out(&fileOut); QTextStream out(&fileOut);
...@@ -41,7 +40,7 @@ void generate(QString target, QMap<QString,QString> pairs, QString path) ...@@ -41,7 +40,7 @@ void generate(QString target, QMap<QString,QString> pairs, QString path)
} }
} }
QString readAndReplace(QString filePath, QMap<QString,QString> pairs) QString readAndReplace(QString filePath, QMap<QString, QString> pairs)
{ {
QFile file(filePath); QFile file(filePath);
...@@ -50,10 +49,10 @@ QString readAndReplace(QString filePath, QMap<QString,QString> pairs) ...@@ -50,10 +49,10 @@ QString readAndReplace(QString filePath, QMap<QString,QString> pairs)
QTextStream in(&file); QTextStream in(&file);
QString content=in.readAll(); QString content = in.readAll();
for(QString key:pairs.keys()) for (QString key : pairs.keys())
content=content.replace(key,pairs[key]); content = content.replace(key, pairs[key]);
return content; return content;
} }
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#include <QtCore> #include <QtCore>
#include <QtDebug> #include <QtDebug>
void generate(QString target,QMap<QString, QString> pairs,QString path); void generate(QString target, QMap<QString, QString> pairs, QString path);
QString readAndReplace(QString filePath, QMap<QString,QString> pairs); QString readAndReplace(QString filePath, QMap<QString, QString> pairs);
// //
// generator.h ends here // generator.h ends here
...@@ -25,12 +25,12 @@ int logLevel = 1; ...@@ -25,12 +25,12 @@ int logLevel = 1;
using std::cout; using std::cout;
using std::endl; using std::endl;
bool operator==(const FrameworkInfo &a, const FrameworkInfo &b) bool operator==(const FrameworkInfo& a, const FrameworkInfo& b)
{ {
return ((a.frameworkPath == b.frameworkPath) && (a.binaryPath == b.binaryPath)); return ((a.frameworkPath == b.frameworkPath) && (a.binaryPath == b.binaryPath));
} }
QDebug operator<<(QDebug debug, const FrameworkInfo &info) QDebug operator<<(QDebug debug, const FrameworkInfo& info)
{ {
debug << "Framework name" << info.frameworkName << "\n"; debug << "Framework name" << info.frameworkName << "\n";
debug << "Framework directory" << info.frameworkDirectory << "\n"; debug << "Framework directory" << info.frameworkDirectory << "\n";
...@@ -50,14 +50,14 @@ QDebug operator<<(QDebug debug, const FrameworkInfo &info) ...@@ -50,14 +50,14 @@ QDebug operator<<(QDebug debug, const FrameworkInfo &info)
const QString bundleFrameworkDirectory = "Contents/Frameworks"; const QString bundleFrameworkDirectory = "Contents/Frameworks";
const QString bundleBinaryDirectory = "Contents/MacOS"; const QString bundleBinaryDirectory = "Contents/MacOS";
inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info) inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo& info)
{ {
debug << "Application bundle path" << info.path << "\n"; debug << "Application bundle path" << info.path << "\n";
debug << "Binary path" << info.binaryPath << "\n"; debug << "Binary path" << info.binaryPath << "\n";
return debug; return debug;
} }
bool copyFilePrintStatus(const QString &from, const QString &to) bool copyFilePrintStatus(const QString& from, const QString& to)
{ {
if (QFile::copy(from, to)) { if (QFile::copy(from, to)) {
LogNormal() << " copied:" << from; LogNormal() << " copied:" << from;
...@@ -70,7 +70,7 @@ bool copyFilePrintStatus(const QString &from, const QString &to) ...@@ -70,7 +70,7 @@ bool copyFilePrintStatus(const QString &from, const QString &to)
} }
} }
FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs) FrameworkInfo parseOtoolLibraryLine(const QString& line, bool useDebugLibs)
{ {
FrameworkInfo info; FrameworkInfo info;
QString trimmed = line.trimmed(); QString trimmed = line.trimmed();
...@@ -80,8 +80,8 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs) ...@@ -80,8 +80,8 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
// Don't deploy system libraries. // Don't deploy system libraries.
if ( trimmed.startsWith("/System/Library/") if ( trimmed.startsWith("/System/Library/")
|| (trimmed.startsWith("/usr/lib/")) // && trimmed.contains("libQt") == false) // exception for libQtuitools and libQtlucene || (trimmed.startsWith("/usr/lib/")) // && trimmed.contains("libQt") == false) // exception for libQtuitools and libQtlucene
|| trimmed.startsWith("@executable_path")) || trimmed.startsWith("@executable_path"))
return info; return info;
enum State {QtPath, FrameworkName, DylibName, Version, End}; enum State {QtPath, FrameworkName, DylibName, Version, End};
...@@ -93,6 +93,7 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs) ...@@ -93,6 +93,7 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
// Split the line into [Qt-path]/lib/qt[Module].framework/Versions/[Version]/ // Split the line into [Qt-path]/lib/qt[Module].framework/Versions/[Version]/
QStringList parts = trimmed.split("/"); QStringList parts = trimmed.split("/");
while (part < parts.count()) { while (part < parts.count()) {
const QString currentPart = parts.at(part).simplified() ; const QString currentPart = parts.at(part).simplified() ;
...@@ -107,10 +108,12 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs) ...@@ -107,10 +108,12 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
// Check for library name part // Check for library name part
if (part < parts.count() && parts.at(part).contains(".dylib ")) { if (part < parts.count() && parts.at(part).contains(".dylib ")) {
state = DylibName; state = DylibName;
if(parts.at(part -1) == "bin")
if (parts.at(part - 1) == "bin")
info.installName += "/" + (qtPath + "bin/").simplified(); info.installName += "/" + (qtPath + "bin/").simplified();
else else
info.installName += "/" + (qtPath + "lib/").simplified(); info.installName += "/" + (qtPath + "lib/").simplified();
info.frameworkDirectory = info.installName; info.frameworkDirectory = info.installName;
state = DylibName;