mainwindow.cpp 33.9 KB
Newer Older
Denis Khachko's avatar
Denis Khachko committed
1 2 3 4
#include "mainwindow.h"
#include "ui_mainwindow.h"
//#include "interface.h"

5 6 7
#include "interfaces/browserinterface.h"
#include "interfaces/browser_instanceinterface.h"

Victor Yacovlev's avatar
Victor Yacovlev committed
8

Denis Khachko's avatar
Denis Khachko committed
9 10 11 12 13 14 15 16 17 18 19 20
MainWindowTask::MainWindowTask(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindowTask)
{

cursFile="";
  course=NULL;
    curDir="";
    progChange.clear();
    connect(qApp,SIGNAL(aboutToQuit()),this,SLOT(aboutToQuit()));

}
21
 void MainWindowTask::setup(const QDir & resourcesRoot, ExtensionSystem::SettingsPtr sett)
Denis Khachko's avatar
Denis Khachko committed
22
 {
Denis Khachko's avatar
Denis Khachko committed
23
       course=NULL;
Denis Khachko's avatar
Denis Khachko committed
24
     ui->setupUi(this);
Denis Khachko's avatar
Denis Khachko committed
25
     isReadOnly=false;
Denis Khachko's avatar
Denis Khachko committed
26 27 28
     ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
     ui->treeView->setIconSize(QSize(25,25));
     ui->treeView->setStyleSheet("icon-size: 25px;font-size: 14px;");
Denis Khachko's avatar
Denis Khachko committed
29
     settings = sett;
Denis Khachko's avatar
Denis Khachko committed
30
     customMenu.hide();
31 32
     connect(ui->loadCurs,SIGNAL(triggered()),this,SLOT(loadCourse()));
     connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(saveCourse()));
Denis Khachko's avatar
Denis Khachko committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
     connect(ui->treeView,SIGNAL(clicked(QModelIndex)),this,SLOT(showText(QModelIndex)));
       connect(ui->do_task,SIGNAL(triggered()),this,SLOT(startTask()));
       qDebug()<<"Check Connect tttttttttttttttttt";
       connect(ui->checkTask,SIGNAL(triggered()),this,SLOT(checkTask()));
      connect(ui->actionReset,SIGNAL(triggered()),this,SLOT(resetTask()));
        connect(ui->actionClose,SIGNAL(triggered()),this,SLOT(Close()));
           connect(ui->actionTested,SIGNAL(triggered()),this,SLOT(returnTested()));
           connect(ui->treeView,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(customContextMenuRequested(QPoint)));

           customMenu.addAction(ui->actionAdd);
           customMenu.addAction(ui->actionRemove);
           customMenu.addAction(ui->actionEdit);
       customMenu.addSeparator();
       customMenu.addAction(ui->actionup);
       customMenu.addAction(ui->actionDown);
         customMenu.addAction(ui->addDeep);
       connect(ui->actionup,SIGNAL(triggered()),this,SLOT(moveUp()));
       connect(ui->actionDown,SIGNAL(triggered()),this,SLOT(moveDown()));
           connect(ui->actionAdd,SIGNAL(triggered()),this,SLOT(addTask()));
            connect(ui->addDeep,SIGNAL(triggered()),this,SLOT(addDeepTask()));
           connect(ui->actionSaveK,SIGNAL(triggered()),this,SLOT(saveKurs()));
            connect(ui->actionSaveKas,SIGNAL(triggered()),this,SLOT(saveKursAs()));
           connect(ui->actionRemove,SIGNAL(triggered()),this,SLOT(deleteTask()));
Denis Khachko's avatar
Denis Khachko committed
56 57 58 59
         //  newDialog=new newKursDialog();
          // connect(ui->actionNewK,SIGNAL(triggered()),this,SLOT(newKurs()));
         //  editDialog = new EditDialog(this);
          // connect(ui->actionEdit,SIGNAL(triggered()),this,SLOT(editTask()));
Denis Khachko's avatar
Denis Khachko committed
60 61 62 63 64 65
          // ui->menuKurs->menuAction()->setEnabled(false);
           setEditTaskEnabled(false);
           ui->treeView->setSelectionMode(QAbstractItemView::SingleSelection);
           editRoot=new QLineEdit(ui->treeView);
           editRoot->hide();
           connect(editRoot,SIGNAL(editingFinished ()),this,SLOT(endRootEdit()));
Denis Khachko's avatar
Denis Khachko committed
66
           ui->treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
Denis Khachko's avatar
Denis Khachko committed
67 68 69
isTeacher=false;
       onTask=false;
       cursFile="";
70
       setWindowIcon(QIcon(resourcesRoot.absoluteFilePath("10.png")));
71
        setupWebView();
Denis Khachko's avatar
Denis Khachko committed
72 73
       //ui->textBrowser->setVisible(false);
 };
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123

void MainWindowTask::setupWebView()
{
    using namespace ExtensionSystem;
    using namespace Shared;

    BrowserInterface * browserPlugin
            = PluginManager::instance()->findPlugin<BrowserInterface>();

    QWidget * webViewComponent = 0;
    simpleBrowserWidget_ = 0;
    browserPluginInstance_ = 0;

    if (browserPlugin) {
        browserPluginInstance_ = browserPlugin->createBrowser();
        webViewComponent = browserPluginInstance_->widget();
    }
    else {
        simpleBrowserWidget_ = new QTextBrowser();
        webViewComponent = simpleBrowserWidget_;
    }

    webViewComponent->setParent(ui->webView);
    webViewComponent->setMinimumWidth(200);
    QVBoxLayout * l = new QVBoxLayout;
    l->setContentsMargins(0, 0, 0, 0);
    ui->webView->setLayout(l);
    l->addWidget(webViewComponent);
}

void MainWindowTask::setTaskViewHtml(const QString &data)
{
    if (simpleBrowserWidget_) {
        simpleBrowserWidget_->setHtml(data);
    }
    else if (browserPluginInstance_) {
        browserPluginInstance_->setContent(data);
    }
}

