Exemplo n.º 1
0
void MainWindow::saveProjectAs()
{
    QString fileName =
            QFileDialog::getSaveFileName(this, tr("Save DES Project"),
                                         QDir::currentPath(),
                                         tr("DES Files (*.xml)"));
    if (fileName.isEmpty())
        return;

    QFile file(fileName);
    if (!file.open(QFile::WriteOnly | QFile::Text)) {
        QMessageBox::warning(this, tr("DES Project Writer"),
                             tr("Cannot write file %1:\n%2.")
                             .arg(fileName)
                             .arg(file.errorString()));
        return;
    }

    m_project->setFileName(fileName);

    ProjectSerializer serializer;
    if(serializer.saveProject(m_project, &file))
        statusBar()->showMessage(tr("Project saved"), 20000);

    m_unsavedChanges = false;
}
Exemplo n.º 2
0
void MainWindow::saveProject()
{
    if(m_project->fileName().isEmpty())
        saveProjectAs();

    else
    {
        QFile file(m_project->fileName());
        if (!file.open(QFile::WriteOnly | QFile::Text)) {
            QMessageBox::warning(this, tr("DES Project Writer"),
                                 tr("Cannot write file %1:\n%2.")
                                 .arg(m_project->fileName())
                                 .arg(file.errorString()));
            return;
        }

        ProjectSerializer serializer;
        if(serializer.saveProject(m_project, &file))
            statusBar()->showMessage(tr("Project saved"), 20000);

        m_unsavedChanges = false;
    }
}