gradepage documentation, using qlist
This commit is contained in:
parent
054237a667
commit
8d5385f99e
10 changed files with 202 additions and 157 deletions
|
@ -33,7 +33,7 @@ coursesTableManager::~coursesTableManager()
|
|||
*/
|
||||
void coursesTableManager::insertJceCoursesIntoTable()
|
||||
{
|
||||
for (gradeCourse *c: *gp->getCourses())
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
{
|
||||
if (us->getInfluenceCourseOnly())
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ bool coursesTableManager::changes(QString change, int row, int col)
|
|||
return true;
|
||||
|
||||
int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt();
|
||||
for (gradeCourse *c: *gp->getCourses())
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
{
|
||||
if (c->getSerialNum() == serialCourse)
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus)
|
|||
else
|
||||
{
|
||||
if (this->gp != NULL)
|
||||
for (gradeCourse *c: *gp->getCourses())
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
{
|
||||
if (!(isCourseAlreadyInserted(c->getSerialNum())))
|
||||
if (c->getPoints() == 0)
|
||||
|
@ -295,7 +295,7 @@ void coursesTableManager::clearTable()
|
|||
gradeCourse *coursesTableManager::getCourseByRow(int row)
|
||||
{
|
||||
QString courseSerial = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text();
|
||||
for (gradeCourse *c: *gp->getCourses())
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
{
|
||||
if (c->getSerialNum() == courseSerial.toDouble())
|
||||
return c;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
calendarExam::calendarExam()
|
||||
{
|
||||
exams = NULL;
|
||||
htmlDataHolderParsed = "";
|
||||
}
|
||||
|
||||
|
@ -13,10 +12,7 @@ calendarExam::calendarExam()
|
|||
void calendarExam::setPage(QString html)
|
||||
{
|
||||
examsCounter = 0;
|
||||
if (exams == NULL)
|
||||
exams = new QList<calendarExamCourse*>();
|
||||
else
|
||||
exams->clear();
|
||||
exams.clear();
|
||||
this->htmlDataHolderParsed = getString(html);
|
||||
examListInit(htmlDataHolderParsed);
|
||||
}
|
||||
|
@ -38,15 +34,15 @@ void calendarExam::examListInit(QString &linesTokinzedString)
|
|||
{
|
||||
calendarExamCourse *cTemp = lineToCourse(tempToken);
|
||||
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)
|
||||
* @param line
|
||||
* @return
|
||||
* @param line - parsed line with tabs between each relevant data
|
||||
* @return object of examcourse with its data
|
||||
*/
|
||||
calendarExamCourse *calendarExam::lineToCourse(QString line)
|
||||
{
|
||||
|
|
|
@ -8,14 +8,21 @@
|
|||
#include <QStringList>
|
||||
#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
|
||||
{
|
||||
public:
|
||||
calendarExam();
|
||||
void setPage(QString html);
|
||||
|
||||
QList<calendarExamCourse*>* getExams() { return exams; }
|
||||
QList<calendarExamCourse*> getExams() { return exams; }
|
||||
int getExamsCounter() const;
|
||||
|
||||
|
||||
|
@ -26,7 +33,7 @@ private:
|
|||
calendarExamCourse * lineToCourse(QString line);
|
||||
|
||||
QString htmlDataHolderParsed;
|
||||
QList<calendarExamCourse*> *exams;
|
||||
QList<calendarExamCourse*> exams;
|
||||
|
||||
int examsCounter; //not including madei b
|
||||
};
|
||||
|
|
|
@ -13,6 +13,17 @@
|
|||
#define HOUR_DEFAULT_STRING "00:00"
|
||||
#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
|
||||
{
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#include "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),
|
||||
ui(new Ui::examDialog)
|
||||
{
|
||||
|
@ -20,6 +24,11 @@ examDialog::examDialog(QWidget *parent, calendarExam *calSchedPtr) : QDialog(par
|
|||
this->setModal(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief examDialog::initializingDataIntoTable
|
||||
*
|
||||
* Inserting each object of exam into the table
|
||||
*/
|
||||
void examDialog::initializingDataIntoTable()
|
||||
{
|
||||
ui->tableWidget->setRowCount(exams->getExamsCounter());
|
||||
|
@ -31,7 +40,7 @@ void examDialog::initializingDataIntoTable()
|
|||
QTimeEdit *firstHourbegin;
|
||||
QDateEdit *secondDate;
|
||||
QTimeEdit *secondHourbegin;
|
||||
for (calendarExamCourse * tempExam: *exams->getExams())
|
||||
for (calendarExamCourse * tempExam: exams->getExams())
|
||||
{
|
||||
j=0;
|
||||
lecturer = new QTableWidgetItem();
|
||||
|
|
|
@ -10,6 +10,16 @@ namespace Ui {
|
|||
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
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
/**
|
||||
* 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
|
||||
* all the courses within that period of time.
|
||||
*
|
||||
* Made By Sagi Dayan, sagidayan@gmail.com On 22/09/2014
|
||||
*/
|
||||
|
||||
#ifndef CALENDARDIALOG_H
|
||||
|
@ -18,17 +20,6 @@ namespace Ui {
|
|||
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
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
* LiranBG@gmail.com
|
||||
*/
|
||||
#include "../course.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
#define COURSE_FIELDS 10
|
||||
#define NO_GRADE_YET 101;
|
||||
|
|
|
@ -5,95 +5,109 @@ static int minYear = 9999;
|
|||
|
||||
GradePage::GradePage(QString html) : Page()
|
||||
{
|
||||
courses = new std::list<gradeCourse*>();
|
||||
tempHtml = getString(html);
|
||||
coursesListInit(tempHtml);
|
||||
|
||||
}
|
||||
GradePage::~GradePage()
|
||||
{
|
||||
for(Course* c : *courses)
|
||||
for (Course* c : courses)
|
||||
delete c;
|
||||
delete courses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GradePage::removeCourse
|
||||
* @param courseSerialID - course ID to remove
|
||||
*/
|
||||
void GradePage::removeCourse(QString courseSerialID)
|
||||
{
|
||||
for(gradeCourse* c : *courses)
|
||||
for(gradeCourse* c : courses)
|
||||
{
|
||||
if (c->getSerialNum() == courseSerialID.toInt())
|
||||
{
|
||||
courses->remove(c);
|
||||
courses.removeAll(c);
|
||||
delete c;
|
||||
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)
|
||||
{
|
||||
std::list<QString> stringHolder;
|
||||
QString temp;
|
||||
gradeCourse* cTemp = NULL;
|
||||
char* tok;
|
||||
char* textToTok = strdup(linesTokinzedString.toStdString().c_str());
|
||||
tok = strtok(textToTok,"\n");
|
||||
while (tok != NULL) //putting every line in a string holder before parsing it
|
||||
QString tempToken;
|
||||
|
||||
QStringList holder = linesTokinzedString.split("\n");
|
||||
QStringList::iterator iterator;
|
||||
for (iterator = holder.begin(); iterator != holder.end(); ++iterator)
|
||||
{
|
||||
temp = tok;
|
||||
stringHolder.push_back(temp);
|
||||
tok = strtok(NULL, "\n");
|
||||
}
|
||||
for (QString temp: stringHolder)
|
||||
tempToken = (*iterator);
|
||||
if ((!tempToken.isEmpty()) && (tempToken.length() > 1))
|
||||
{
|
||||
cTemp = lineToCourse(temp);
|
||||
gradeCourse *cTemp = lineToCourse(tempToken);
|
||||
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 *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;
|
||||
double points,hours,grade;
|
||||
QString name,type, additions;
|
||||
QString tempS = "";
|
||||
|
||||
QString tempToken;
|
||||
int i = 0;
|
||||
char* tok;
|
||||
char* cLine = strdup(line.toStdString().c_str());
|
||||
tok = strtok(cLine, "\t");
|
||||
while(tok != NULL)
|
||||
QStringList holder = line.split("\t");
|
||||
QStringList::iterator iterator;
|
||||
for (iterator = holder.begin(); iterator != holder.end(); ++iterator)
|
||||
{
|
||||
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 = "";
|
||||
char *tokTemp;
|
||||
tokTemp = tok;
|
||||
while (!(isdigit((int)*tokTemp))) //getting to serial number starting pointer
|
||||
tokTemp++;
|
||||
QString tempDataOfSerialCourseName;
|
||||
|
||||
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);
|
||||
tokTemp++;
|
||||
tempDataOfSerialCourseName.append(*secIterator + " ");
|
||||
secIterator++;
|
||||
}
|
||||
templinearray[i] = tempS.trimmed();
|
||||
templinearray[i+1] = QString(tokTemp).trimmed();
|
||||
i +=2; //skipping on serial and course name
|
||||
templinearray[++i] = tempDataOfSerialCourseName.trimmed();
|
||||
}
|
||||
else
|
||||
{
|
||||
templinearray[i] = tempS.trimmed();
|
||||
i++;
|
||||
templinearray[i] = tempToken;
|
||||
}
|
||||
|
||||
if (i == COURSE_FIELDS)
|
||||
i++;
|
||||
if (i >= COURSE_FIELDS)
|
||||
break;
|
||||
tok=strtok(NULL, "\t");
|
||||
}
|
||||
|
||||
if (templinearray[0] == "") //empty parsing
|
||||
{
|
||||
qCritical() << Q_FUNC_INFO << "empty parsing";
|
||||
|
@ -128,7 +142,11 @@ gradeCourse* GradePage::lineToCourse(QString line)
|
|||
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)
|
||||
{
|
||||
if (strlen(grade.toStdString().c_str()) <= 1)
|
||||
|
@ -144,6 +162,7 @@ bool GradePage::isGradedYet(QString grade)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GradePage::getAvg getting avg
|
||||
* @return - gpa avg of all courses
|
||||
|
@ -152,7 +171,7 @@ double GradePage::getAvg()
|
|||
{
|
||||
double avg = 0;
|
||||
double points = 0;
|
||||
for (gradeCourse* c : *courses)
|
||||
for (gradeCourse* c : courses)
|
||||
{
|
||||
if ((c->getGrade() != 0))
|
||||
{
|
||||
|
@ -164,6 +183,7 @@ double GradePage::getAvg()
|
|||
avg /= points;
|
||||
return avg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GradePage::getAvg getting avg of given year
|
||||
* @param year - year (yyyy)
|
||||
|
@ -173,7 +193,7 @@ double GradePage::getAvg(int year)
|
|||
{
|
||||
double avg = 0;
|
||||
double points = 0;
|
||||
for (gradeCourse* c : *courses)
|
||||
for (gradeCourse* c : courses)
|
||||
{
|
||||
if ((c->getGrade() != 0) && (c->getYear() == year))
|
||||
{
|
||||
|
@ -187,17 +207,19 @@ double GradePage::getAvg(int year)
|
|||
avg=0;
|
||||
return avg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GradePage::getAvg
|
||||
* @param year - year (yyyy)
|
||||
* @param semester - semeser (1-3)
|
||||
* @return -gpa avg of given year in given semester
|
||||
*/
|
||||
|
||||
double GradePage::getAvg(int year, int semester)
|
||||
{
|
||||
double avg = 0;
|
||||
double points = 0;
|
||||
for (gradeCourse* c : *courses)
|
||||
for (gradeCourse* c : courses)
|
||||
{
|
||||
if ((c->getGrade() != 0) && (c->getYear() == year) && (c->getSemester() == semester))
|
||||
{
|
||||
|
@ -211,6 +233,7 @@ double GradePage::getAvg(int year, int semester)
|
|||
avg=0;
|
||||
return avg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GradePage::getMinYearInList
|
||||
* @return the minimal year inside courses list
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "../page.h"
|
||||
#include "../Grades/gradeCourse.h"
|
||||
|
||||
#include <list>
|
||||
#include <QList>
|
||||
|
||||
class GradePage : public Page
|
||||
{
|
||||
|
@ -21,6 +21,7 @@ public:
|
|||
~GradePage();
|
||||
|
||||
void removeCourse(QString courseSerialID);
|
||||
|
||||
double getAvg();
|
||||
double getAvg(int year);
|
||||
double getAvg(int year, int semester);
|
||||
|
@ -29,7 +30,7 @@ public:
|
|||
int getMaxYearInList();
|
||||
|
||||
|
||||
std::list<gradeCourse*>* getCourses() { return courses; }
|
||||
QList<gradeCourse*> getCourses() { return courses; }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -38,7 +39,7 @@ private:
|
|||
|
||||
bool isGradedYet(QString grade);
|
||||
|
||||
std::list<gradeCourse*>* courses;
|
||||
QList<gradeCourse*> courses;
|
||||
|
||||
QString tempHtml;
|
||||
|
||||
|
|
Loading…
Reference in a new issue