예제 #1
0
 /**
  * @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;
     }
 }
예제 #2
0
    /**
     * @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);
            }
        }

    }
예제 #3
0
    /**
     * @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);
        }
    }
예제 #4
0
    /**
     * @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 &section) {
                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);
    }
예제 #6
0
 /**
  * @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)
 {
 }
예제 #7
0
    /**
     * @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);
        }
    }
예제 #8
0
/**
 * @brief EditEntityDialog::onScopeAdded
 * @param scope
 */
void EditEntityDialog::onScopeAdded(const entity::SharedScope &scope)
{
    ui->cbScopes->addItem(scope->name(), QVariant::fromValue(scope));
}