/** * @brief Database::addExistsScope * @param scope */ void Database::addExistsScope(const entity::SharedScope &scope) { if (scope) { Q_ASSERT(!m_Scopes.contains(scope->id())); m_Scopes[scope->id()] = scope; } }
/** * @brief Database::getDepthType * @param scope * @param id * @param result */ void Database::getDepthType(const entity::SharedScope &scope, const QString &id, entity::SharedType &result) const { if (scope->containsType(id)) { result = scope->type(id); return; } else if (scope->hasChildScopes()){ for (auto &&child_scope : scope->scopes()) { if (result) break; getDepthType(child_scope, id, result); } } }
/** * @brief Database::recursiveFind * @param scope * @param id * @param ids */ void Database::recursiveFind(entity::SharedScope scope, const QString &id, QStringList &ids) const { if (scope->scopes().isEmpty()) { ids.clear(); return; } ids << scope->id(); if (scope->containsChildScope(id)) { ids << scope->getChildScope(id)->id(); return; } else { for (auto sc : scope->scopes()) recursiveFind(sc, id, ids); } }
/** * @brief ProjectDatabase::addExistsScope * @param scope * @return */ Entity::SharedScope ProjectDatabase::addExistsScope(const Entity::SharedScope &scope) { Database::addExistsScope(scope); G_CONNECT(scope.get(), &Entity::Scope::typeSearcherRequired, this, &ProjectDatabase::onTypeUserAdded); return scope; }
/** * @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 ProjectTreeModel::addScope * @param scope * @param parent */ void ProjectTreeModel::addScope(const entity::SharedScope &scope, const QString &projectName) { if (auto &&pr = find(projectName)) { auto &&projectIndex = index(indexOf(pr), 0); Q_ASSERT(projectIndex.isValid()); auto pos = projectIndex.row() + 1; beginInsertRows(projectIndex, pos, pos); auto &&newItem = pr->makeChild(QVariant::fromValue(scope), TreeItemType::ScopeItem); endInsertRows(); observeItemChanging(m_CurrentProject, scope.get(), newItem); } }
/** * @brief EditEntityDialog::onScopeAdded * @param scope */ void EditEntityDialog::onScopeAdded(const entity::SharedScope &scope) { ui->cbScopes->addItem(scope->name(), QVariant::fromValue(scope)); }