readonly file saving bugfix

master
Denes Matetelki 14 years ago
parent 1e417c8d47
commit e097b51b2c

@ -109,12 +109,6 @@ bool ArgumentParser::parseCmdLineArgs(bool &successful)
successful = false;
return false;
}
if (!fileInfo.isWritable())
{
std::cout << tr("File: ").toStdString() <<
m_filePath.toStdString() <<
tr(" is not writeable.").toStdString() << std::endl;
}
}
return true;
}

@ -225,6 +225,11 @@ void MainWindow::openFile(const QString &fileName)
m_fileName = fileName;
}
QFileInfo fileInfo(fileName);
if (!fileInfo.isWritable())
statusBarMsg(tr("Read-only file!"));
if (!m_graphicsView->readContentFromXmlFile(m_fileName))
{
m_fileName = currFilename;
@ -232,17 +237,35 @@ void MainWindow::openFile(const QString &fileName)
}
m_ui->actionSave->setEnabled(true);
m_ui->actionSaveAs->setEnabled(true);
m_ui->actionClose->setEnabled(true);
m_ui->actionExport->setEnabled(true);
contentChanged(false);
setTitle(m_fileName);
if (!fileInfo.isWritable())
{
m_ui->actionSave->setEnabled(false);
setTitle(QString("readonly ").append(m_fileName));
}
else
{
m_ui->actionSave->setEnabled(true);
setTitle(m_fileName);
}
showMainToolbar();
}
void MainWindow::saveFile()
{
QFileInfo fileInfo(m_fileName);
if (!fileInfo.isWritable())
{
statusBarMsg(tr("Read-only file!"));
return;
}
m_graphicsView->writeContentToXmlFile(m_fileName);
contentChanged(false);
}

Loading…
Cancel
Save