-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteacheroperate.cpp
More file actions
55 lines (48 loc) · 1.59 KB
/
Copy pathteacheroperate.cpp
File metadata and controls
55 lines (48 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "teacheroperate.h"
#include "ui_teacheroperate.h"
#include "Enroll.h"
#include "CommunicationProtocol.h"
TeacherOperate::TeacherOperate(QWidget *parent) :
QWidget(parent),
ui(new Ui::TeacherOperate)
{
ui->setupUi(this);
qDebug() << "a new TeacherOperate";
examWidget = new ExamTeacher;
scoreWidget = new Score;
ui->stackedWidget->addWidget(examWidget);
ui->stackedWidget->addWidget(scoreWidget);
ui->stackedWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
connect(ui->listWidget, SIGNAL(currentRowChanged(int))
, ui->stackedWidget, SLOT(setCurrentIndex(int)));
}
TeacherOperate::~TeacherOperate()
{
delete ui;
}
TeacherOperate &TeacherOperate::getInstance()
{
static TeacherOperate instance;
return instance;
}
void TeacherOperate::handleGetExams(const QJsonObject &jsonObj)
{
CommunicationProtocol::GetExamsResponse response = CommunicationProtocol::GetExamsResponse::fromJson(jsonObj);
qDebug() << "get exams = " << response.exams;
if(response.exams.size() > 0){
examWidget->setExams(response.exams);
}
}
void TeacherOperate::handleGetScores(const QJsonObject &jsonObj)
{
CommunicationProtocol::GetScoresResponse response = CommunicationProtocol::GetScoresResponse::fromJson(jsonObj);
qDebug() << "get exams = " << response.scores.size();
if(response.scores.size() > 0){
scoreWidget->setScores(response.scores);
}
}
void TeacherOperate::closeEvent(QCloseEvent *event)
{
Enroll::getInstance().show();
QWidget::closeEvent(event); // 调用基类的关闭事件处理
}