Commit 36a0453e authored by Denis Khachko's avatar Denis Khachko

Cource manager. Lock /unlock actions

parent 99867a35
......@@ -18,9 +18,12 @@ Plugin::Plugin()
MW->setup();
mainWindow_=MW;
field_no=0;
prevFld=new QAction("Предыдущая обстановка",this);
nextFld=new QAction("Следующая обстановка",this);
prevFld=new QAction(trUtf8("Предыдущая обстановка"),this);
nextFld=new QAction(trUtf8("Следующая обстановка"),this);
connect(nextFld,SIGNAL(triggered()),this,SLOT(nextField()));
connect(prevFld,SIGNAL(triggered()),this,SLOT(prevField()));
nextFld->setEnabled(false);
prevFld->setEnabled(false);
}
QList<QMenu*> Plugin::menus()const
{
......@@ -81,6 +84,15 @@ bool Plugin::startNewTask(QStringList isps,KumZadanie* task)
qDebug()<<"Set field"<<task->field(isps.at(i), field_no);
actor->loadActorData(field_data);
}
if(task->minFieldCount()>1){
nextFld->setEnabled(true);
prevFld->setEnabled(false);
}else
{
nextFld->setEnabled(false);
prevFld->setEnabled(false);
}
cur_task=task;
return true;
};
QWidget* Plugin::mainWindow() const
......@@ -98,23 +110,27 @@ AI * Plugin::getActor(QString name)
}
return NULL;
}
void Plugin::checkNext(KumZadanie* task)
{
GI * gui = ExtensionSystem::PluginManager::instance()->findPlugin<GI>();
for(int i=0;i<task->isps.count();i++)
void Plugin::selectNext(KumZadanie* task)
{
AI* actor=getActor(task->isps.at(i));
if(!actor)
for(int i=0;i<task->isps.count();i++)
{
QMessageBox::information( NULL, "", QString::fromUtf8("Нет исполнтеля:")+task->isps.at(i), 0,0,0);
return;
}
//TODO LOAD FIELDS;
QFile* field_data=new QFile(task->field(task->isps.at(i), field_no));
actor->loadActorData(field_data);
AI* actor=getActor(task->isps.at(i));
if(!actor)
{
QMessageBox::information( NULL, "", QString::fromUtf8("Нет исполнтеля:")+task->isps.at(i), 0,0,0);
return;
}
//TODO LOAD FIELDS;
QFile* field_data=new QFile(task->field(task->isps.at(i), field_no));
actor->loadActorData(field_data);
}
}
void Plugin::checkNext(KumZadanie* task)
{
GI * gui = ExtensionSystem::PluginManager::instance()->findPlugin<GI>();
selectNext(task);
gui->startTesting();
};
void Plugin::startProgram(QVariant param,KumZadanie* task)
......@@ -183,17 +199,42 @@ void Plugin::changeCurrentDirectory(const QString &path)
}
void Plugin::nextField()
{
if(field_no<cur_task->minFieldCount() )
{
field_no++;
selectNext(cur_task);
}
prevFld->setEnabled(field_no>0);
nextFld->setEnabled((field_no+1)<cur_task->minFieldCount() && cur_task->minFieldCount()>0);
};
void Plugin::prevField()
{
if(field_no>-1 )
{
field_no--;
selectNext(cur_task);
}
prevFld->setEnabled(field_no>0);
nextFld->setEnabled(field_no<cur_task->minFieldCount() && cur_task->minFieldCount()>0);
};
void Plugin::lockContrls()
{
prevFld->setEnabled(false);
nextFld->setEnabled(false);
}
void Plugin::changeGlobalState(ExtensionSystem::GlobalState old,
ExtensionSystem::GlobalState current)
{
if(current==ExtensionSystem::GS_Running)MW->lockControls();
if(current==ExtensionSystem::GS_Observe)MW->unlockControls();
if(current==ExtensionSystem::GS_Running)
{MW->lockControls();
nextFld->setEnabled(false);
prevFld->setEnabled(false);
};
if(current==ExtensionSystem::GS_Observe)
{MW->unlockControls();
prevFld->setEnabled(field_no>0);
nextFld->setEnabled(field_no<cur_task->minFieldCount() && cur_task->minFieldCount()>0);
};
}
QString Plugin::initialize(const QStringList &arguments)
......@@ -211,6 +252,8 @@ QString Plugin::initialize(const QStringList &arguments)
QString error;
isp_no=0;
field_no=0;
courseMenu->addAction(nextFld);
courseMenu->addAction(prevFld);
return error;
}
......
......@@ -40,6 +40,7 @@ public slots:
void setTestingResult(ProgramRunStatus status, int value);
void nextField();
void prevField();
void lockContrls();
private /*methods*/:
void saveSession() const;
void restoreSession();
......@@ -61,6 +62,7 @@ private /*fields*/:
MainWindowTask* MW;
bool setTextFromFile(QString fname);
int isp_no,field_no;
void selectNext(KumZadanie* task);
KumZadanie* cur_task;
};
......
......@@ -248,7 +248,8 @@ void MainWindowTask::loadCourse()
}else ui->webView->setHtml(cText);
if(isTeacher)ui->actionEdit->setEnabled(true);
setWindowTitle(course->name()+trUtf8(" - Практикум"));
interface->lockContrls();
ui->checkTask->setEnabled(false);
};
......@@ -391,6 +392,7 @@ if(ioDir.isFile())
task.isps=course->Modules(curTaskIdx.internalId());
task.name=course->getTitle(curTaskIdx.internalId());
qDebug()<<"ISPS"<<task.isps;
task.fields.clear();
for(int i=0;i<task.isps.count();i++)
{
// task.Scripts.append(loadScript(course->Script(curTaskIdx.internalId(),task.isps[i])));
......
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