-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudentmanageprojectcontroller.cpp
More file actions
98 lines (71 loc) · 2.32 KB
/
Copy pathstudentmanageprojectcontroller.cpp
File metadata and controls
98 lines (71 loc) · 2.32 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "studentmanageprojectcontroller.h"
#include "studentmanageprojectview.h"
#include "project.h"
#include "session.h"
#include "logindialog.h"
#include "Database.h"
#include <QDebug>
#include "studentprojectregisterview.h"
StudentManageProjectController *StudentManageProjectController::instance=0;
StudentManageProjectController::StudentManageProjectController():QObject(),
database(Database::getInstance())
{
}
int StudentManageProjectController::init(){
allProjects = database->getProjectsByStudent(Session::getStudent().getID());
QList<QString> projectTitles;
QString tempTitle;
for(int i=0;i<allProjects.count();i++){
tempTitle = allProjects.at(i)->getTitle();
projectTitles << tempTitle;
}
studentManageProjectView->updateProjectsList(projectTitles);
if(allProjects.count() > 0)
{
studentManageProjectView->updateDetailedView(*allProjects.at(0));
selectedProject = allProjects.at(0);
}
return 1;
}
int StudentManageProjectController::updateSelectedProject(const int& index){
if (allProjects.count() > 0)
{
selectedProject=allProjects.at(index);
if(selectedProject != NULL){
studentManageProjectView->updateDetailedView(*selectedProject);
return 1;
}
else return 0;
}
return 0;
}
int StudentManageProjectController::goStudentRegisterProjectView()
{
studentManageProjectView->close();
studentProjectRegisterView studentrojectRegisterView;
studentrojectRegisterView.exec();
return 0;
}
int StudentManageProjectController::gotoLoginDialog(){
studentManageProjectView->close();
LoginDialog login;
login.exec();
}
int StudentManageProjectController::unregisterFromProject(){
if(database->removeStudentFromProject(selectedProject->getID(),Session::getStudent()))
{
allProjects.removeOne(selectedProject);
return 1;
}
else return 0;
}
int StudentManageProjectController::setView(StudentManageProjectView *view)
{
studentManageProjectView = view;
}
StudentManageProjectController* StudentManageProjectController::getInstance(){
if(!StudentManageProjectController::instance){
StudentManageProjectController::instance = new StudentManageProjectController();
}
return StudentManageProjectController::instance;
}