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

Cource manager. Lock /unlock actions

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