void MainWindowTask::setTaskViewUrl(const QUrl &url)
{
    if (simpleBrowserWidget_) {
        simpleBrowserWidget_->setSource(url);
    }
    else if (browserPluginInstance_) {
        browserPluginInstance_->go(url);
    }
}

Denis Khachko's avatar
Lost 2  
Denis Khachko committed
124
QList<QAction*> MainWindowTask::getActions()
Denis Khachko's avatar
Denis Khachko committed
125 126 127 128
{
    QList<QAction*> toRet;
    toRet.append(ui->loadCurs);
    toRet.append(ui->checkTask);
Denis Khachko's avatar
Denis Khachko committed
129 130 131
    toRet.append(ui->actionSave);
    toRet.append(ui->actionReset);
    toRet.append(ui->actionTested);
Denis Khachko's avatar
Lost 2  
Denis Khachko committed
132
    return toRet;
Denis Khachko's avatar
Denis Khachko committed
133
}
Denis Khachko's avatar
Denis Khachko committed
134

Denis Khachko's avatar
Denis Khachko committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
MainWindowTask::~MainWindowTask()
{
    delete ui;
}

void MainWindowTask::changeEvent(QEvent *e)
{
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}
Denis Khachko's avatar
Denis Khachko committed
151 152
void MainWindowTask::updateLastFiles(const QString newFile )
{
Denis Khachko's avatar
Denis Khachko committed
153
      QStringList lastFiles= settings->value("Courses/LastFiles","").toString().split(";");
Denis Khachko's avatar
Denis Khachko committed
154
    qDebug()<<lastFiles;
Denis Khachko's avatar
Denis Khachko committed
155
     qDebug()<<settings->locationDirectory();
Denis Khachko's avatar
Denis Khachko committed
156 157 158 159 160 161 162
    if(lastFiles.indexOf(newFile)<0)lastFiles.prepend(newFile);
    int max_fid=std::min(lastFiles.count(),10);
    QString sett="";
    for(int i=0;i<max_fid;i++)
    {
        sett+= lastFiles.at(i)+";";
    }
Denis Khachko's avatar
Denis Khachko committed
163 164
    settings->setValue("Courses/LastFiles",sett);
    interface->rebuildRescentMenu();
Denis Khachko's avatar
Denis Khachko committed
165
};
Denis Khachko's avatar
Denis Khachko committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
void MainWindowTask::loadCourseData(const QString fileName)
{

course=new courseModel();
connect(course,SIGNAL(dataChanged (QModelIndex ,QModelIndex )),ui->treeView,SLOT(dataChanged(QModelIndex,QModelIndex)));
int tasks=course->loadCourse(fileName);
course->setTeacher(isTeacher);
if(tasks==-1)
{
//QMessageBox::information( 0, "", trUtf8("Ошибка открытия файла: ") + fileName, 0,0,0);
return;
};
ui->treeView->setModel(course);
curTaskIdx=QModelIndex();
onTask=false;
ui->actionSave->setEnabled(true);

changes.cleanChanges();
cursFile=fileName;
};
void MainWindowTask::loadMarks(const QString fileName)
{
    QDomDocument workXml;
    QFile f(fileName);
Denis Khachko's avatar
Denis Khachko committed
190
    
Denis Khachko's avatar
Denis Khachko committed
191 192 193 194 195 196
    if  (!f.open(QIODevice::ReadOnly))
    {
        QMessageBox::information( 0, "", trUtf8("Ошибка открытия файла: ") + fileName, 0,0,0);
        return;

    };
Denis Khachko's avatar
Denis Khachko committed
197 198 199 200 201 202 203
    QFileInfo fi(f);
    if(!fi.isWritable())
    {
       QMessageBox::information( 0, "", trUtf8("Файл загружен только для чтения, изменение не будут сохранены: ") + fileName, 0,0,0);
        isReadOnly=true;
    }else
     isReadOnly=false;   
Denis Khachko's avatar
Denis Khachko committed
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
if(f.atEnd())
    {
    QMessageBox::information( 0, "", trUtf8("Ошибка открытия файла ,файл пуст: ") + fileName, 0,0,0);
    return;
    };
cursWorkFile.setFileName(f.fileName());
QString error;
int str,pos;
workXml.setContent(f.readAll(),true,&error,&str,&pos);
qDebug()<<"File parce:"<<error<<"str"<<str<<" pos"<<pos;

QDomElement root=workXml.documentElement ();
if(root.tagName()!="COURSE")
  {
        QMessageBox::information( 0, "", trUtf8("Ошибка загрузки файла: ") + fileName, 0,0,0);
        return;
  };
QDomElement fileEl=root.firstChildElement("FILE");
QString krsFile=fileEl.attribute("fileName");
loadCourseData(krsFile);//Gruzim kurs

if(cursFile!=krsFile){//Esli ne udalos po puti - ishem v toyje direktorii
    QFileInfo finf(fileEl.attribute("fileName"));
    QFileInfo cfi(cursWorkFile);
    qDebug()<<"PATH"<<cfi.dir().canonicalPath()+"/"+finf.fileName();
    krsFile=cfi.dir().canonicalPath()+"/"+finf.fileName();
    curDir=cfi.dir().canonicalPath();
Denis Khachko's avatar
Denis Khachko committed
231 232
    QFileInfo krsFi(krsFile);
    if(krsFi.isReadable())
Denis Khachko's avatar
Denis Khachko committed
233 234 235 236 237
    loadCourseData(krsFile);

}

QString fileN=fileEl.attribute("fileName");
Denis Khachko's avatar
Denis Khachko committed
238
//qDebug()<<"KURS ZAGRUZILI";
Denis Khachko's avatar
Denis Khachko committed
239 240 241 242 243 244 245 246 247
if(cursFile!=krsFile){
    QMessageBox::information( 0, "", trUtf8("Не наеден файл курса:") + fileEl.attribute("fileName"), 0,0,0);
    fileN=getFileName(krsFile);
    loadCourseData(fileN);
    if(cursFile!=fileN)return;
    }
QFileInfo fi_kurs=QFileInfo(krsFile);
curDir=fi_kurs.absolutePath();
QDomNodeList marksElList=root.elementsByTagName("MARK"); //Оценки
Denis Khachko's avatar
Denis Khachko committed
248
//qDebug()<<"Loading marks "<<marksElList.count();
Denis Khachko's avatar
Denis Khachko committed
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
for(int i=0;i<marksElList.count();i++)
 {
 int taskId=marksElList.at(i).toElement().attribute("testId").toInt();
 int mark=marksElList.at(i).toElement().attribute("mark").toInt();
 qDebug()<<"task:"<<taskId<<" mark:"<<mark;
 course->setMark(taskId,mark);
 changes.setMark(taskId,mark);
 };

qDebug()<<"Loading user prgs...";
QDomNodeList prgElList=root.elementsByTagName("USER_PRG");//Программы
for(int i=0;i<prgElList.count();i++)
 {
 int taskId=prgElList.at(i).toElement().attribute("testId").toInt();
 qDebug()<<"Tassk id"<<taskId;
 QString prg =prgElList.at(i).toElement().attribute("prg");
 QModelIndex tIdx=course->getIndexById(taskId);

 if(progChange.indexOf(taskId)==-1){

     progChange.append(taskId);
      };
 course->setUserText(taskId,prg);

 };

QDomNodeList prgElListT=root.elementsByTagName("TESTED_PRG");//Программы тестированные
for(int i=0;i<prgElListT.count();i++)
 {
 int taskId=prgElListT.at(i).toElement().attribute("testId").toInt();
 QString prg =prgElListT.at(i).toElement().attribute("prg");

 course->setUserTestedText(taskId,prg);

 };
};
Denis Khachko's avatar
Denis Khachko committed
285 286 287 288 289 290 291
 void MainWindowTask::loadCourseFromFile(const QString & file)
{QFileInfo fi(file);
    if(!fi.exists())
    {
        
        return;
    };
Denis Khachko's avatar
Denis Khachko committed
292

Denis Khachko's avatar
Denis Khachko committed
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
    baseKursFile=fi;
    curDir=fi.absolutePath ();
    settings->setValue("Directories/Kurs", curDir);
    qDebug()<<"curDir"<<curDir;
    QString fileName=file;
    progChange.clear();
    if(fileName.right(9)==".work.xml")//Загрузка оценок и программ
    {
        loadMarks(fileName);
        this->show();
        return;
    }else
        cursWorkFile.setFileName("");
    loadCourseData(fileName);
    QString cText=course->courceDescr();
    
    
    if(cText.right(4)==".htm" ||cText.right(5)==".html" )
    {
        loadHtml(cText);
313
    }else setTaskViewHtml(cText);
Denis Khachko's avatar
Denis Khachko committed
314 315 316 317
    // if(isTeacher)ui->actionEdit->setEnabled(true);
    setWindowTitle(course->name()+trUtf8(" - Практикум"));
    updateLastFiles(fileName);
    interface->lockContrls();
318
    interface->setPreProgram(QVariant(""));
Denis Khachko's avatar
Denis Khachko committed
319 320 321
    ui->checkTask->setEnabled(false);
    this->show();
};
Denis Khachko's avatar
Denis Khachko committed
322 323 324 325 326 327 328 329 330 331 332 333 334

void MainWindowTask::loadCourse()
{
    editRoot->hide();
    ui->splitter->setEnabled(true);
    QString dir=settings->value("Directories/Kurs","").toString();
    QDir chD(dir);
    if(!chD.exists())dir=QDir::homePath();
//    QFileDialog dialog(this,trUtf8("Открыть файл"),dir, "(*.kurs.xml *.work.xml)");
//     dialog.setAcceptMode(QFileDialog::AcceptOpen);
//     if(!dialog.exec())return;


Denis Khachko's avatar
Denis Khachko committed
335
     QString	File=QFileDialog::getOpenFileName(this, QString::fromUtf8 ("Открыть файл"), dir, "Xml (*.xml)");
Denis Khachko's avatar
Denis Khachko committed
336
     QFileInfo fi(File);
Denis Khachko's avatar
Denis Khachko committed
337 338 339 340 341
    if(!fi.exists())
    {
           
        return;
    };
Denis Khachko's avatar
Denis Khachko committed
342
    this->showNormal();
Denis Khachko's avatar
Denis Khachko committed
343 344 345 346 347 348 349 350 351

     baseKursFile=fi;
     curDir=fi.absolutePath ();
     settings->setValue("Directories/Kurs", curDir);
     qDebug()<<"curDir"<<curDir;
     QString fileName=File;
     progChange.clear();
     if(fileName.right(9)==".work.xml")//Загрузка оценок и программ
     {
Denis Khachko's avatar
Denis Khachko committed
352
         isReadOnly=false;
Denis Khachko's avatar
Denis Khachko committed
353
         loadMarks(fileName);
354 355
         Q_EMIT activateRequest();
//         this->show();
Denis Khachko's avatar
Denis Khachko committed
356
         return;
357 358
     }
    bool createDefaultWorkFile=true;
Victor Yacovlev's avatar
Victor Yacovlev committed
359 360 361 362 363 364 365 366 367 368 369 370
    QMessageBox msgBoxCreateWorkbook(
                QMessageBox::Question,
                trUtf8("Практикум"),
                trUtf8("Вы хотите создать тетрадь?"),
                QMessageBox::Yes | QMessageBox::No,
                this
                );
    msgBoxCreateWorkbook.button(QMessageBox::Yes)->setText(trUtf8("Создать"));
    msgBoxCreateWorkbook.button(QMessageBox::No)->setText(trUtf8("Не создавать"));
    int ans = msgBoxCreateWorkbook.exec();
//            ans = QMessageBox::question(this, trUtf8("Практикум"), trUtf8("Вы хотите создать тетрадь?"),
//                    QMessageBox::Yes | QMessageBox::No , QMessageBox::Yes);
371 372 373 374 375
            if (ans == QMessageBox::Yes)
            {
                createDefaultWorkFile=false;
                
            };
Denis Khachko's avatar
Denis Khachko committed
376
    
Denis Khachko's avatar
Denis Khachko committed
377 378
     cursWorkFile.setFileName("");
     loadCourseData(fileName);
Denis Khachko's avatar
Denis Khachko committed
379
     isReadOnly=false;
380
     interface->setPreProgram(QVariant(""));
Denis Khachko's avatar
Denis Khachko committed
381
     QString cText=course->courceDescr();
Denis Khachko's avatar
Denis Khachko committed
382
  
Denis Khachko's avatar
Denis Khachko committed
383 384 385 386

  if(cText.right(4)==".htm" ||cText.right(5)==".html" )
  {
      loadHtml(cText);
387
  }else setTaskViewHtml(cText);
Denis Khachko's avatar
Denis Khachko committed
388
 // if(isTeacher)ui->actionEdit->setEnabled(true);
Denis Khachko's avatar
Denis Khachko committed
389
  setWindowTitle(course->name()+trUtf8(" - Практикум"));
Denis Khachko's avatar
Denis Khachko committed
390
    updateLastFiles(fileName);
391 392
    interface->lockContrls();
    ui->checkTask->setEnabled(false);
393 394
    Q_EMIT activateRequest();
//    this->show();
395 396 397 398 399 400 401
    if(createDefaultWorkFile)
    {
        markProgChange();
        //curDir=QDir::currentPath();
        qDebug()<<curDir;

        cursWorkFile.setFileName(QDir::currentPath()+"/default.work.xml");
Denis Khachko's avatar
Denis Khachko committed
402
        
403 404 405 406 407
        saveCourseFile();
    }else
    {
        saveCourse();
    };
Denis Khachko's avatar
Denis Khachko committed
408
    
Denis Khachko's avatar
Denis Khachko committed
409 410
};

Denis Khachko's avatar
Denis Khachko committed
411 412 413
void MainWindowTask::openRescent()
{
    
Denis Khachko's avatar
Denis Khachko committed
414

Denis Khachko's avatar
Denis Khachko committed
415 416
    
    QAction *s = qobject_cast<QAction*>(sender());
Denis Khachko's avatar
Denis Khachko committed
417 418
    
    loadCourseFromFile(s->property ( "fullName" ).toString());
Denis Khachko's avatar
Denis Khachko committed
419
  //  if( LoadFromFile(RobotFile)!=0)QMessageBox::information( mainWidget(), "", QString::fromUtf8("Ошибка открытия файла! ")+RobotFile, 0,0,0);
Denis Khachko's avatar
Denis Khachko committed
420
Q_EMIT activateRequest();
Denis Khachko's avatar
Denis Khachko committed
421
};
Denis Khachko's avatar
Denis Khachko committed
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497

void MainWindowTask::setUpDown(QModelIndex index)
{
    if(!isTeacher){ui->actionup->setEnabled(false);
        ui->actionDown->setEnabled(false);
    }
    return;
    if(course->hasUpSib(index))ui->actionup->setEnabled(true);
      else ui->actionup->setEnabled(false);
      if(course->hasDownSib(index))ui->actionDown->setEnabled(true);
        else ui->actionDown->setEnabled(false);
};


void MainWindowTask::moveUp()

{
    curTaskIdx=course->moveUp(curTaskIdx);
    QModelIndex par=curTaskIdx.parent();
    ui->treeView->setCurrentIndex(curTaskIdx);
    setUpDown(curTaskIdx);


   ui->treeView->collapse(par);
   ui->treeView->expand(par);
saveBaseKurs();
};
void MainWindowTask:: moveDown()
{ ui->treeView->setCurrentIndex(curTaskIdx);

    curTaskIdx=course->moveDown(curTaskIdx);
    ui->treeView->setCurrentIndex(curTaskIdx);
    setUpDown(curTaskIdx);
  //ui->treeView->dataChanged(curTaskIdx,ui->treeView->indexAbove(curTaskIdx));
   //showText(curTaskIdx);
   // ui->treeView->update(curTaskIdx);

   ui->treeView->collapse(curTaskIdx.parent());
   ui->treeView->expand(curTaskIdx.parent());
};


void MainWindowTask::showText(const QModelIndex & index )
 {
      editRoot->hide();
    qDebug()<<"TASK IDX:"<<curTaskIdx.internalId();
    if(index.internalId()>0)setEditTaskEnabled(true);
    else setEditTaskEnabled(false);
    setUpDown(index);
    if(index==curTaskIdx)return;
//    if(onTask)
//    {
//        QMessageBox::StandardButton ans;
//        ans = QMessageBox::question(this, trUtf8("Задание"), trUtf8("Вы хотите сменить задание?"),
//                                                                                                                        QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes);
//        if ((ans == QMessageBox::Cancel)||(ans == QMessageBox::No))
//        {
//            qDebug()<<"Cancel";
//        if(curTaskIdx.internalId()>0)ui->treeView->setCurrentIndex(curTaskIdx);
//            return;};

//    }
    if(curTaskIdx.internalId()>0)
    {
        markProgChange();
    }
    onTask=false;
    ui->checkTask->setEnabled(false);
    QString taskText=course->getTaskText(index);
 //ui->textBrowser->setText(taskText);



 if(taskText.right(4)==".htm" ||taskText.right(5)==".html" )
 {
     loadHtml(taskText);
498
 }else setTaskViewHtml(taskText);
Denis Khachko's avatar
Denis Khachko committed
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
  qDebug()<<"TaskText:"<<course->getTaskText(index);
 curTaskIdx=index;

 if(course->isTask(curTaskIdx.internalId()) && curTaskIdx.internalId()>0 && course->taskAvailable(curTaskIdx.internalId()))
   {
     ui->do_task->setEnabled(true);
     startTask();
     ui->do_task->setEnabled(false);
      ui->actionReset->setEnabled(true);
      QString testedText=course->getUserTestedText(curTaskIdx.internalId());
      qDebug()<<"TESTED TEXT"<<testedText;
      if(testedText!="")ui->actionTested->setEnabled(true);
   }
 else {
           ui->do_task->setEnabled(false);
           ui->actionReset->setEnabled(false);
           ui->actionTested->setEnabled(false);
       };
 };

void MainWindowTask::loadHtml(QString fileName)
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
{    
    const QString absolutePath = QDir(curDir).absoluteFilePath(fileName);
    const QUrl url = QUrl::fromLocalFile(absolutePath);
    setTaskViewUrl(url);
//    qDebug()<<"LoadHtml"<<fileName;
//    if(fileName.isEmpty())return;
//    QFile inp(curDir+'/'+fileName);
//    if  (!inp.open(QIODevice::ReadOnly))
//    {
//    QMessageBox::information( 0, "", trUtf8("Ошибка чтения: ") + fileName, 0,0,0);
//    return;
//    };
//    QString htmlData=QString::fromUtf8(inp.readAll());
//    //ui->textBrowser->setHtml(htmlData);

//    ui->webView->setHtml(htmlData,QUrl("file://"+curDir+'/'+fileName));
//    inp.close();
Denis Khachko's avatar
Denis Khachko committed
537 538 539 540 541 542 543 544 545 546

};
void MainWindowTask::startTask()
 {editRoot->hide();
    qDebug()<<"StartTask";
     if(curTaskIdx.internalId()<=0)
     {
         QMessageBox::about(NULL, trUtf8("Не выбрано задание"),trUtf8("Необходимо выбрать задание"));
         return;
     }
547
     if(course->csName(curTaskIdx.internalId()).toLower()!=CS)
Denis Khachko's avatar
Denis Khachko committed
548 549 550 551 552 553
     {
         QMessageBox::about(NULL, trUtf8("Неправильное окружение"),trUtf8("Необходим ")+course->csName(curTaskIdx.internalId()));
         return;
     }

     QString progFile=course->progFile(curTaskIdx.internalId());
Denis Khachko's avatar
Denis Khachko committed
554
//interface->setTesting(loadTestAlg(course->getTaskCheck(curTaskIdx)));
Denis Khachko's avatar
Denis Khachko committed
555 556 557 558 559 560 561 562 563
QFileInfo ioDir(curDir+"/"+course->progFile(curTaskIdx.internalId()));
qDebug()<<"PRG FILE"<<course->progFile(curTaskIdx.internalId());
if(ioDir.isFile())
     {
     interface->setParam("input dir",ioDir.absoluteFilePath());
     };
     task.isps=course->Modules(curTaskIdx.internalId());
     task.name=course->getTitle(curTaskIdx.internalId());
       qDebug()<<"ISPS"<<task.isps;
564
       task.fields.clear();
Denis Khachko's avatar
Denis Khachko committed
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
       for(int i=0;i<task.isps.count();i++)
       {
      // task.Scripts.append(loadScript(course->Script(curTaskIdx.internalId(),task.isps[i])));
       QStringList t_fields=course->Fields(curTaskIdx.internalId(),task.isps[i]);
       qDebug()<<"fields"<<t_fields;
       task.fields.clear();
        for(int j=0;j<t_fields.count();j++)
            {
                qDebug()<<"Cur Dir"<<curDir;
            task.fields.insertMulti(task.isps[i],curDir+'/'+t_fields[j]);
            qDebug()<<curDir+'/'+t_fields[j];

            };
        qDebug()<<"Fields!!!!"<<task.fields;
        }
       qDebug()<<"MODULES:"<<course->Modules(curTaskIdx.internalId());
Denis Khachko's avatar
Denis Khachko committed
581
  if(!interface->startNewTask(course->Modules(curTaskIdx.internalId()),&task))QMessageBox::about(NULL, trUtf8("Невозможно выполнить задание"),trUtf8("Нет неоходимых исполнителей"));
Denis Khachko's avatar
Denis Khachko committed
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
  if(course->getUserText(curTaskIdx.internalId())!="")
  {
      interface->setPreProgram(QVariant(course->getUserText(curTaskIdx.internalId())));
      ui->actionReset->setEnabled(true);
  }
   else
      if(!progFile.isEmpty())interface->setPreProgram(QVariant(curDir+'/'+progFile));



//qDebug()<<"Scripts "<<task.Scripts;
 ui->do_task->setEnabled(false);
 ui->checkTask->setEnabled(true);
 onTask=true;
 //ui->loadCurs->setEnabled(false);
 qDebug()<<"end load task";
 if(progChange.indexOf(curTaskIdx.internalId())==-1)progChange.append(curTaskIdx.internalId());
 };
 void MainWindowTask::checkTask()
 {
     qDebug()<<"CheckTASK";
     if(!onTask){qDebug()<<"!onTASK";return;};


markProgChange();
if(!cursWorkFile.exists()){

    QMessageBox::information( 0, "", trUtf8("Нужно завести файл рабочей тетради "), 0,0,0);
    saveCourse();
      };
course->setMark(curTaskIdx.internalId(),0);
Denis Khachko's avatar
Denis Khachko committed
613

Denis Khachko's avatar
Denis Khachko committed
614 615
     qDebug()<<"task"<<task.isps;
interface->startProgram(QVariant("TODO LOAD SCRIPT"),&task);
Denis Khachko's avatar
Denis Khachko committed
616 617 618 619
   //ui->loadCurs->setEnabled(false);

 };

Denis Khachko's avatar
Denis Khachko committed
620 621 622 623 624 625
 void MainWindowTask::lockControls()
{
    ui->splitter->setEnabled(false);
    ui->checkTask->setEnabled(false);
    ui->loadCurs->setEnabled(false);  
};
Denis Khachko's avatar
Denis Khachko committed
626

