Commit a6442965 authored by Victor Yacovlev's avatar Victor Yacovlev

Merge branch 'master' of git.lpm.org.ru:niisi/kumir2

parents dcf05e6d d6203b81
...@@ -143,7 +143,7 @@ QVariant courseModel::data(const QModelIndex &index, int role) const ...@@ -143,7 +143,7 @@ QVariant courseModel::data(const QModelIndex &index, int role) const
QDomNode child_n=nodeById(child.internalId(),root); QDomNode child_n=nodeById(child.internalId(),root);
// if(child_n.isNull())return QModelIndex(); // if(child_n.isNull())return QModelIndex();
QDomNode par=child_n.parentNode(); QDomNode par=child_n.parentNode();
if(par.toElement().attribute("id").toInt()==0) return QModelIndex(); if(par.toElement().attribute("id").toInt()==0) return createIndex(0,0,0);
return createIndex(domRow(par),0,idByNode(par)); return createIndex(domRow(par),0,idByNode(par));
}; };
int courseModel::columnCount(const QModelIndex &parent)const int courseModel::columnCount(const QModelIndex &parent)const
...@@ -207,7 +207,7 @@ QVariant courseModel::data(const QModelIndex &index, int role) const ...@@ -207,7 +207,7 @@ QVariant courseModel::data(const QModelIndex &index, int role) const
} }
QModelIndex courseModel::createMyIndex(int row,int column,QModelIndex parent) const QModelIndex courseModel::createMyIndex(int row,int column,QModelIndex parent) const
{ {
if(!parent.isValid())return QModelIndex(); if(!parent.isValid())return createIndex(0,0,0);
int id=parent.internalId(); int id=parent.internalId();
if(id<0)return QModelIndex(); if(id<0)return QModelIndex();
QDomNode par=nodeById(id,root); QDomNode par=nodeById(id,root);
...@@ -446,7 +446,7 @@ QString courseModel::Script(int index,QString isp) ...@@ -446,7 +446,7 @@ QString courseModel::Script(int index,QString isp)
} }
csEl=csEl.nextSiblingElement("ISP"); csEl=csEl.nextSiblingElement("ISP");
}; };
return QDomElement();
}; };
void courseModel::removeEvn(QDomElement ispElement,QString fieldStr) void courseModel::removeEvn(QDomElement ispElement,QString fieldStr)
{ {
......
#ifndef COURSE_MODEL_H #ifndef COURSE_MODEL_H
#define COURSE_MODEL_H #define COURSE_MODEL_H
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QApplication>
#include <QFile> #include <QFile>
#include <QDebug> #include <QDebug>
#include <QStringList> #include <QStringList>
#include <QFont> #include <QFont>
#include <QDomDocument> #include <QDomDocument>
#include <QIcon> #include <QIcon>
#include <QUrl>
......
...@@ -86,7 +86,6 @@ cursFile=""; ...@@ -86,7 +86,6 @@ cursFile="";
// QMessageBox::information( 0, "", trUtf8("Setup add "), 0,0,0); // QMessageBox::information( 0, "", trUtf8("Setup add "), 0,0,0);
ui->ispSel->addItem("Robot"); ui->ispSel->addItem("Robot");
ui->ispSel->addItem(trUtf8("Водолей")); ui->ispSel->addItem(trUtf8("Водолей"));
ui->ispSel->addItem(trUtf8("Файл ввода"));
ui->actionup->setIcon(QIcon(":/arrow_up.png")); ui->actionup->setIcon(QIcon(":/arrow_up.png"));
ui->actionDown->setIcon(QIcon(":/arrow_down.png")); ui->actionDown->setIcon(QIcon(":/arrow_down.png"));
changed=false; changed=false;
...@@ -524,7 +523,7 @@ void MainWindowTask::startTask() ...@@ -524,7 +523,7 @@ void MainWindowTask::startTask()
} }
QString progFile=course->progFile(curTaskIdx.internalId()); QString progFile=course->progFile(curTaskIdx.internalId());
csInterface->setTesting(loadTestAlg(course->getTaskCheck(curTaskIdx))); interface->setTesting(loadTestAlg(course->getTaskCheck(curTaskIdx)));
task.isps=course->Modules(curTaskIdx.internalId()); task.isps=course->Modules(curTaskIdx.internalId());
qDebug()<<"ISPS"<<task.isps; qDebug()<<"ISPS"<<task.isps;
for(int i=0;i<task.isps.count();i++) for(int i=0;i<task.isps.count();i++)
...@@ -544,16 +543,14 @@ void MainWindowTask::startTask() ...@@ -544,16 +543,14 @@ void MainWindowTask::startTask()
qDebug()<<"Fields!!!!"<<task.fields; qDebug()<<"Fields!!!!"<<task.fields;
} }
qDebug()<<"MODULES:"<<course->Modules(curTaskIdx.internalId()); qDebug()<<"MODULES:"<<course->Modules(curTaskIdx.internalId());
if(!csInterface->startNewTask(course->Modules(curTaskIdx.internalId()))) if(!interface->startNewTask(course->Modules(curTaskIdx.internalId())))QMessageBox::about(NULL, trUtf8("Невозможно выполнить задание"),trUtf8("Нет неоходимых исполнителей"));
QMessageBox::about(NULL, trUtf8("Невозможно выполнить задание"),trUtf8("Нет неоходимых исполнителей"));
if(course->getUserText(curTaskIdx.internalId())!="") if(course->getUserText(curTaskIdx.internalId())!="")
{ {
csInterface->setPreProgram(QVariant(course->getUserText(curTaskIdx.internalId()))); interface->setPreProgram(QVariant(course->getUserText(curTaskIdx.internalId())));
ui->actionReset->setEnabled(true); ui->actionReset->setEnabled(true);
} }
else else
if(!progFile.isEmpty()) if(!progFile.isEmpty())interface->setPreProgram(QVariant(curDir+'/'+progFile));
csInterface->setPreProgram(QVariant(curDir+'/'+progFile));
...@@ -580,7 +577,7 @@ if(!cursWorkFile.exists()){ ...@@ -580,7 +577,7 @@ if(!cursWorkFile.exists()){
saveCourse(); saveCourse();
}; };
course->setMark(curTaskIdx.internalId(),0); course->setMark(curTaskIdx.internalId(),0);
csInterface->startProgram(QVariant("TODO LOAD SCRIPT")); interface->startProgram(QVariant("TODO LOAD SCRIPT"));
ui->treeView->setEnabled(false); ui->treeView->setEnabled(false);
ui->loadCurs->setEnabled(true); ui->loadCurs->setEnabled(true);
}; };
...@@ -685,7 +682,7 @@ void MainWindowTask::markProgChange() ...@@ -685,7 +682,7 @@ void MainWindowTask::markProgChange()
qDebug()<<"Dummy call MainWindowTask::markProgChange()"; qDebug()<<"Dummy call MainWindowTask::markProgChange()";
return; return;
course->setUserText(curTaskIdx,csInterface->getText()); course->setUserText(curTaskIdx,interface->getText());
if(progChange.indexOf(curTaskIdx.internalId())==-1)progChange.append(curTaskIdx.internalId()); if(progChange.indexOf(curTaskIdx.internalId())==-1)progChange.append(curTaskIdx.internalId());
if(!cursWorkFile.exists()) if(!cursWorkFile.exists())
{ {
...@@ -713,28 +710,8 @@ void MainWindowTask::Close() ...@@ -713,28 +710,8 @@ void MainWindowTask::Close()
//saveBaseKurs(); //saveBaseKurs();
close(); close();
}; };
void MainWindowTask::showEvent(QShowEvent * event)
{
QStringList settlist=settings->value("SpliterPos").toString().split(" ");
QList<int> sizes;
for(int i=0;i<settlist.count();i++ )
{
sizes.append(settlist.at(i).toInt());
}
ui->splitter->setSizes(sizes);
};
void MainWindowTask::closeEvent(QCloseEvent *event) void MainWindowTask::closeEvent(QCloseEvent *event)
{ {
QString sizes="";
for(int i=0;i<ui->splitter->sizes().count();i++ )
{
sizes+=QString::number(ui->splitter->sizes().at(i))+" ";
}
settings->setValue("SpliterPos",sizes);
qDebug()<<"CLOSE TASK WINDOW";
if(!course) if(!course)
{close(); {close();
return; return;
...@@ -745,7 +722,7 @@ void MainWindowTask::closeEvent(QCloseEvent *event) ...@@ -745,7 +722,7 @@ void MainWindowTask::closeEvent(QCloseEvent *event)
QMessageBox::StandardButton ans; QMessageBox::StandardButton ans;
ans = QMessageBox::question(this, trUtf8("Курсы"), trUtf8("Вы хотите сохранить работу?"), ans = QMessageBox::question(this, trUtf8("Курсы"), trUtf8("Вы хотите сохранить работу?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes); QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes);
if (ans == QMessageBox::No) if ((ans == QMessageBox::No))
{ {
event->accept(); event->accept();
...@@ -758,14 +735,14 @@ void MainWindowTask::closeEvent(QCloseEvent *event) ...@@ -758,14 +735,14 @@ void MainWindowTask::closeEvent(QCloseEvent *event)
saveBaseKurs(); saveBaseKurs();
} }
;
qDebug()<<"CLOSE TASK WINDOW";
close(); close();
}; };
void MainWindowTask::returnTested() void MainWindowTask::returnTested()
{ {
csInterface->setPreProgram(QVariant(course->getUserTestedText(curTaskIdx.internalId()))); interface->setPreProgram(QVariant(course->getUserTestedText(curTaskIdx.internalId())));
}; };
QString MainWindowTask::loadTestAlg(QString file_name) QString MainWindowTask::loadTestAlg(QString file_name)
{ {
...@@ -1083,7 +1060,6 @@ QString MainWindowTask::getFileTypes() ...@@ -1083,7 +1060,6 @@ QString MainWindowTask::getFileTypes()
{ {
if(ui->ispList->currentItem()->text()=="Robot")return "(*.fil)"; if(ui->ispList->currentItem()->text()=="Robot")return "(*.fil)";
if(ui->ispList->currentItem()->text()==trUtf8("Водолей"))return "(*.vod)"; if(ui->ispList->currentItem()->text()==trUtf8("Водолей"))return "(*.vod)";
if(ui->ispList->currentItem()->text()==trUtf8("Файл ввода"))return "(*.txt)";
return "(*.*)"; return "(*.*)";
} }
......
...@@ -33,16 +33,12 @@ class MainWindowTask : public QMainWindow { ...@@ -33,16 +33,12 @@ class MainWindowTask : public QMainWindow {
public: public:
MainWindowTask(QWidget *parent = 0); MainWindowTask(QWidget *parent = 0);
~MainWindowTask(); ~MainWindowTask();
void setInterface(CSInterface * csInterface){this->csInterface=csInterface;}; void setInterface(CSInterface * csInterface){interface=csInterface;};
void setCS(QString cs){CS=cs;}; void setCS(QString cs){CS=cs;};
KumZadanie task; KumZadanie task;
void setup(); void setup();
QString getFileName(QString fileName); QString getFileName(QString fileName);
QFileInfo baseCourceFile()
{
return baseKursFile;
}
public slots: public slots:
void aboutToQuit (); void aboutToQuit ();
void loadCourse(); void loadCourse();
...@@ -88,7 +84,7 @@ public slots: ...@@ -88,7 +84,7 @@ public slots:
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void showEvent(QShowEvent * event);
private: private:
bool checkInList(int id,QModelIndexList list);//Поиск id среди списка индексов bool checkInList(int id,QModelIndexList list);//Поиск id среди списка индексов
void enableMkSect(bool flag); void enableMkSect(bool flag);
...@@ -107,10 +103,9 @@ private: ...@@ -107,10 +103,9 @@ private:
QString curDir; QString curDir;
courseModel* course; courseModel* course;
QModelIndex curTaskIdx; QModelIndex curTaskIdx;
CSInterface * csInterface; CSInterface * interface;
QString CS; QString CS;
bool onTask; bool onTask;
QMenu * practMenu;
courseChanges changes; courseChanges changes;
QString cursFile; QString cursFile;
QList<int> progChange; QList<int> progChange;
......
...@@ -41,7 +41,7 @@ class taskControlInterface ...@@ -41,7 +41,7 @@ class taskControlInterface
public: public:
virtual void start(QString csName)=0; virtual void start(QString csName)=0;
virtual void setCSmode(int mode)=0; virtual void setCSmode(int mode)=0;
virtual void setCSinterface(CSInterface* csInterface)=0; virtual void setCSinterface(CSInterface* interface)=0;
virtual void setWindowGeometry(QRect retc)=0; virtual void setWindowGeometry(QRect retc)=0;
virtual void show()=0; virtual void show()=0;
virtual void checkFinished(int mark)=0; virtual void checkFinished(int mark)=0;
......
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