Esempio n. 1
0
bool QLCFixtureEditor::save()
{
    if (checkManufacturerModel() == false)
        return false;

    if (m_fileName.simplified().isEmpty() == true)
    {
        return saveAs();
    }
    else
    {
        QFile::FileError error = m_fixtureDef->saveXML(m_fileName);
        if (error == QFile::NoError)
        {
            setModified(false);
            return true;
        }
        else
        {
            QMessageBox::critical(this, tr("Fixture saving failed"),
                                  tr("Unable to save fixture definition:\n%1")
                                  .arg(QLCFile::errorString(error)));
            return false;
        }
    }
}
Esempio n. 2
0
bool QLCFixtureEditor::save()
{
	if (checkManufacturerModel() == false)
		return false;

	if (m_fileName.length() == 0)
	{
		return saveAs();
	}
	else
	{
		if (m_fixtureDef->saveXML(m_fileName) == true)
		{
			setModified(false);
			return true;
		}
		else
		{
			QMessageBox::critical(this, "Unable to save file",
					      QString("Error: ") +
					      strerror(errno));
			return false;
		}
	}
}
Esempio n. 3
0
bool QLCFixtureEditor::saveAs()
{
	QString path;

	if (checkManufacturerModel() == false)
		return false;

	if (m_fileName.length() == 0)
	{
		QSettings s;
		path = s.value("directories/fixtures").toString() + "/";
		path += m_fixtureDef->manufacturer() + QString("-");
		path += m_fixtureDef->model() + QString(".qxf");
	}
	else
	{
		path = m_fileName;
	}

	path = QFileDialog::getSaveFileName(this, path, "Fixtures (*.qxf)");
	if (path.length() != 0)
	{
		if (path.right(strlen(KExtFixture)) != QString(KExtFixture))
			path += QString(KExtFixture);

		if (m_fixtureDef->saveXML(path) == true)
		{
			m_fileName = path;
			setCaption();
			setModified(false);
			return true;
		}
		else
		{
			QMessageBox::critical(this,"Unable to save file: ",
					      QString("Error: ") +
					      strerror(errno));
			return false;
		}
	}
	else
	{
		return false;
	}
}
Esempio n. 4
0
bool QLCFixtureEditor::saveAs()
{
    /* Bail out if there is no manufacturer or model */
    if (checkManufacturerModel() == false)
        return false;

    /* Create a file save dialog */
    QFileDialog dialog(this);
    dialog.setWindowTitle(tr("Save fixture definition"));
    dialog.setAcceptMode(QFileDialog::AcceptSave);
    dialog.setNameFilter(KQXFFilter);

    QString path;
    QDir dir = QLCFixtureDefCache::userDefinitionDirectory();
    if (m_fileName.isEmpty() == true)
    {
        /* Construct a new path for the (yet) unnamed file */
        QString man = m_fixtureDef->manufacturer().replace(" ", "-");
        QString mod = m_fixtureDef->model().replace(" ", "-");
        path = QString("%1-%2%3").arg(man).arg(mod).arg(KExtFixture);
        dialog.setDirectory(dir);
        dialog.selectFile(path);
    }
    else
    {
        /* The fixture already has a file name. Use that then. */
        dialog.setDirectory(QDir(m_fileName));
        dialog.selectFile(m_fileName);
    }

    /* Execute the dialog */
    if (dialog.exec() != QDialog::Accepted)
        return false;

    path = dialog.selectedFiles().first();
    if (path.length() != 0)
    {
        if (path.right(strlen(KExtFixture)) != QString(KExtFixture))
            path += QString(KExtFixture);

        QFile::FileError error = m_fixtureDef->saveXML(path);
        if (error == QFile::NoError)
        {
            m_fileName = path;
            setCaption();
            setModified(false);
            return true;
        }
        else
        {
            QMessageBox::critical(this, tr("Fixture saving failed"),
                                  tr("Unable to save fixture definition:\n%1")
                                  .arg(QLCFile::errorString(error)));
            return false;
        }
    }
    else
    {
        return false;
    }
}