Denis Khachko's avatar
Denis Khachko committed
627 628 629 630 631 632
void MainWindowTask::unlockControls()
{
    ui->splitter->setEnabled(true);
    ui->checkTask->setEnabled(true);
    ui->loadCurs->setEnabled(true);  
};
Denis Khachko's avatar
Denis Khachko committed
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671

void  MainWindowTask::setMark(int mark)
{
    ui->loadCurs->setEnabled(true);
    if(!onTask)return;
    ui->loadCurs->setEnabled(true);
  qDebug()<<"ui->cource enabled!";
    ui->splitter->setEnabled(true);
    ui->actionTested->setEnabled(true);
    qDebug()<<"ui->treeView enabled!";
    ui->checkTask->setEnabled(true);
    if((course->taskMark(curTaskIdx.internalId())<mark) &&  (course->taskMark(curTaskIdx.internalId())>0))return;

    course->setUserTestedText(curTaskIdx.internalId(),interface->getText());
    qDebug()<<"Mark:"<<mark;
    course->setMark(curTaskIdx.internalId(),mark);
    changes.setMark(curTaskIdx.internalId(),mark);
    ui->treeView->dataChanged(curTaskIdx,curTaskIdx);
    //if(mark==10)onTask=false;else onTask=true;

};
QString MainWindowTask::loadScript(QString file_name)
{
    qDebug()<<"Script file name:"<<file_name;
    if(file_name.isEmpty())return "";
    QFile file(curDir+"/"+file_name);
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        QMessageBox::about(NULL, trUtf8("Ошибка"),trUtf8("Невозможно открыть ")+curDir+"/"+file_name);
        return "";
    };
    return file.readAll();
};


void MainWindowTask::saveCourse()
{
    editRoot->hide();
   markProgChange();
Victor Yacovlev's avatar
Victor Yacovlev committed
672 673 674 675 676 677 678 679 680 681 682 683 684 685
//    QFileDialog dialog(this,trUtf8("Сохранить изменения"),curDir+"/", "Work files(*.work.xml);;All files (*)");
//    dialog.setDefaultSuffix("work.xml");
//    dialog.setAcceptMode(QFileDialog::AcceptSave);
//    if(!dialog.exec())return;
//    QFileInfo fi(dialog.selectedFiles().first());
//    //curDir=fi.absolutePath ();
//    qDebug()<<"curDir"<<curDir;
//    QString fileName=dialog.selectedFiles().first();
   const QString fileName = QFileDialog::getSaveFileName(
               this,
               trUtf8("Сохранить изменения"),
               curDir,
               tr("Work files(*.work.xml);;All files (*)")
               );
Denis Khachko's avatar
Denis Khachko committed
686 687
   // QString type=fileName.right(9);
   // if(type!=".work.xml")fileName+=".work.xml";
Denis Khachko's avatar
Denis Khachko committed
688
    cursWorkFile.setFileName(fileName);
Denis Khachko's avatar
Denis Khachko committed
689
    updateLastFiles(fileName);
Denis Khachko's avatar
Denis Khachko committed
690 691 692 693 694
    saveCourseFile();

};
void MainWindowTask::saveCourseFile()
{
Denis Khachko's avatar
Denis Khachko committed
695
    if(isReadOnly)return;
Denis Khachko's avatar
Denis Khachko committed
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811
    qDebug()<<"Save cource file";
    QDomDocument saveXml;

    QDomElement	crsEl=saveXml.createElement("COURSE");
    QDomElement	fileEl=saveXml.createElement("FILE");
    QDomAttr crsAtt=saveXml.createAttribute("fileName");
    crsAtt.setValue(cursFile);
    fileEl.setAttributeNode(crsAtt);

    crsEl.appendChild(fileEl);
    saveXml.appendChild(crsEl);
    QDomElement	mrksEl=saveXml.createElement("MARKS");

    //USER PROGRAMS n TESTED PROGRAMS
    for(int i=0;i<progChange.count();i++){
    QDomElement	prgEl=saveXml.createElement("USER_PRG");
    QDomAttr testIdprg=saveXml.createAttribute("testId");
    testIdprg.setValue(QString::number(progChange[i]));
    QDomAttr userPrg=saveXml.createAttribute("prg");
    userPrg.setValue(course->getUserText(progChange[i]));
    prgEl.setAttributeNode(testIdprg);
    prgEl.setAttributeNode(userPrg);
    crsEl.appendChild(prgEl);

    QDomElement	prgElT=saveXml.createElement("TESTED_PRG");
    QDomAttr testIdprgT=saveXml.createAttribute("testId");
    testIdprgT.setValue(QString::number(progChange[i]));
    QDomAttr userPrgT=saveXml.createAttribute("prg");
    userPrgT.setValue(course->getUserTestedText(progChange[i]));
    prgElT.setAttributeNode(testIdprg);
    prgElT.setAttributeNode(userPrgT);
    crsEl.appendChild(prgElT);



     }
    //END USER PROGRAMS




    QMapIterator<int, int> i(changes.marksChanged);
    while (i.hasNext()) {
        i.next();
        QDomElement mrk=saveXml.createElement("MARK");
        QDomAttr testId=saveXml.createAttribute("testId");
        testId.setValue(QString::number(i.key()));
        QDomAttr mvalue=saveXml.createAttribute("mark");
        mvalue.setValue(QString::number(i.value()));
        mrk.setAttributeNode(testId);
        mrk.setAttributeNode(mvalue);
        mrksEl.appendChild(mrk);
    }
    crsEl.appendChild(mrksEl);





          if  (!cursWorkFile.open(QIODevice::WriteOnly))
          {
          QMessageBox::information( 0, "", trUtf8("Ошибка записи: ") + cursWorkFile.fileName(), 0,0,0);
          return;
          };
    cursWorkFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    cursWorkFile.write(saveXml.toByteArray());
    cursWorkFile.close();

};

