gpa grade gradient, cleartable on get gpa
This commit is contained in:
parent
a33939c93b
commit
10f53aa3f3
8 changed files with 237 additions and 219 deletions
|
@ -5,46 +5,46 @@
|
||||||
*/
|
*/
|
||||||
coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
|
coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
|
||||||
{
|
{
|
||||||
this->gp = NULL;
|
this->gp = NULL;
|
||||||
this->us = usrPtr;
|
this->us = usrPtr;
|
||||||
this->courseTBL = ptr;
|
this->courseTBL = ptr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initilizing Table
|
* Initilizing Table
|
||||||
*/
|
*/
|
||||||
courseTBL->setRowCount(0);
|
courseTBL->setRowCount(0);
|
||||||
courseTBL->setColumnCount(COURSE_FIELDS);
|
courseTBL->setColumnCount(COURSE_FIELDS);
|
||||||
QStringList mz;
|
QStringList mz;
|
||||||
mz << QObject::tr("Number") << QObject::tr("Year") << QObject::tr("Semester") << QObject::tr("Serial") << QObject::tr("Name") << QObject::tr("Type") << QObject::tr("Points") << QObject::tr("Hours") << QObject::tr("Grade") << QObject::tr("Additions");
|
mz << QObject::tr("Number") << QObject::tr("Year") << QObject::tr("Semester") << QObject::tr("Serial") << QObject::tr("Name") << QObject::tr("Type") << QObject::tr("Points") << QObject::tr("Hours") << QObject::tr("Grade") << QObject::tr("Additions");
|
||||||
courseTBL->setHorizontalHeaderLabels(mz);
|
courseTBL->setHorizontalHeaderLabels(mz);
|
||||||
courseTBL->verticalHeader()->setVisible(false);
|
courseTBL->verticalHeader()->setVisible(false);
|
||||||
courseTBL->setSelectionMode(QAbstractItemView::SingleSelection);
|
courseTBL->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
courseTBL->setShowGrid(true);
|
courseTBL->setShowGrid(true);
|
||||||
courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
|
courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
|
||||||
|
|
||||||
graph = new gradegraph(ptr);
|
graph = new gradegraph(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
coursesTableManager::~coursesTableManager()
|
coursesTableManager::~coursesTableManager()
|
||||||
{
|
{
|
||||||
courseTBL = NULL;
|
courseTBL = NULL;
|
||||||
delete gp;
|
delete gp;
|
||||||
gp = NULL;
|
gp = NULL;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief coursesTableManager::insertJceCoursesIntoTable phrasing the course list to rows in table
|
* @brief coursesTableManager::insertJceCoursesIntoTable phrasing the course list to rows in table
|
||||||
*/
|
*/
|
||||||
void coursesTableManager::insertJceCoursesIntoTable()
|
void coursesTableManager::insertJceCoursesIntoTable()
|
||||||
{
|
{
|
||||||
for (gradeCourse *c: gp->getCourses())
|
for (gradeCourse *c: gp->getCourses())
|
||||||
{
|
{
|
||||||
if (us->getInfluenceCourseOnly())
|
if (us->getInfluenceCourseOnly())
|
||||||
{
|
{
|
||||||
if (isCourseInfluence(c))
|
if (isCourseInfluence(c))
|
||||||
addRow(c);
|
addRow(c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
addRow(c);
|
addRow(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -53,9 +53,9 @@ void coursesTableManager::insertJceCoursesIntoTable()
|
||||||
*/
|
*/
|
||||||
void coursesTableManager::setCoursesList(QString &html)
|
void coursesTableManager::setCoursesList(QString &html)
|
||||||
{
|
{
|
||||||
if (gp != NULL)
|
clearTable();
|
||||||
gp->~GradePage();
|
gp = new GradePage(html);
|
||||||
gp = new GradePage(html);
|
insertJceCoursesIntoTable();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief coursesTableManager::changes when user changes the table manually it updates it
|
* @brief coursesTableManager::changes when user changes the table manually it updates it
|
||||||
|
@ -67,81 +67,85 @@ void coursesTableManager::setCoursesList(QString &html)
|
||||||
bool coursesTableManager::changes(QString change, int row, int col)
|
bool coursesTableManager::changes(QString change, int row, int col)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool isNumFlag = true;
|
bool isNumFlag = true;
|
||||||
if (courseTBL->item(row,gradeCourse::CourseScheme::SERIAL) == NULL)
|
if (courseTBL->item(row,gradeCourse::CourseScheme::SERIAL) == NULL)
|
||||||
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)
|
||||||
{
|
{
|
||||||
switch (col)
|
switch (col)
|
||||||
{
|
{
|
||||||
case (gradeCourse::CourseScheme::COURSE_NUMBER_IN_LIST):
|
case (gradeCourse::CourseScheme::COURSE_NUMBER_IN_LIST):
|
||||||
c->setCourseNumInList(change.toInt());
|
c->setCourseNumInList(change.toInt());
|
||||||
break;
|
break;
|
||||||
case (gradeCourse::CourseScheme::YEAR):
|
case (gradeCourse::CourseScheme::YEAR):
|
||||||
c->setYear(change.toInt());
|
c->setYear(change.toInt());
|
||||||
break;
|
break;
|
||||||
case (gradeCourse::CourseScheme::SEMESTER):
|
case (gradeCourse::CourseScheme::SEMESTER):
|
||||||
c->setSemester(change.toInt());
|
c->setSemester(change.toInt());
|
||||||
break;
|
break;
|
||||||
case (gradeCourse::CourseScheme::NAME):
|
case (gradeCourse::CourseScheme::NAME):
|
||||||
c->setName(change);
|
c->setName(change);
|
||||||
break;
|
break;
|
||||||
case (gradeCourse::CourseScheme::TYPE):
|
case (gradeCourse::CourseScheme::TYPE):
|
||||||
c->setType(change);
|
c->setType(change);
|
||||||
break;
|
break;
|
||||||
case (gradeCourse::CourseScheme::POINTS):
|
case (gradeCourse::CourseScheme::POINTS):
|
||||||
{
|
{
|
||||||
change.toDouble(&isNumFlag);
|
change.toDouble(&isNumFlag);
|
||||||
|
|
||||||
if (!isNumFlag)
|
if (!isNumFlag)
|
||||||
{
|
{
|
||||||
courseTBL->item(row,col)->setText(QString::number(c->getPoints()));
|
courseTBL->item(row,col)->setText(QString::number(c->getPoints()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
c->setPoints(change.toDouble());
|
c->setPoints(change.toDouble());
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case (gradeCourse::CourseScheme::HOURS):
|
|
||||||
{
|
|
||||||
change.toDouble(&isNumFlag);
|
|
||||||
|
|
||||||
if (!isNumFlag)
|
|
||||||
{
|
|
||||||
courseTBL->item(row,col)->setText(QString::number(c->getHours()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
c->setHours(change.toDouble());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case (gradeCourse::CourseScheme::GRADE):
|
|
||||||
{
|
|
||||||
change.toDouble(&isNumFlag);
|
|
||||||
|
|
||||||
if (!isNumFlag)
|
|
||||||
{
|
|
||||||
courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((change.toDouble() >= 0) && (change.toDouble() <= 100))
|
|
||||||
c->setGrade(change.toDouble());
|
|
||||||
else
|
|
||||||
courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case (gradeCourse::CourseScheme::ADDITION):
|
|
||||||
c->setAdditions(change);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
case (gradeCourse::CourseScheme::HOURS):
|
||||||
|
{
|
||||||
|
change.toDouble(&isNumFlag);
|
||||||
|
|
||||||
|
if (!isNumFlag)
|
||||||
|
{
|
||||||
|
courseTBL->item(row,col)->setText(QString::number(c->getHours()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
c->setHours(change.toDouble());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (gradeCourse::CourseScheme::GRADE):
|
||||||
|
{
|
||||||
|
|
||||||
|
change.toDouble(&isNumFlag);
|
||||||
|
|
||||||
|
if (!isNumFlag) //not a number
|
||||||
|
{
|
||||||
|
courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((change.toDouble() >= 0) && (change.toDouble() <= 100))
|
||||||
|
{
|
||||||
|
c->setGrade(change.toDouble());
|
||||||
|
colorTheGrade(row);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (gradeCourse::CourseScheme::ADDITION):
|
||||||
|
c->setAdditions(change);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isNumFlag;
|
return isNumFlag;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -150,192 +154,202 @@ bool coursesTableManager::changes(QString change, int row, int col)
|
||||||
*/
|
*/
|
||||||
void coursesTableManager::addRow(const gradeCourse *courseToAdd)
|
void coursesTableManager::addRow(const gradeCourse *courseToAdd)
|
||||||
{
|
{
|
||||||
int i=1,j=1;
|
int i=1,j=1;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
QTableWidgetItem *number,*year,*semester,*serial,*name,*type,*points,*hours,*grade,*addition;
|
QTableWidgetItem *number,*year,*semester,*serial,*name,*type,*points,*hours,*grade,*addition;
|
||||||
const gradeCourse * c;
|
const gradeCourse * c;
|
||||||
if (courseToAdd != NULL)
|
if (courseToAdd != NULL)
|
||||||
{
|
{
|
||||||
c = courseToAdd;
|
c = courseToAdd;
|
||||||
if (!isCourseAlreadyInserted(c->getSerialNum()))
|
if (!isCourseAlreadyInserted(c->getSerialNum()))
|
||||||
{
|
{
|
||||||
courseTBL->setRowCount(courseTBL->rowCount() + 1);
|
courseTBL->setRowCount(courseTBL->rowCount() + 1);
|
||||||
i = courseTBL->rowCount()-1;
|
i = courseTBL->rowCount()-1;
|
||||||
|
|
||||||
number = new QTableWidgetItem();
|
number = new QTableWidgetItem();
|
||||||
number->setData(Qt::EditRole, c->getCourseNumInList());
|
number->setData(Qt::EditRole, c->getCourseNumInList());
|
||||||
number->setFlags(number->flags() & ~Qt::ItemIsEditable);
|
number->setFlags(number->flags() & ~Qt::ItemIsEditable);
|
||||||
|
|
||||||
year = new QTableWidgetItem();
|
year = new QTableWidgetItem();
|
||||||
year->setData(Qt::EditRole,c->getYear());
|
year->setData(Qt::EditRole,c->getYear());
|
||||||
year->setFlags(year->flags() & ~Qt::ItemIsEditable);
|
year->setFlags(year->flags() & ~Qt::ItemIsEditable);
|
||||||
|
|
||||||
semester = new QTableWidgetItem();
|
semester = new QTableWidgetItem();
|
||||||
semester->setData(Qt::EditRole,c->getSemester());
|
semester->setData(Qt::EditRole,c->getSemester());
|
||||||
semester->setFlags(semester->flags() & ~Qt::ItemIsEditable);
|
semester->setFlags(semester->flags() & ~Qt::ItemIsEditable);
|
||||||
|
|
||||||
serial = new QTableWidgetItem();
|
serial = new QTableWidgetItem();
|
||||||
serial->setData(Qt::EditRole,c->getSerialNum());
|
serial->setData(Qt::EditRole,c->getSerialNum());
|
||||||
serial->setFlags(serial->flags() & ~Qt::ItemIsEditable);
|
serial->setFlags(serial->flags() & ~Qt::ItemIsEditable);
|
||||||
|
|
||||||
name = new QTableWidgetItem();
|
name = new QTableWidgetItem();
|
||||||
name->setData(Qt::EditRole,c->getName());
|
name->setData(Qt::EditRole,c->getName());
|
||||||
name->setFlags(name->flags() & ~Qt::ItemIsEditable);
|
name->setFlags(name->flags() & ~Qt::ItemIsEditable);
|
||||||
|
|
||||||
type = new QTableWidgetItem();
|
type = new QTableWidgetItem();
|
||||||
type->setData(Qt::EditRole, c->getType());
|
type->setData(Qt::EditRole, c->getType());
|
||||||
type->setFlags(type->flags() & ~Qt::ItemIsEditable);
|
type->setFlags(type->flags() & ~Qt::ItemIsEditable);
|
||||||
|
|
||||||
points = new QTableWidgetItem();
|
points = new QTableWidgetItem();
|
||||||
points->setData(Qt::EditRole, c->getPoints());
|
points->setData(Qt::EditRole, c->getPoints());
|
||||||
points->setFlags(points->flags() & ~Qt::ItemIsEditable);
|
points->setFlags(points->flags() & ~Qt::ItemIsEditable);
|
||||||
|
|
||||||
hours = new QTableWidgetItem();
|
hours = new QTableWidgetItem();
|
||||||
hours->setData(Qt::EditRole, c->getHours());
|
hours->setData(Qt::EditRole, c->getHours());
|
||||||
hours->setFlags(hours->flags() & ~Qt::ItemIsEditable);
|
hours->setFlags(hours->flags() & ~Qt::ItemIsEditable);
|
||||||
|
|
||||||
grade = new QTableWidgetItem();
|
grade = new QTableWidgetItem();
|
||||||
//grade->setData(Qt::EditRole,c->getGrade());
|
//grade->setData(Qt::EditRole,c->getGrade());
|
||||||
//BUG QT bug
|
//BUG QT bug
|
||||||
//good for sorting, the problem is when you edit -> the cell indicator disappear
|
//good for sorting, the problem is when you edit -> the cell indicator disappear
|
||||||
grade->setText(QString::number(c->getGrade()));
|
grade->setText(QString::number(c->getGrade()));
|
||||||
|
|
||||||
addition = new QTableWidgetItem();
|
addition = new QTableWidgetItem();
|
||||||
addition->setData(Qt::EditRole,c->getAddidtions());
|
addition->setData(Qt::EditRole,c->getAddidtions());
|
||||||
|
|
||||||
courseTBL->setItem(i,j++,number);
|
courseTBL->setItem(i,j++,number);
|
||||||
courseTBL->setItem(i,j++,year);
|
courseTBL->setItem(i,j++,year);
|
||||||
courseTBL->setItem(i,j++,semester);
|
courseTBL->setItem(i,j++,semester);
|
||||||
courseTBL->setItem(i,j++,serial);
|
courseTBL->setItem(i,j++,serial);
|
||||||
courseTBL->setItem(i,j++,name);
|
courseTBL->setItem(i,j++,name);
|
||||||
courseTBL->setItem(i,j++,type);
|
courseTBL->setItem(i,j++,type);
|
||||||
courseTBL->setItem(i,j++,points);
|
courseTBL->setItem(i,j++,points);
|
||||||
courseTBL->setItem(i,j++,hours);
|
courseTBL->setItem(i,j++,hours);
|
||||||
courseTBL->setItem(i,j,grade);
|
courseTBL->setItem(i,j++,grade);
|
||||||
|
courseTBL->setItem(i,j,addition);
|
||||||
|
|
||||||
//FIXME : make it a function, add it when cell has changed
|
colorTheGrade(i);
|
||||||
if(c->getGrade() < 55 && c->getGrade() != 0)
|
|
||||||
{
|
|
||||||
courseTBL->item(i, j)->setBackground(Qt::darkRed);
|
|
||||||
courseTBL->item(i,j)->setTextColor(Qt::white);
|
|
||||||
}
|
|
||||||
else if(55 <= c->getGrade() && c->getGrade() < 70 )
|
|
||||||
{
|
|
||||||
courseTBL->item(i, j)->setBackground(Qt::darkYellow);
|
|
||||||
courseTBL->item(i,j)->setTextColor(Qt::white);
|
|
||||||
}
|
|
||||||
// else if(70 < c->getGrade() && c->getGrade() <= 80 )
|
|
||||||
// courseTBL->item(i, j)->setBackground(Qt::darkGreen); //They Look Bad!!
|
|
||||||
// else if(c->getGrade() > 80)
|
|
||||||
// courseTBL->item(i, j)->setBackground(Qt::green);
|
|
||||||
|
|
||||||
j++;
|
|
||||||
|
|
||||||
courseTBL->setItem(i,j,addition);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCritical() << Q_FUNC_INFO << " no course to load!";
|
qCritical() << Q_FUNC_INFO << " no course to load!";
|
||||||
}
|
}
|
||||||
|
|
||||||
courseTBL->resizeColumnsToContents();
|
courseTBL->resizeColumnsToContents();
|
||||||
courseTBL->resizeRowsToContents();
|
courseTBL->resizeRowsToContents();
|
||||||
|
|
||||||
}
|
}
|
||||||
double coursesTableManager::getAvg()
|
double coursesTableManager::getAvg()
|
||||||
{
|
{
|
||||||
if (this->gp != NULL)
|
if (this->gp != NULL)
|
||||||
return gp->getAvg();
|
return gp->getAvg();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void coursesTableManager::showGraph()
|
bool coursesTableManager::showGraph()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if (gp != NULL)
|
if (gp != NULL)
|
||||||
{
|
{
|
||||||
this->graph->showGraph(gp);
|
this->graph->showGraph(gp);
|
||||||
}
|
return true;
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning() << Q_FUNC_INFO << "open with null grade page";
|
|
||||||
}
|
}
|
||||||
|
qWarning() << Q_FUNC_INFO << "open with null grade page";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus)
|
void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus)
|
||||||
{
|
{
|
||||||
if (ignoreCourseStatus)
|
if (ignoreCourseStatus)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < courseTBL->rowCount())
|
while (i < courseTBL->rowCount())
|
||||||
{
|
{
|
||||||
if (courseTBL->item(i,gradeCourse::CourseScheme::POINTS)->text().compare("0") == 0)
|
if (courseTBL->item(i,gradeCourse::CourseScheme::POINTS)->text().compare("0") == 0)
|
||||||
courseTBL->removeRow(i--);
|
courseTBL->removeRow(i--);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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)
|
||||||
addRow(c);
|
addRow(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void coursesTableManager::clearTable()
|
void coursesTableManager::clearTable()
|
||||||
{
|
{
|
||||||
if (courseTBL->rowCount() == 0)
|
if (courseTBL->rowCount() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int i = 0; //starting point
|
int i = 0; //starting point
|
||||||
while (courseTBL->rowCount() > i)
|
while (courseTBL->rowCount() > i)
|
||||||
{
|
{
|
||||||
gp->removeCourse(courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text());
|
if (gp != NULL)
|
||||||
courseTBL->removeRow(i);
|
gp->removeCourse(courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text());
|
||||||
|
courseTBL->removeRow(i);
|
||||||
}
|
}
|
||||||
gp = NULL;
|
if (gp != NULL)
|
||||||
courseTBL->repaint();
|
delete gp;
|
||||||
|
gp = NULL;
|
||||||
|
courseTBL->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool coursesTableManager::isCourseAlreadyInserted(double courseID)
|
bool coursesTableManager::isCourseAlreadyInserted(double courseID)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = courseTBL->rowCount(); i >= 0; --i)
|
for (i = courseTBL->rowCount(); i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (courseTBL->item(i,gradeCourse::CourseScheme::SERIAL) != NULL)
|
if (courseTBL->item(i,gradeCourse::CourseScheme::SERIAL) != NULL)
|
||||||
{
|
{
|
||||||
QString courseSerial = courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text();
|
QString courseSerial = courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text();
|
||||||
if (QString::number(courseID) == courseSerial)
|
if (QString::number(courseID) == courseSerial)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool coursesTableManager::isCourseInfluence(const gradeCourse *courseToCheck)
|
bool coursesTableManager::isCourseInfluence(const gradeCourse *courseToCheck)
|
||||||
{
|
{
|
||||||
if (courseToCheck->getPoints() > 0)
|
if (courseToCheck->getPoints() > 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief coursesTableManager::colorTheGrade - color the course grade
|
||||||
|
* @param rowIndex - course's row index
|
||||||
|
*/
|
||||||
|
void coursesTableManager::colorTheGrade(int rowIndex)
|
||||||
|
{
|
||||||
|
gradeCourse * temp = getCourseByRow(rowIndex);
|
||||||
|
if (temp != NULL)
|
||||||
|
{
|
||||||
|
if (temp->getGrade() != 0)
|
||||||
|
{
|
||||||
|
float green,red, blue = 0;
|
||||||
|
float grade = ((float)temp->getGrade());
|
||||||
|
|
||||||
|
green = qRound(grade * 255 / 100);
|
||||||
|
red = qRound((255 * (100 - grade) / 100));
|
||||||
|
blue = 0;
|
||||||
|
//higher the grade -> the greener it is
|
||||||
|
courseTBL->item(rowIndex,gradeCourse::CourseScheme::GRADE)->setBackground(QColor(red,green,blue));
|
||||||
|
courseTBL->item(rowIndex,gradeCourse::CourseScheme::GRADE)->setTextColor(Qt::black);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,13 @@
|
||||||
#define COURSESTABLEMANAGER_H
|
#define COURSESTABLEMANAGER_H
|
||||||
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QtGlobal>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QtCore/QCoreApplication>
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include "./src/jceData/Grades/graph/gradegraph.h"
|
#include "./src/jceData/Grades/graph/gradegraph.h"
|
||||||
#include "./src/jceData/Grades/gradePage.h"
|
#include "./src/jceData/Grades/gradePage.h"
|
||||||
#include "./src/jceSettings/user.h"
|
#include "./src/jceSettings/user.h"
|
||||||
|
@ -28,7 +24,7 @@ public:
|
||||||
void addRow(const gradeCourse * courseToAdd = 0);
|
void addRow(const gradeCourse * courseToAdd = 0);
|
||||||
double getAvg();
|
double getAvg();
|
||||||
|
|
||||||
void showGraph();
|
bool showGraph();
|
||||||
|
|
||||||
void influnceCourseChanged(bool status);
|
void influnceCourseChanged(bool status);
|
||||||
void clearTable();
|
void clearTable();
|
||||||
|
@ -42,6 +38,8 @@ private:
|
||||||
gradeCourse * getCourseByRow(int row);
|
gradeCourse * getCourseByRow(int row);
|
||||||
bool isCourseAlreadyInserted(double courseID);
|
bool isCourseAlreadyInserted(double courseID);
|
||||||
bool isCourseInfluence(const gradeCourse *courseToCheck);
|
bool isCourseInfluence(const gradeCourse *courseToCheck);
|
||||||
|
|
||||||
|
void colorTheGrade(int rowIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COURSESTABLEMANAGER_H
|
#endif // COURSESTABLEMANAGER_H
|
||||||
|
|
|
@ -59,6 +59,7 @@ bool loginHandler::makeConnection()
|
||||||
{
|
{
|
||||||
case jceLogin::JCE_YOU_ARE_IN:
|
case jceLogin::JCE_YOU_ARE_IN:
|
||||||
{
|
{
|
||||||
|
statusBar->setIconConnectionStatus(jceStatusBar::LoggedIn);
|
||||||
logggedInFlag = true;
|
logggedInFlag = true;
|
||||||
return logggedInFlag;
|
return logggedInFlag;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +146,6 @@ int loginHandler::makeCalendarRequest(int year, int semester)
|
||||||
else
|
else
|
||||||
return jceLogin::JCE_NOT_CONNECTED;
|
return jceLogin::JCE_NOT_CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int loginHandler::makeExamsScheduleRequest(int year, int semester)
|
int loginHandler::makeExamsScheduleRequest(int year, int semester)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,6 @@ void MainScreen::on_ratesButton_clicked()
|
||||||
statusBar->setIconConnectionStatus(jceStatusBar::Inserting);
|
statusBar->setIconConnectionStatus(jceStatusBar::Inserting);
|
||||||
pageString = loginHandel->getCurrentPageContect();
|
pageString = loginHandel->getCurrentPageContect();
|
||||||
courseTableMgr->setCoursesList(pageString);
|
courseTableMgr->setCoursesList(pageString);
|
||||||
courseTableMgr->insertJceCoursesIntoTable();
|
|
||||||
statusBar->setIconConnectionStatus(jceStatusBar::Done);
|
statusBar->setIconConnectionStatus(jceStatusBar::Done);
|
||||||
}
|
}
|
||||||
else if (status == jceLogin::JCE_NOT_CONNECTED)
|
else if (status == jceLogin::JCE_NOT_CONNECTED)
|
||||||
|
@ -231,7 +230,8 @@ void MainScreen::on_clearTableButton_clicked()
|
||||||
void MainScreen::on_graphButton_clicked()
|
void MainScreen::on_graphButton_clicked()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
courseTableMgr->showGraph();
|
if (!courseTableMgr->showGraph())
|
||||||
|
QMessageBox::critical(this,tr("Error"),tr("You must to load GPA first\nClick on 'Get GPA'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ bool jceSSLClient::recieveData(QString *str)
|
||||||
disconnect(this, SIGNAL(readyRead()), this, SLOT(readIt()));
|
disconnect(this, SIGNAL(readyRead()), this, SLOT(readIt()));
|
||||||
|
|
||||||
str->append(packet);
|
str->append(packet);
|
||||||
// qDebug() << *str; //if you want to see the whole packet, unmark me
|
qDebug() << *str; //if you want to see the whole packet, unmark me
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "packet size: " << packetSizeRecieved << "received data lenght: " << str->length();
|
qDebug() << Q_FUNC_INFO << "packet size: " << packetSizeRecieved << "received data lenght: " << str->length();
|
||||||
qDebug() << Q_FUNC_INFO << "return with flag: " << recieveLastPacket;
|
qDebug() << Q_FUNC_INFO << "return with flag: " << recieveLastPacket;
|
||||||
|
|
|
@ -135,8 +135,10 @@ gradeCourse* GradePage::lineToCourse(QString line)
|
||||||
if (year >= maxYear)
|
if (year >= maxYear)
|
||||||
maxYear = year;
|
maxYear = year;
|
||||||
|
|
||||||
if (year <= minYear)
|
if ((year <= minYear) && (points > 0)) //not graded yet isnt influced year!
|
||||||
|
{
|
||||||
minYear = year;
|
minYear = year;
|
||||||
|
}
|
||||||
|
|
||||||
tempC = new gradeCourse(year,semester,courseNumInList,serial,name,type,points,hours,grade,additions);
|
tempC = new gradeCourse(year,semester,courseNumInList,serial,name,type,points,hours,grade,additions);
|
||||||
return tempC;
|
return tempC;
|
||||||
|
@ -152,11 +154,12 @@ bool GradePage::isGradedYet(QString grade)
|
||||||
if (strlen(grade.toStdString().c_str()) <= 1)
|
if (strlen(grade.toStdString().c_str()) <= 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (char c: grade.toStdString())
|
for (QChar c: grade)
|
||||||
{
|
{
|
||||||
if (c == '\0')
|
if (c == '\0')
|
||||||
break;
|
break;
|
||||||
if (((!isdigit((int)c)) && (!isspace((int)c)))) //48 = 0, 57 = 9
|
|
||||||
|
if (((!c.isDigit()) && (!c.isSpace()))) //48 = 0, 57 = 9
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ void gradegraph::showGraph(GradePage *gpPTR)
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
this->gp = gpPTR;
|
this->gp = gpPTR;
|
||||||
|
|
||||||
clearGraph();
|
if (ui->graphwidget->graphCount() > 0)
|
||||||
|
clearGraph();
|
||||||
|
|
||||||
setVisualization();
|
setVisualization();
|
||||||
setGraphsData();
|
setGraphsData();
|
||||||
|
@ -34,7 +35,7 @@ gradegraph::~gradegraph()
|
||||||
|
|
||||||
void gradegraph::setGraphsData()
|
void gradegraph::setGraphsData()
|
||||||
{
|
{
|
||||||
int minYearInList = gp->getMinYearInList();
|
int minYearInList = gp->getMinYearInList()-1;
|
||||||
int maxYearInList = gp->getMaxYearInList()+1;
|
int maxYearInList = gp->getMaxYearInList()+1;
|
||||||
int xRangeForYear = (maxYearInList - minYearInList+2)*3;
|
int xRangeForYear = (maxYearInList - minYearInList+2)*3;
|
||||||
QVector<double> SemesterialAvg(xRangeForYear),yearlyAvg(xRangeForYear),indicatorX(xRangeForYear);
|
QVector<double> SemesterialAvg(xRangeForYear),yearlyAvg(xRangeForYear),indicatorX(xRangeForYear);
|
||||||
|
@ -134,8 +135,7 @@ void gradegraph::setVisualization()
|
||||||
ui->graphwidget->graph(1)->setPen(QPen( QColor(Qt::GlobalColor::red)));
|
ui->graphwidget->graph(1)->setPen(QPen( QColor(Qt::GlobalColor::red)));
|
||||||
ui->graphwidget->graph(1)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::red, Qt::red, 7));
|
ui->graphwidget->graph(1)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::red, Qt::red, 7));
|
||||||
|
|
||||||
|
int minYearInList = gp->getMinYearInList()-1;
|
||||||
int minYearInList = gp->getMinYearInList();
|
|
||||||
int maxYearInList = gp->getMaxYearInList()+1;
|
int maxYearInList = gp->getMaxYearInList()+1;
|
||||||
int xRangeForYear = (maxYearInList - minYearInList+2)*3;
|
int xRangeForYear = (maxYearInList - minYearInList+2)*3;
|
||||||
|
|
||||||
|
|
|
@ -325,7 +325,10 @@ void jceLogin::reValidation()
|
||||||
if (checkValidation())
|
if (checkValidation())
|
||||||
{
|
{
|
||||||
if (makeSecondVisit() == true)
|
if (makeSecondVisit() == true)
|
||||||
|
{
|
||||||
|
statusBar->setIconConnectionStatus(jceStatusBar::LoggedIn);
|
||||||
qDebug() << Q_FUNC_INFO << "Validated";
|
qDebug() << Q_FUNC_INFO << "Validated";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
qWarning() << Q_FUNC_INFO << "Second visit finished with an error";
|
qWarning() << Q_FUNC_INFO << "Second visit finished with an error";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue