Commit e957d381 authored by Denis Khachko's avatar Denis Khachko

Course - read only files fix.

parent 8d4528c4
......@@ -3366,7 +3366,7 @@ void RobotModule::copyFromPult(QString log)
// The source should be ready-to-read QIODevice like QBuffer or QFile
qDebug()<<"Load env";
if(field->loadFromDataStream(source)!=0)return ;
m_mainWidget->setWindowTitle("Робот - "+source->objectName());
m_mainWidget->setWindowTitle(trUtf8("Робот - ")+source->objectName());
startField=field->Clone();
field->dropWasEdit();
// ajustWindowSize();//NEW ROBOT
......
......@@ -19,6 +19,7 @@ cursFile="";
{
course=NULL;
ui->setupUi(this);
isReadOnly=false;
ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
ui->treeView->setIconSize(QSize(25,25));
ui->treeView->setStyleSheet("icon-size: 25px;font-size: 14px;");
......@@ -133,12 +134,20 @@ void MainWindowTask::loadMarks(const QString fileName)
{
QDomDocument workXml;
QFile f(fileName);
if (!f.open(QIODevice::ReadOnly))
{
QMessageBox::information( 0, "", trUtf8("Ошибка открытия файла: ") + fileName, 0,0,0);
return;
};
QFileInfo fi(f);
if(!fi.isWritable())
{
QMessageBox::information( 0, "", trUtf8("Файл загружен только для чтения, изменение не будут сохранены: ") + fileName, 0,0,0);
isReadOnly=true;
}else
isReadOnly=false;
if(f.atEnd())
{
QMessageBox::information( 0, "", trUtf8("Ошибка открытия файла ,файл пуст: ") + fileName, 0,0,0);
......@@ -287,12 +296,14 @@ void MainWindowTask::loadCourse()
progChange.clear();
if(fileName.right(9)==".work.xml")//Загрузка оценок и программ
{
isReadOnly=false;
loadMarks(fileName);
this->show();
return;
}else
cursWorkFile.setFileName("");
loadCourseData(fileName);
isReadOnly=false;
interface->setPreProgram(QVariant(""));
QString cText=course->courceDescr();
......@@ -572,6 +583,7 @@ void MainWindowTask::saveCourse()
};
void MainWindowTask::saveCourseFile()
{
if(isReadOnly)return;
qDebug()<<"Save cource file";
QDomDocument saveXml;
......
......@@ -156,6 +156,7 @@ private:
QLineEdit *editRoot;
QFileInfo baseKursFile; //4 mode
Ui::MainWindowTask *ui;
bool isReadOnly;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment