/** * @brief BasicCppProjectGenerator::generateFiles * @param scope * @param directory */ void BasicCppProjectGenerator::generateFiles(const entity::SharedScope &scope, const SharedVirtualDirectory &directory) { SharedVirtualDirectory dir((m_Options & NamespacesInSubfolders) ? directory->addDirectory(scope->name().toLower()) : directory); for (auto &&t : scope->types()) { translation::Code code = m_ProjectTranslator.translate(t); m_ProjectTranslator.addNamespace(t, code); QString name(t->name().toLower()); if (!code.toSource.isEmpty()) { code.toSource.prepend(QString("#include \"%1.h\"\n\n").arg(name)); } if (!code.toHeader.isEmpty()) { if (m_Options & DefineIcludeGuard) { QString guardName = scope->name().toUpper() + "_" + t->name().toUpper() + "_H"; code.toHeader.prepend("#define " + guardName + "\n\n"); code.toHeader.prepend("#ifndef " + guardName + "\n"); code.toHeader.append("\n\n#endif // " + guardName); } else { code.toHeader.prepend("#pragma once\n\n"); } } auto addFile = [&](const QString &data, const QString &ext, QStringList §ion) { QString fname(name + ext); dir->addFile(fname)->setData(data); section.append(fname); }; if (!code.toHeader.isEmpty()) addFile(code.toHeader, ".h", m_ProfileData.headers); if (!code.toSource.isEmpty()) addFile(code.toSource, ".cpp", m_ProfileData.sources); } for (auto &&s : scope->scopes()) generateFiles(s, dir); }
/** * @brief MoveTypeToOtherScope::MoveTypeToOtherScope * @param type * @param appModel * @param srcScope * @param dstScope * @param parent */ MoveTypeToOtherScope::MoveTypeToOtherScope(const entity::SharedType &type, const models::SharedApplicationModel &appModel, const entity::SharedScope &srcScope, const entity::SharedScope &dstScope, QUndoCommand *parent) : BaseCommand(tr("Move \"%1\" from \"%2\" to \"%3\".").arg(type->name(), srcScope->name(), dstScope->name()), parent) , m_Type(type) , m_SrcScope(srcScope) , m_DstScope(dstScope) , m_Model(appModel) { }
/** * @brief EditEntityDialog::onScopeAdded * @param scope */ void EditEntityDialog::onScopeAdded(const entity::SharedScope &scope) { ui->cbScopes->addItem(scope->name(), QVariant::fromValue(scope)); }