gradepage documentation, using qlist

This commit is contained in:
liranbg 2014-10-10 21:33:08 +03:00
parent 054237a667
commit 8d5385f99e
10 changed files with 202 additions and 157 deletions

View file

@ -33,7 +33,7 @@ coursesTableManager::~coursesTableManager()
*/ */
void coursesTableManager::insertJceCoursesIntoTable() void coursesTableManager::insertJceCoursesIntoTable()
{ {
for (gradeCourse *c: *gp->getCourses()) for (gradeCourse *c: gp->getCourses())
{ {
if (us->getInfluenceCourseOnly()) if (us->getInfluenceCourseOnly())
{ {
@ -69,7 +69,7 @@ bool coursesTableManager::changes(QString change, int row, int col)
return true; return true;
int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt(); int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt();
for (gradeCourse *c: *gp->getCourses()) for (gradeCourse *c: gp->getCourses())
{ {
if (c->getSerialNum() == serialCourse) if (c->getSerialNum() == serialCourse)
{ {
@ -267,7 +267,7 @@ void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus)
else else
{ {
if (this->gp != NULL) if (this->gp != NULL)
for (gradeCourse *c: *gp->getCourses()) for (gradeCourse *c: gp->getCourses())
{ {
if (!(isCourseAlreadyInserted(c->getSerialNum()))) if (!(isCourseAlreadyInserted(c->getSerialNum())))
if (c->getPoints() == 0) if (c->getPoints() == 0)
@ -295,7 +295,7 @@ void coursesTableManager::clearTable()
gradeCourse *coursesTableManager::getCourseByRow(int row) gradeCourse *coursesTableManager::getCourseByRow(int row)
{ {
QString courseSerial = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text(); QString courseSerial = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text();
for (gradeCourse *c: *gp->getCourses()) for (gradeCourse *c: gp->getCourses())
{ {
if (c->getSerialNum() == courseSerial.toDouble()) if (c->getSerialNum() == courseSerial.toDouble())
return c; return c;

View file

@ -2,7 +2,6 @@
calendarExam::calendarExam() calendarExam::calendarExam()
{ {
exams = NULL;
htmlDataHolderParsed = ""; htmlDataHolderParsed = "";
} }
@ -13,10 +12,7 @@ calendarExam::calendarExam()
void calendarExam::setPage(QString html) void calendarExam::setPage(QString html)
{ {
examsCounter = 0; examsCounter = 0;
if (exams == NULL) exams.clear();
exams = new QList<calendarExamCourse*>();
else
exams->clear();
this->htmlDataHolderParsed = getString(html); this->htmlDataHolderParsed = getString(html);
examListInit(htmlDataHolderParsed); examListInit(htmlDataHolderParsed);
} }
@ -38,15 +34,15 @@ void calendarExam::examListInit(QString &linesTokinzedString)
{ {
calendarExamCourse *cTemp = lineToCourse(tempToken); calendarExamCourse *cTemp = lineToCourse(tempToken);
if (cTemp != NULL) if (cTemp != NULL)
this->exams->push_back(cTemp); this->exams.push_back(cTemp);
} }
} }
} }
/** /**
* @brief calendarExam::lineToCourse getting line of exam with data and make it an object containing data (date, time, course name and etc) * @brief calendarExam::lineToCourse getting line of exam with data and make it an object containing data (date, time, course name and etc)
* @param line * @param line - parsed line with tabs between each relevant data
* @return * @return object of examcourse with its data
*/ */
calendarExamCourse *calendarExam::lineToCourse(QString line) calendarExamCourse *calendarExam::lineToCourse(QString line)
{ {

View file

@ -8,14 +8,21 @@
#include <QStringList> #include <QStringList>
#include <QList> #include <QList>
/**
* @brief The calendarExam class
*
* This class generating html string to a list of examcourses
* Each item in a list is a course with its information (hour, day, name, serial and etc)
*
* Made By liran ben gida, LiranBG@gmail.com On 08/10/2014
*/
class calendarExam : public Page class calendarExam : public Page
{ {
public: public:
calendarExam(); calendarExam();
void setPage(QString html); void setPage(QString html);
QList<calendarExamCourse*>* getExams() { return exams; } QList<calendarExamCourse*> getExams() { return exams; }
int getExamsCounter() const; int getExamsCounter() const;
@ -26,7 +33,7 @@ private:
calendarExamCourse * lineToCourse(QString line); calendarExamCourse * lineToCourse(QString line);
QString htmlDataHolderParsed; QString htmlDataHolderParsed;
QList<calendarExamCourse*> *exams; QList<calendarExamCourse*> exams;
int examsCounter; //not including madei b int examsCounter; //not including madei b
}; };

View file

@ -13,6 +13,17 @@
#define HOUR_DEFAULT_STRING "00:00" #define HOUR_DEFAULT_STRING "00:00"
#define SECOND_DATE_DEFAULT_STRING "nullSECOND_DATE" #define SECOND_DATE_DEFAULT_STRING "nullSECOND_DATE"
/**
* @brief The calendarExamCourse class
*
* This class holds each exam course
* the course scheme can be found below, inside the enum ExamScheme
*
* The class's constructor gets the data and manipulate it into an object
* with its relevant information.
*
* Made By liran ben gida, LiranBG@gmail.com On 08/10/2014
*/
class calendarExamCourse : public Course class calendarExamCourse : public Course
{ {

View file

@ -1,6 +1,10 @@
#include "examDialog.h" #include "examDialog.h"
#include "ui_examDialog.h" #include "ui_examDialog.h"
/**
* @brief examDialog::examDialog
* @param parent
* @param calSchedPtr - list of courses with information about each exam
*/
examDialog::examDialog(QWidget *parent, calendarExam *calSchedPtr) : QDialog(parent), examDialog::examDialog(QWidget *parent, calendarExam *calSchedPtr) : QDialog(parent),
ui(new Ui::examDialog) ui(new Ui::examDialog)
{ {
@ -20,6 +24,11 @@ examDialog::examDialog(QWidget *parent, calendarExam *calSchedPtr) : QDialog(par
this->setModal(true); this->setModal(true);
} }
/**
* @brief examDialog::initializingDataIntoTable
*
* Inserting each object of exam into the table
*/
void examDialog::initializingDataIntoTable() void examDialog::initializingDataIntoTable()
{ {
ui->tableWidget->setRowCount(exams->getExamsCounter()); ui->tableWidget->setRowCount(exams->getExamsCounter());
@ -31,7 +40,7 @@ void examDialog::initializingDataIntoTable()
QTimeEdit *firstHourbegin; QTimeEdit *firstHourbegin;
QDateEdit *secondDate; QDateEdit *secondDate;
QTimeEdit *secondHourbegin; QTimeEdit *secondHourbegin;
for (calendarExamCourse * tempExam: *exams->getExams()) for (calendarExamCourse * tempExam: exams->getExams())
{ {
j=0; j=0;
lecturer = new QTableWidgetItem(); lecturer = new QTableWidgetItem();

View file

@ -10,6 +10,16 @@ namespace Ui {
class examDialog; class examDialog;
} }
/**
* @brief The examDialog class
*
* This class preseting a Dialog with dates, information and time of exams
*
* This dialog main goal is to let the user an option to edit and see the containing data of his exam schedule.
* The user will be able to export the exam schedule into .CSV file through CalendarTab
*
* Made By liran ben gida, LiranBG@gmail.com On 08/10/2014
*/
class examDialog : public QDialog class examDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT

View file

@ -1,10 +1,12 @@
/** /**
* JCE Manager (C) * JCE Manager (C)
* *
* This QDialog widget will hold the dates of a Semester, Start and End. * This QDialog widget hold the dates of a Semester, Start and End.
* *
* this dialog will help the csv_exporter class to export a CSV file that will contain * this dialog will help the csv_exporter class to export a CSV file that will contain
* all the courses within that period of time. * all the courses within that period of time.
*
* Made By Sagi Dayan, sagidayan@gmail.com On 22/09/2014
*/ */
#ifndef CALENDARDIALOG_H #ifndef CALENDARDIALOG_H
@ -18,17 +20,6 @@ namespace Ui {
class CalendarDialog; class CalendarDialog;
} }
/**
* @brief The CalendarDialog class
*
* This class preseting a Dialog with selection of dates
* The user has to choose between a starting point of semester to the end.
*
* This dialog main goal is to let the user an option to export his CSV
* containing data of his schedule.
*
* Made By Sagi Dayan, sagidayan@gmail.com On 22/09/2014
*/
class CalendarDialog : public QDialog class CalendarDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT

View file

@ -8,9 +8,6 @@
* LiranBG@gmail.com * LiranBG@gmail.com
*/ */
#include "../course.h" #include "../course.h"
#include <string>
#include <iostream>
#include <list>
#define COURSE_FIELDS 10 #define COURSE_FIELDS 10
#define NO_GRADE_YET 101; #define NO_GRADE_YET 101;

View file

@ -5,95 +5,109 @@ static int minYear = 9999;
GradePage::GradePage(QString html) : Page() GradePage::GradePage(QString html) : Page()
{ {
courses = new std::list<gradeCourse*>();
tempHtml = getString(html); tempHtml = getString(html);
coursesListInit(tempHtml); coursesListInit(tempHtml);
} }
GradePage::~GradePage() GradePage::~GradePage()
{ {
for(Course* c : *courses) for (Course* c : courses)
delete c; delete c;
delete courses;
} }
/**
* @brief GradePage::removeCourse
* @param courseSerialID - course ID to remove
*/
void GradePage::removeCourse(QString courseSerialID) void GradePage::removeCourse(QString courseSerialID)
{ {
for(gradeCourse* c : *courses) for(gradeCourse* c : courses)
{ {
if (c->getSerialNum() == courseSerialID.toInt()) if (c->getSerialNum() == courseSerialID.toInt())
{ {
courses->remove(c); courses.removeAll(c);
delete c; delete c;
return; return;
} }
} }
} }
/**
* @brief GradePage::coursesListInit
* using lineToCourse function, its making a list of gradeCourse object from a given string of information
* @param linesTokinzedString list of courses, tokenized by lines. containing data of each course
*/
void GradePage::coursesListInit(QString &linesTokinzedString) void GradePage::coursesListInit(QString &linesTokinzedString)
{ {
std::list<QString> stringHolder; QString tempToken;
QString temp;
gradeCourse* cTemp = NULL; QStringList holder = linesTokinzedString.split("\n");
char* tok; QStringList::iterator iterator;
char* textToTok = strdup(linesTokinzedString.toStdString().c_str()); for (iterator = holder.begin(); iterator != holder.end(); ++iterator)
tok = strtok(textToTok,"\n");
while (tok != NULL) //putting every line in a string holder before parsing it
{ {
temp = tok; tempToken = (*iterator);
stringHolder.push_back(temp); if ((!tempToken.isEmpty()) && (tempToken.length() > 1))
tok = strtok(NULL, "\n");
}
for (QString temp: stringHolder)
{ {
cTemp = lineToCourse(temp); gradeCourse *cTemp = lineToCourse(tempToken);
if (cTemp != NULL) if (cTemp != NULL)
courses->push_back(cTemp); this->courses.push_back(cTemp);
}
} }
} }
/**
* @brief GradePage::lineToCourse
* making an object of gradepage with the given information from string
* @param line - lines tokenized by tabs containing each course information (year, serial, name, points and etc..)
* @return
*/
gradeCourse* GradePage::lineToCourse(QString line) gradeCourse* GradePage::lineToCourse(QString line)
{ {
gradeCourse *tempC = NULL; gradeCourse *tempC = NULL;
QString templinearray[COURSE_FIELDS];//[serial,name,type,points,hours,grade,additions] QString templinearray[COURSE_FIELDS];//[year,semester,numInList,serial,name,type,points,hours,grade,additions]
int serial,year,semester,courseNumInList; int serial,year,semester,courseNumInList;
double points,hours,grade; double points,hours,grade;
QString name,type, additions; QString name,type, additions;
QString tempS = "";
QString tempToken;
int i = 0; int i = 0;
char* tok; QStringList holder = line.split("\t");
char* cLine = strdup(line.toStdString().c_str()); QStringList::iterator iterator;
tok = strtok(cLine, "\t"); for (iterator = holder.begin(); iterator != holder.end(); ++iterator)
while(tok != NULL)
{ {
tempS = tok;
if (i == gradeCourse::CourseScheme::SERIAL) //we need to extract the serial manually tempToken = (*iterator);
tempToken = tempToken.trimmed();
//we are checking it because in GPA, serial and course name are mixed
if (i == gradeCourse::CourseScheme::SERIAL)
{ {
tempS = ""; QString tempDataOfSerialCourseName;
char *tokTemp;
tokTemp = tok;
while (!(isdigit((int)*tokTemp))) //getting to serial number starting pointer
tokTemp++;
while (isdigit((int)*tokTemp)) //serial number //getting serial
QStringList secHolder = tempToken.split(" ");
QStringList::iterator secIterator = secHolder.begin();
tempDataOfSerialCourseName = *secIterator;
templinearray[i] = tempDataOfSerialCourseName.trimmed();
//getting course name;
++secIterator;
tempDataOfSerialCourseName.clear();
while (secIterator != secHolder.end())
{ {
tempS += QString(*tokTemp); tempDataOfSerialCourseName.append(*secIterator + " ");
tokTemp++; secIterator++;
} }
templinearray[i] = tempS.trimmed(); templinearray[++i] = tempDataOfSerialCourseName.trimmed();
templinearray[i+1] = QString(tokTemp).trimmed();
i +=2; //skipping on serial and course name
} }
else else
{ {
templinearray[i] = tempS.trimmed(); templinearray[i] = tempToken;
i++;
} }
if (i == COURSE_FIELDS) i++;
if (i >= COURSE_FIELDS)
break; break;
tok=strtok(NULL, "\t");
} }
if (templinearray[0] == "") //empty parsing if (templinearray[0] == "") //empty parsing
{ {
qCritical() << Q_FUNC_INFO << "empty parsing"; qCritical() << Q_FUNC_INFO << "empty parsing";
@ -128,7 +142,11 @@ gradeCourse* GradePage::lineToCourse(QString line)
return tempC; return tempC;
} }
//checking if one of the chars inside grade is not a number /**
* @brief GradePage::isGradedYet checking if one of the chars inside grade is not a number
* @param grade
* @return if has bee graded or not
*/
bool GradePage::isGradedYet(QString grade) bool GradePage::isGradedYet(QString grade)
{ {
if (strlen(grade.toStdString().c_str()) <= 1) if (strlen(grade.toStdString().c_str()) <= 1)
@ -144,6 +162,7 @@ bool GradePage::isGradedYet(QString grade)
} }
return true; return true;
} }
/** /**
* @brief GradePage::getAvg getting avg * @brief GradePage::getAvg getting avg
* @return - gpa avg of all courses * @return - gpa avg of all courses
@ -152,7 +171,7 @@ double GradePage::getAvg()
{ {
double avg = 0; double avg = 0;
double points = 0; double points = 0;
for (gradeCourse* c : *courses) for (gradeCourse* c : courses)
{ {
if ((c->getGrade() != 0)) if ((c->getGrade() != 0))
{ {
@ -164,6 +183,7 @@ double GradePage::getAvg()
avg /= points; avg /= points;
return avg; return avg;
} }
/** /**
* @brief GradePage::getAvg getting avg of given year * @brief GradePage::getAvg getting avg of given year
* @param year - year (yyyy) * @param year - year (yyyy)
@ -173,7 +193,7 @@ double GradePage::getAvg(int year)
{ {
double avg = 0; double avg = 0;
double points = 0; double points = 0;
for (gradeCourse* c : *courses) for (gradeCourse* c : courses)
{ {
if ((c->getGrade() != 0) && (c->getYear() == year)) if ((c->getGrade() != 0) && (c->getYear() == year))
{ {
@ -187,17 +207,19 @@ double GradePage::getAvg(int year)
avg=0; avg=0;
return avg; return avg;
} }
/** /**
* @brief GradePage::getAvg * @brief GradePage::getAvg
* @param year - year (yyyy) * @param year - year (yyyy)
* @param semester - semeser (1-3) * @param semester - semeser (1-3)
* @return -gpa avg of given year in given semester * @return -gpa avg of given year in given semester
*/ */
double GradePage::getAvg(int year, int semester) double GradePage::getAvg(int year, int semester)
{ {
double avg = 0; double avg = 0;
double points = 0; double points = 0;
for (gradeCourse* c : *courses) for (gradeCourse* c : courses)
{ {
if ((c->getGrade() != 0) && (c->getYear() == year) && (c->getSemester() == semester)) if ((c->getGrade() != 0) && (c->getYear() == year) && (c->getSemester() == semester))
{ {
@ -211,6 +233,7 @@ double GradePage::getAvg(int year, int semester)
avg=0; avg=0;
return avg; return avg;
} }
/** /**
* @brief GradePage::getMinYearInList * @brief GradePage::getMinYearInList
* @return the minimal year inside courses list * @return the minimal year inside courses list

View file

@ -11,7 +11,7 @@
#include "../page.h" #include "../page.h"
#include "../Grades/gradeCourse.h" #include "../Grades/gradeCourse.h"
#include <list> #include <QList>
class GradePage : public Page class GradePage : public Page
{ {
@ -21,6 +21,7 @@ public:
~GradePage(); ~GradePage();
void removeCourse(QString courseSerialID); void removeCourse(QString courseSerialID);
double getAvg(); double getAvg();
double getAvg(int year); double getAvg(int year);
double getAvg(int year, int semester); double getAvg(int year, int semester);
@ -29,7 +30,7 @@ public:
int getMaxYearInList(); int getMaxYearInList();
std::list<gradeCourse*>* getCourses() { return courses; } QList<gradeCourse*> getCourses() { return courses; }
private: private:
@ -38,7 +39,7 @@ private:
bool isGradedYet(QString grade); bool isGradedYet(QString grade);
std::list<gradeCourse*>* courses; QList<gradeCourse*> courses;
QString tempHtml; QString tempHtml;