void MainWindowTask::markProgChange()
{

    course->setUserText(curTaskIdx,interface->getText());
    if(progChange.indexOf(curTaskIdx.internalId())==-1)progChange.append(curTaskIdx.internalId());
    if(!cursWorkFile.exists())
    {
      qDebug()<<"!cursWorkFile";
    }else saveCourseFile();

}
QString MainWindowTask::getFileName(QString fileName)
{
    QFileInfo finf(fileName);
    qDebug()<<"GET FILE!";
//    QFileDialog dialog(this,trUtf8("Открыть файл"),curDir, finf.fileName()+" *.kurs.xml");
//    dialog.setAcceptMode(QFileDialog::AcceptOpen);
//    if(!dialog.exec())return "";
//    QFileInfo fi(dialog.selectedFiles().first());



    QString	File=QFileDialog::getOpenFileName(this, QString::fromUtf8 ("Открыть файл"), curDir,  finf.fileName()+" *.kurs.xml");
    QFileInfo fi(File);


    return File;
};

void MainWindowTask::resetTask()
{
    QString progFile=course->progFile(curTaskIdx.internalId());


     if(!progFile.isEmpty())interface->setPreProgram(QVariant(curDir+'/'+progFile));
    course->setUserText(curTaskIdx,"");


};
void MainWindowTask::Close()
{
    qDebug()<<cursFile;
    if(cursFile!="")markProgChange();
    saveBaseKurs();
    close();
};
Denis Khachko's avatar
Denis Khachko committed
812 813
void MainWindowTask::showEvent(QShowEvent * event)
{
814
    ui->splitter->restoreState(settings->value("Window/SpliterState")
Denis Khachko's avatar
Denis Khachko committed
815
                 .toByteArray());
816
    QByteArray settlist=settings->value("Window/SpliterPos").toByteArray();
Denis Khachko's avatar
Denis Khachko committed
817 818 819 820
    qDebug()<<settlist;
    ui->splitter->restoreGeometry(settlist);
};

Denis Khachko's avatar
Denis Khachko committed
821 822
void MainWindowTask::closeEvent(QCloseEvent *event)
{
Denis Khachko's avatar
Denis Khachko committed
823 824 825
    
   
    
826 827 828
    settings->setValue("Window/SpliterPos",ui->splitter->saveGeometry());
    settings->setValue("Window/SpliterState",ui->splitter->saveState());
    settings->flush();
Denis Khachko's avatar
Denis Khachko committed
829 830
    qDebug()<<ui->splitter->saveGeometry();
    qDebug()<<"CLOSE TASK WINDOW";
Denis Khachko's avatar
Denis Khachko committed
831 832 833 834 835 836 837
  if(!course)return;
  qDebug()<<"START CLOSE TASK WINDOW";
  if(!cursWorkFile.exists())
  {
      QMessageBox::StandardButton ans;
            ans = QMessageBox::question(this, trUtf8("Курсы"), trUtf8("Вы хотите сохранить работу?"),
                              QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes);
Victor Yacovlev's avatar
Victor Yacovlev committed
838
            if (ans == QMessageBox::No)
Denis Khachko's avatar
Denis Khachko committed
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978

            {
                event->accept();
                if(course)delete course;
                course=NULL;
                return;
             };
            if(ans == QMessageBox::Cancel){event->ignore();
                return;};

            saveCourse();
  }
        markProgChange();
        qDebug()<<"CLOSE TASK WINDOW";
        close();

};
void MainWindowTask::returnTested()
{
   interface->setPreProgram(QVariant(course->getUserTestedText(curTaskIdx.internalId())));
};
QString MainWindowTask::loadTestAlg(QString file_name)
{
    if(file_name.isEmpty())return "";
    QFile file(curDir+"/"+file_name);
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {

        QMessageBox::about(NULL, trUtf8("Ошибка"),trUtf8("Невозможно открыть ")+curDir+"/"+file_name);
        return "";
    };
    QTextStream ts(&file);
    ts.setCodec("UTF-16LE");
    QString testalg= ts.readAll();
    file.close();

    qDebug()<<"Test alg"<<testalg;
    return testalg;
}
void MainWindowTask::aboutToQuit()
{
  close();
};
void MainWindowTask:: customContextMenuRequested(QPoint  pos)
{
editRoot->hide();
    if(!isTeacher)return;

    curTaskIdx=ui->treeView->currentIndex();
    if(curTaskIdx.internalId()==0)
    {setEditTaskEnabled(false);
        ui->actionEdit->setEnabled(true);
        ui->addDeep->setEnabled(true);
    }else setEditTaskEnabled(true);
        if(!baseKursFile.isReadable())
    {
            return;
        };
    pos.setY(pos.y()+ui->mainToolBar->height());
    customMenu.move(pos+this->pos()+ui->centralWidget->pos());
    customMenu.show();
  qDebug()<<"Menu Request!!!";
};
void MainWindowTask::addTask()
{
    qDebug()<<"Add task";
       QModelIndex par=curTaskIdx.parent();
course->addSiblingTask(curTaskIdx.internalId());
ui->treeView->collapse(par);
ui->treeView->expand(par);
};
void MainWindowTask::addDeepTask(){
    qDebug()<<"Add deep task";
       QModelIndex par=curTaskIdx.parent();
course->addDeepTask(curTaskIdx.internalId());
ui->treeView->collapse(par);
ui->treeView->expand(par);
saveBaseKurs();
if(curTaskIdx.internalId()==0)
 {
      loadCourseData(baseKursFile.absoluteFilePath());
 }
};
void MainWindowTask::deleteTask()
{
    QModelIndex par=curTaskIdx.parent();
course->removeNode(curTaskIdx.internalId());
ui->treeView->collapse(par);
ui->treeView->expand(par);
};

