/
StudentWindow.cpp
53 lines (41 loc) · 2.31 KB
/
StudentWindow.cpp
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
#include "StudentWindow.h"
StudentWindow::StudentWindow(DatabaseLayer *db, User loggedInUser) : MainWindow(db, loggedInUser, new StudentMainWidget())
{
this->studentMainWidget = (StudentMainWidget *)mainWidget;
this->lessonWidget = new StudentLessonWidget();
this->testWidget = new TestWidget(db, email);
connect(this->studentMainWidget, SIGNAL(selectedLesson(int)), this, SLOT(showLessonWidget(int)));
connect(db, SIGNAL(newLessonCreated()), this, SLOT(newLessonCreated()));
connect(this->lessonWidget, SIGNAL(prepared()), this->lessonWidget, SLOT(show()));
connect(this->lessonWidget, SIGNAL(prepared()), this->studentMainWidget, SLOT(hide()));
connect(this->lessonWidget, SIGNAL(transitLessons()), this->studentMainWidget, SLOT(show()));
connect(this->lessonWidget, SIGNAL(logOut()), this, SLOT(save()));
connect(this->lessonWidget, SIGNAL(logOut()), this, SLOT(logoff()));
connect(this->lessonWidget, SIGNAL(transitLessons()), this->lessonWidget, SLOT(hide()));
connect(this->lessonWidget, SIGNAL(logOut()), this->lessonWidget, SLOT(close()));
QObject::connect(this->studentMainWidget->logOutButton, SIGNAL(clicked()), this, SLOT(save()));
}
void StudentWindow::showLessonWidget(int i)
{
LessonsDB *lessons = LessonsDBController::getDB();
Lesson lesson = lessons->getLessons().at(i);
LessonsDBController::setIndex(i);
this->lessonWidget->prepare(&lesson);
connect(this->lessonWidget->menuWidget->lessonButton, SIGNAL(clicked()), this->lessonWidget, SLOT(transit()));
connect(this->lessonWidget->menuWidget->logoutButton, SIGNAL(clicked()), this->lessonWidget, SLOT(exit()));
connect(this->lessonWidget->menuWidget, SIGNAL(selectTest(bool)), this->testWidget, SLOT(prepare(bool)));
connect(this->testWidget, SIGNAL(prepared()), this->testWidget, SLOT(show()));
connect(this->testWidget, SIGNAL(prepared()), this->lessonWidget, SLOT(hide()));
connect(this->testWidget, SIGNAL(transitLessonStudent()), this->testWidget, SLOT(hide()));
connect(this->testWidget, SIGNAL(transitLessonStudent()), this->lessonWidget, SLOT(show()));
}
void StudentWindow::newLessonCreated()
{
QMessageBox::information(0, "", "New Lesson Created");
db->loadLessons();
this->studentMainWidget->updateTable();
}
void StudentWindow::save()
{
db->saveMarks();
}