-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse.h
69 lines (55 loc) · 1.67 KB
/
course.h
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
/*********************
* Defines a course with its dependencies
* and other needed information.
*/
#ifndef COURSE_H
#define COURSE_H
#include <qobject.h>
#include <qstring.h>
#include <vector>
#include <functional>
class Course;
typedef std::vector<Course *> CourseVect;
typedef std::vector<int> NumVect;
class Course : public QObject {
Q_OBJECT
private:
CourseVect depend_on, depend_by;
NumVect semesters;
QString number;
QString title;
float hours, points;
bool is_user; // Was this course manually selected or as dep?
public:
Course(const QString& Inumber, const QString& Ititle,
const NumVect& Isemesters, float Ihours);
void addDependency (Course *dep);
void select (int semester, Course *selector);
void select (int semester);
void deselect (Course *deselector);
void deselect ();
void changePrefSem (int semester) { emit pref_changed(semester); }
float getHours() const { return hours; }
QString getTitle() const { return title; }
QString getNumber() const { return number; }
NumVect getSemesters() const { return semesters; }
bool is_used() const { return (is_user || depend_by.size() ); }
signals:
void pref_changed (int semester);
// This one should ALWAYS come AFTER selected() or deselected():
void sel_changed ();
void selected (int semester);
void deselected ();
};
class CourseByNum : public std::unary_function<Course *, bool> {
QString number;
public:
CourseByNum() {}
CourseByNum(const QString& num) : number(num) {}
void setNum(const QString& num) { number = num; }
bool operator() (Course *course) {
if (!course) return 0;
return course->getNumber() == number;
}
};
#endif //COURSE_H