void MainWindowTask::saveKurs()
{
    qDebug()<<"Save Kurs teacher";
    QFile cursKursFile("../../test.kurs.xml");
    if  (!cursKursFile.open(QIODevice::WriteOnly))
    {
    QMessageBox::information( 0, "", trUtf8("Ошибка записи: ") + cursKursFile.fileName(), 0,0,0);
    return;
    };

    cursKursFile.write(course->document()->toByteArray());
    cursKursFile.close();
    ui->actionEdit->setEnabled(true);
};
void MainWindowTask::saveBaseKurs()
{
    QFile cursKursFile(baseKursFile.absoluteFilePath());
    if  (!cursKursFile.open(QIODevice::WriteOnly))
    {
    QMessageBox::information( 0, "", trUtf8("Ошибка записи: ") + cursKursFile.fileName(), 0,0,0);
    return;
    };

    cursKursFile.write(course->document()->toByteArray());
    cursKursFile.close();
}

void MainWindowTask::saveKursAs()
{
    QString dir=curDir;
    QDir chD(curDir);
    if(!chD.exists())dir=QDir::homePath ();
     QFileDialog dialog(this,trUtf8("Сохранить файл курса"),dir, "(*.kurs.xml )");
     dialog.setAcceptMode(QFileDialog::AcceptSave);

     if(!dialog.exec())return;
     QFileInfo fi(dialog.selectedFiles().first());
     baseKursFile=fi;






     saveBaseKurs();

;
};
void MainWindowTask:: setTeacher(bool mode)
979
{
Denis Khachko's avatar
Denis Khachko committed
980 981 982 983 984
    ui->actionup->setVisible(false);
     ui->actionDown->setVisible(false);
    isTeacher=mode;};
void MainWindowTask::editTask()
{
Denis Khachko's avatar
Denis Khachko committed
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
//if(curTaskIdx.internalId()==0)//ROOT
//    {
//
//    QRect rect=ui->treeView->visualRect(curTaskIdx);
//    editRoot->resize(rect.width(),rect.height());
//     editRoot->setText(course->rootText());
//    editRoot->move(rect.topLeft());
//    editRoot->show();
//    return;
//     };
//    QModelIndex par=curTaskIdx.parent();
//
//editDialog->setTitle(course->getTitle(curTaskIdx.internalId()));
//editDialog->setDesc(course->getTaskText(curTaskIdx));
//editDialog->setProgram(course->progFile(curTaskIdx.internalId()));
//QStringList isps=course->Modules(curTaskIdx.internalId());
//
//if(isps.count()>0)editDialog->setUseIsps(isps.first());
//   else editDialog->setUseIsps("");
//
//if(course->Modules(curTaskIdx.internalId()).count()>0)editDialog->setEnvs(course->Fields(curTaskIdx.internalId(),isps.first()));
// else editDialog->setEnvs(QStringList());
//editDialog->setCurDir(curDir);
// if(editDialog->exec ())
// {
//  course->setUserText(curTaskIdx.internalId(),"");
//  course->setTitle(curTaskIdx.internalId(),editDialog->getTitle());
//  course->setDesc(curTaskIdx.internalId(),editDialog->getDesc());
//  qDebug()<<"Desc"<<editDialog->getDesc();
//  course->setProgram(curTaskIdx.internalId(),editDialog->getProgram());
//  qDebug()<<"EDIT ISPS"<<editDialog->getUseIsps();
//
//
//  course->setIsps(curTaskIdx,editDialog->getUseIsps());
//  qDebug()<<"PRG"<<editDialog->getProgram();
//  if(course->Modules(curTaskIdx.internalId()).count()>0)course->setIspEnvs(curTaskIdx,course->Modules(curTaskIdx.internalId()).first(),editDialog->getEnvs());
// showText(curTaskIdx);
//  ui->treeView->collapse(par);
//  ui->treeView->expand(par);
//  qDebug()<<"Set task isps:"<<course->Modules(curTaskIdx.internalId());
//  qDebug()<<"EDIT DIALOG EXEC OK";
//  saveBaseKurs();
//  resetTask();
// };
//
Denis Khachko's avatar
Denis Khachko committed
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046
};

void MainWindowTask::setEditTaskEnabled(bool flag)
{
   // ui->actionEdit->setEnabled(flag);
    ui->actionup->setEnabled(flag);
    ui->actionDown->setEnabled(flag);

    ui->actionSaveKas->setEnabled(flag);
    ui->actionAdd->setEnabled(flag);
    ui->actionRemove->setEnabled(flag);
    ui->addDeep->setEnabled(flag);
};

void MainWindowTask::newKurs()
{

Denis Khachko's avatar
Denis Khachko committed
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
// if(newDialog->exec())
// {
//    QFile newKurs(newDialog->fileName());
//
//    if  (!newKurs.open(QIODevice::WriteOnly))
//    {
//    QMessageBox::information( 0, "", trUtf8("Ошибка записи: ") + newKurs.fileName(), 0,0,0);
//    return;
//    };
//    QString toWr="<?xml version='1.0' encoding='UTF-8'?>\n";
//    newKurs.write(toWr.toUtf8());
//    toWr="<KURS xml:id=\"0\" xml:name=\""+newDialog->name()+"\">\n";
//    newKurs.write(toWr.toUtf8());
//
//    toWr=QString::fromUtf8("<T xml:id=\"1\" xml:name=\"Новое задание\">\n<DESC>Нет Описания</DESC>\n<CS>Кумир</CS>\n <ISP xml:ispname=\"Robot\">\n</ISP>\n<READY>false</READY>\n</T>\n");
//    newKurs.write(toWr.toUtf8());
//
//    toWr="</KURS>\n";
//    newKurs.write(toWr.toUtf8());
//    newKurs.close();
//    loadCourseData(newKurs.fileName());
//    baseKursFile=QFileInfo(newKurs);
//    curDir=baseKursFile.absolutePath();
//    ui->actionEdit->setEnabled(true);
// }
Denis Khachko's avatar
Denis Khachko committed
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089

};
  void  MainWindowTask::createMoveMenu()
{

  }
void MainWindowTask::endRootEdit()
{
    course->setRootText(editRoot->text());
   editRoot->hide();
}
 void MainWindowTask::cancelRootEdit()
 {  editRoot->hide();
 };
void MainWindowTask::lockCheck()
{
    ui->checkTask->setDisabled(true);
}