Exemplo n.º 1
0
    /**
     * @brief SignatureMaker::makeType
     * @param type
     * @return
     */
    QString SignatureMaker::makeType(const Entity::SharedType &type) const
    {
        if (!type)
            return "";

        QString result;

        QStringList scopes;
        auto scopeId = type->scopeId();
        QSet<Common::ID> forbidden = {Common::ID::projectScopeID(),
                                            Common::ID::globalScopeID(),
                                            Common::ID::localTemplateScopeID()};
        while (!globalIds.contains(scopeId)) {
            if (auto scope = findScope(scopeId)) {
                if (!scope->name().isEmpty() && !forbidden.contains(scopeId))
                    scopes.prepend(scope->name());
                scopeId = scope->scopeId();
            } else {
                return "";
            }
        }

        scopes.removeAll("");
        if (!scopes.isEmpty())
            result.prepend(scopes.join("::").append("::"));

        result.append(type->name());

        return result;
    }
Exemplo n.º 2
0
    /**
     * @brief scopesNamesList
     * @param type
     * @param db
     * @return
     */
    QStringList scopesNamesList(const entity::SharedType &type, const db::SharedDatabase &db)
    {
        QStringList result;
        entity::SharedScope scope(db->depthScopeSearch(type->scopeId()));
        QString id(scope ? scope->id() : GLOBAL_SCOPE_ID);

        while (scope && id != GLOBAL_SCOPE_ID) {
            result << scope->name();
            id = scope->parentScopeId();
            scope = db->depthScopeSearch(id);
        }

        return result;
    }
Exemplo n.º 3
0
/**
 * @brief EditEntityDialog::setData
 * @param model
 * @param id
 */
void EditEntityDialog::setData(const models::SharedApplicationModel &model, const entity::SharedType &type)
{
    Q_ASSERT(model);
    Q_ASSERT(type);

    m_ApplicationModel = model;
    m_Project = m_ApplicationModel->currentProject();
    m_Scope = m_Project->database()->getScope(type->scopeId());
    m_Type = type;

    components::ComponentsMaker &maker = m_SignatureEditDelegate->maker();
    maker.setModel(m_ApplicationModel);
    maker.setScope(m_Scope);
    maker.setEntity(m_Type);

    // Temporary {
    if (m_Type->hashType() == entity::Class::staticHashType()) {
        auto cl = std::static_pointer_cast<entity::Class>(m_Type);

        if (cl->methods().isEmpty()) {
            auto intType = m_Scope->addType("int");
            auto doubleType = m_Scope->addType("double");

            cl->makeMethod("foo")->setReturnTypeId(intType->id());
            cl->makeMethod("bar")->setReturnTypeId(doubleType->id());
            cl->makeMethod("baz");
        }

        if (cl->fields().isEmpty()) {
            cl->addField("f1", "stub");
            cl->addField("f2", "stub");
        }
    }
    // }

    auto signatureMaker = std::make_unique<translation::SignatureMaker>(
                              m_ApplicationModel->globalDatabase(), m_Project->database(),
                              m_Scope, m_Type
                          );
    m_ComponentsModel->setSignatureMaker(std::move(signatureMaker));
    m_ComponentsModel->setComponents(m_Type);

    fillMaps();
}