jce-manager/src/jceData/Calendar/calendarCourse.cpp

174 lines
4.5 KiB
C++
Raw Normal View History

2014-09-08 15:54:52 +00:00
#include "calendarCourse.h"
calendarCourse::calendarCourse(int serial, QString name, QString type, QString lecturer, double points,
double semesterHours, QString dayAndHour,
QString room, calendarCourse::CourseCalendarType courseType) : Course(serial,name, type,points)
2014-09-08 15:54:52 +00:00
{
this->lecturer = lecturer;
this->semesterHours = semesterHours;
this->room = room;
setDayAndHour(dayAndHour,courseType);
2014-09-08 15:54:52 +00:00
}
/**
* @brief calendarCourse::setDayAndHour
* given a string of time and day - parsing it into day, hour it begins and hour it ends seperated
* @param parse -
*/
void calendarCourse::setDayAndHour(QString parse, calendarCourse::CourseCalendarType courseType)
2014-09-08 15:54:52 +00:00
{
if (courseType == calendarCourse::CourseCalendarType::CoursesSchedule)
2014-09-08 15:54:52 +00:00
{
2014-10-07 21:16:27 +00:00
int ctr = 0;
QString temp = "";
QTime timetemp;
char *tok;
char* textToTok = strdup(parse.toStdString().c_str());
tok = strtok(textToTok, " -");
while(tok != NULL)
2014-09-08 15:54:52 +00:00
{
2014-10-07 21:16:27 +00:00
temp = tok;
switch (ctr)
{
case 0: //day
setDay(temp);
break;
case 1: //hour it begins
timetemp = QTime::fromString(temp,"hh:mm");
setHourBegin(timetemp.hour());
setMinutesBegin(timetemp.minute());
break;
case 2: //hour it ends
timetemp = QTime::fromString(temp,"hh:mm");
setHourEnd(timetemp.hour());
setMinutesEnd(timetemp.minute());
break;
}
ctr++;
tok = strtok(NULL, " -");
2014-09-08 15:54:52 +00:00
}
2014-10-07 21:16:27 +00:00
}
if (courseType == calendarCourse::CourseCalendarType::ExamSchedule)
2014-10-07 21:16:27 +00:00
{
2014-09-08 15:54:52 +00:00
}
}
QString calendarCourse::getLecturer() const
2014-09-08 15:54:52 +00:00
{
return lecturer;
}
void calendarCourse::setLecturer(const QString &value)
2014-09-08 15:54:52 +00:00
{
lecturer = value;
}
double calendarCourse::getSemesterHours() const
{
return semesterHours;
}
void calendarCourse::setSemesterHours(double value)
{
semesterHours = value;
}
int calendarCourse::getHourBegin() const
{
return hourBegin;
}
void calendarCourse::setHourBegin(int value)
{
hourBegin = value;
}
int calendarCourse::getMinutesBegin() const
{
return minutesBegin;
}
void calendarCourse::setMinutesBegin(int value)
{
minutesBegin = value;
}
int calendarCourse::getHourEnd() const
{
return hourEnd;
}
void calendarCourse::setHourEnd(int value)
{
hourEnd = value;
}
int calendarCourse::getMinutesEnd() const
{
return minutesEnd;
}
void calendarCourse::setMinutesEnd(int value)
{
minutesEnd = value;
}
/**
* @brief calendarCourse::courseToString
* @return prints the course into string pattern
*/
QString calendarCourse::courseToString()
2014-09-08 15:54:52 +00:00
{
QString courseText = "";
courseText += " " + QString::number(this->getSerialNum());
2014-09-08 15:54:52 +00:00
courseText += " " + this->getName();
courseText += " " + this->getType();
courseText += " " + this->lecturer;
courseText += " " + QString::number(this->getPoints());
courseText += " " + QString::number(this->semesterHours);
courseText += " " + QString::number(this->day);
courseText += " " + QString::number(this->hourBegin) + ":" + QString::number(this->minutesBegin) + "-" + QString::number(this->hourEnd) + ":" + QString::number(this->minutesEnd);
2014-09-08 15:54:52 +00:00
courseText += " " + this->room;
courseText += "\n";
return courseText;
}
int calendarCourse::getDay() const
{
return day;
}
/**
* @brief calendarCourse::setDay
* translating a day that written with hebrew unicode character to an integer
* @param value - contains the day in unicode
*/
void calendarCourse::setDay(const QString &value)
2014-09-08 15:54:52 +00:00
{
std::string dayTemp = value.toStdString().substr(0,2); //recieving two characters respresting days
2014-09-08 15:54:52 +00:00
if (dayTemp.compare("\u05D0") == 0) //alef
day = 1;
else if (dayTemp.compare("\u05D1") == 0) //bet
day = 2;
else if (dayTemp.compare("\u05D2") == 0) //gimel
day = 3;
else if (dayTemp.compare("\u05D3") == 0) //dalet
day = 4;
else if (dayTemp.compare("\u05D4") == 0) //hey
day = 5;
else if (dayTemp.compare("\u05D5") == 0) //vav
day = 6;
else
day= -1;
}
QString calendarCourse::getRoom() const
2014-09-08 15:54:52 +00:00
{
return room;
}
void calendarCourse::setRoom(const QString &value)
2014-09-08 15:54:52 +00:00
{
room = value;
}