-
Notifications
You must be signed in to change notification settings - Fork 0
/
Group.cpp
100 lines (83 loc) · 1.73 KB
/
Group.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
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
98
99
100
#include "Group.hpp"
Group::Group():
m_course(1)
{
}
const QString &Group::name() const
{
return m_name;
}
void Group::setName(const QString &name_)
{
m_name = name_;
}
int Group::course() const
{
return m_course;
}
void Group::setCourse(const int course_)
{
m_course = course_;
}
QStringList Group::memberNames() const
{
QStringList lst;
foreach (const Student &student, m_members)
{
lst.append(student.name);
}
return lst;
}
void Group::setMembers(const StudentList &studentList)
{
m_members = studentList;
}
void Group::appendMember()
{
m_members.append(Student());
m_members.back().name = QObject::trUtf8("Новый студент");
}
void Group::removeMember(const int n)
{
m_members.erase(m_members.begin()+n);
}
Student &Group::member(const int n)
{
return m_members[n];
}
QStringList Group::subjectNames() const
{
QStringList lst;
foreach (const SubjectGroup &sg, m_subjects)
{
lst.append(sg.name);
}
return lst;
}
void Group::appendSubject()
{
m_subjects.append(SubjectGroup());
m_subjects.back().name = QObject::trUtf8("Новый предмет");
}
void Group::removeSubject(const int n)
{
Q_ASSERT(0<=n && n<m_subjects.size());
m_subjects.erase(m_subjects.begin()+n);
}
SubjectGroup &Group::subject(const int n)
{
SubjectGroup &subj = m_subjects[n];
return subj;
}
const StudentList &Group::members() const
{
return m_members;
}
QDataStream &operator>>(QDataStream &in, Group &group)
{
return in>>group.m_name>>group.m_course>>group.m_members>>group.m_subjects;
}
QDataStream &operator<<(QDataStream &out, const Group &group)
{
return out<<group.m_name<<group.m_course<<group.m_members<<group.m_subjects;
}