/**
 * @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();
}
Beispiel #2
0
 /**
  * @brief SignatureMaker::SignatureMaker
  * @param model
  * @param project
  * @param scope
  * @param type
  */
 SignatureMaker::SignatureMaker(const DB::SharedDatabase &globalDb,
                                const DB::SharedProjectDatabase &projectDb,
                                const Entity::SharedScope &scope, const Entity::SharedType &type)
     : m_Type(type)
     , m_Scope(scope)
     , m_GlobalDatabase(globalDb)
     , m_ProjectDatabase(projectDb)
 {
     m_MakersMap[Entity::Field::staticHashType()] =
         [&](const Common::SharedBasicEntity &component) {
             return makeField(std::static_pointer_cast<Entity::Field>(component));
         };
     m_MakersMap[Entity::ClassMethod::staticHashType()] =
             [&](const Common::SharedBasicEntity &component) {
                 return makeMethod(std::static_pointer_cast<Entity::ClassMethod>(component));
             };
     m_MakersMap[Entity::Property::staticHashType()] =
             [&](const Common::SharedBasicEntity &component) {
                 return makeProperty(std::static_pointer_cast<Entity::Property>(component));
             };
 }
Beispiel #3
0
 /**
  * @brief Class::addNewMethod
  * @return
  */
 SharedMethod Class::addNewMethod()
 {
     return makeMethod(newMethodName);
 }