Пример #1
0
Core::IDocument::OpenResult ModelDocument::load(QString *errorString, const QString &fileName)
{
    d->documentController = ModelEditorPlugin::modelsManager()->createModel(this);
    connect(d->documentController, &qmt::DocumentController::changed, this, &IDocument::changed);

    try {
        d->documentController->loadProject(fileName);
        setFilePath(Utils::FileName::fromString(d->documentController->projectController()->project()->fileName()));
    } catch (const qmt::FileNotFoundException &ex) {
        *errorString = ex.errorMessage();
        return OpenResult::ReadError;
    } catch (const qmt::Exception &ex) {
        *errorString = tr("Could not open \"%1\" for reading: %2.").arg(fileName).arg(ex.errorMessage());
        return OpenResult::CannotHandle;
    }

    QString configPath = d->documentController->projectController()->project()->configPath();
    if (!configPath.isEmpty()) {
        QString canonicalPath = QFileInfo(QDir(QFileInfo(fileName).path()).filePath(configPath)).canonicalFilePath();
        if (!canonicalPath.isEmpty()) {
            // TODO error output on reading definition files
            d->documentController->configController()->readStereotypeDefinitions(canonicalPath);
        } else {
            // TODO error output
        }
    }

    emit contentSet();
    return OpenResult::Success;
}
Пример #2
0
bool ModelDocument::load(QString *errorString, const QString &fileName)
{
    d->documentController = ModelEditorPlugin::modelsManager()->createModel(this);
    connect(d->documentController, &qmt::DocumentController::changed, this, &IDocument::changed);

    try {
        d->documentController->loadProject(fileName);
        setFilePath(Utils::FileName::fromString(d->documentController->getProjectController()->getProject()->getFileName()));
    } catch (const qmt::Exception &ex) {
        *errorString = ex.getErrorMsg();
        return false;
    }

    emit contentSet();
    return true;
}
Пример #3
0
Core::IDocument::OpenResult ModelDocument::load(QString *errorString, const QString &fileName)
{
    d->documentController = ModelEditorPlugin::modelsManager()->createModel(this);
    connect(d->documentController, &qmt::DocumentController::changed, this, &IDocument::changed);

    try {
        d->documentController->loadProject(fileName);
        setFilePath(Utils::FileName::fromString(d->documentController->getProjectController()->getProject()->getFileName()));
    } catch (const qmt::FileNotFoundException &ex) {
        *errorString = ex.getErrorMsg();
        return OpenResult::ReadError;
    } catch (const qmt::Exception &ex) {
        *errorString = tr("Could not open \"%1\" for reading: %2.").arg(fileName).arg(ex.getErrorMsg());
        return OpenResult::CannotHandle;
    }

    emit contentSet();
    return OpenResult::Success;
}