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)
|
||||
{
|
||||
this->gp = NULL;
|
||||
this->us = usrPtr;
|
||||
this->courseTBL = ptr;
|
||||
this->gp = NULL;
|
||||
this->us = usrPtr;
|
||||
this->courseTBL = ptr;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Initilizing Table
|
||||
*/
|
||||
courseTBL->setRowCount(0);
|
||||
courseTBL->setColumnCount(COURSE_FIELDS);
|
||||
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");
|
||||
courseTBL->setHorizontalHeaderLabels(mz);
|
||||
courseTBL->verticalHeader()->setVisible(false);
|
||||
courseTBL->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
courseTBL->setShowGrid(true);
|
||||
courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
|
||||
courseTBL->setRowCount(0);
|
||||
courseTBL->setColumnCount(COURSE_FIELDS);
|
||||
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");
|
||||
courseTBL->setHorizontalHeaderLabels(mz);
|
||||
courseTBL->verticalHeader()->setVisible(false);
|
||||
courseTBL->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
courseTBL->setShowGrid(true);
|
||||
courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
|
||||
|
||||
graph = new gradegraph(ptr);
|
||||
graph = new gradegraph(ptr);
|
||||
}
|
||||
|
||||
coursesTableManager::~coursesTableManager()
|
||||
{
|
||||
courseTBL = NULL;
|
||||
delete gp;
|
||||
gp = NULL;
|
||||
courseTBL = NULL;
|
||||
delete gp;
|
||||
gp = NULL;
|
||||
}
|
||||
/**
|
||||
* @brief coursesTableManager::insertJceCoursesIntoTable phrasing the course list to rows in table
|
||||
*/
|
||||
void coursesTableManager::insertJceCoursesIntoTable()
|
||||
{
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
{
|
||||
if (us->getInfluenceCourseOnly())
|
||||
if (us->getInfluenceCourseOnly())
|
||||
{
|
||||
if (isCourseInfluence(c))
|
||||
addRow(c);
|
||||
if (isCourseInfluence(c))
|
||||
addRow(c);
|
||||
}
|
||||
else
|
||||
addRow(c);
|
||||
else
|
||||
addRow(c);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -53,9 +53,9 @@ void coursesTableManager::insertJceCoursesIntoTable()
|
|||
*/
|
||||
void coursesTableManager::setCoursesList(QString &html)
|
||||
{
|
||||
if (gp != NULL)
|
||||
gp->~GradePage();
|
||||
gp = new GradePage(html);
|
||||
clearTable();
|
||||
gp = new GradePage(html);
|
||||
insertJceCoursesIntoTable();
|
||||
}
|
||||
/**
|
||||
* @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 isNumFlag = true;
|
||||
if (courseTBL->item(row,gradeCourse::CourseScheme::SERIAL) == NULL)
|
||||
return true;
|
||||
bool isNumFlag = true;
|
||||
if (courseTBL->item(row,gradeCourse::CourseScheme::SERIAL) == NULL)
|
||||
return true;
|
||||
|
||||
int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt();
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt();
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
{
|
||||
if (c->getSerialNum() == serialCourse)
|
||||
if (c->getSerialNum() == serialCourse)
|
||||
{
|
||||
switch (col)
|
||||
switch (col)
|
||||
{
|
||||
case (gradeCourse::CourseScheme::COURSE_NUMBER_IN_LIST):
|
||||
c->setCourseNumInList(change.toInt());
|
||||
break;
|
||||
c->setCourseNumInList(change.toInt());
|
||||
break;
|
||||
case (gradeCourse::CourseScheme::YEAR):
|
||||
c->setYear(change.toInt());
|
||||
break;
|
||||
c->setYear(change.toInt());
|
||||
break;
|
||||
case (gradeCourse::CourseScheme::SEMESTER):
|
||||
c->setSemester(change.toInt());
|
||||
break;
|
||||
c->setSemester(change.toInt());
|
||||
break;
|
||||
case (gradeCourse::CourseScheme::NAME):
|
||||
c->setName(change);
|
||||
break;
|
||||
c->setName(change);
|
||||
break;
|
||||
case (gradeCourse::CourseScheme::TYPE):
|
||||
c->setType(change);
|
||||
break;
|
||||
c->setType(change);
|
||||
break;
|
||||
case (gradeCourse::CourseScheme::POINTS):
|
||||
{
|
||||
{
|
||||
change.toDouble(&isNumFlag);
|
||||
|
||||
if (!isNumFlag)
|
||||
{
|
||||
{
|
||||
courseTBL->item(row,col)->setText(QString::number(c->getPoints()));
|
||||
}
|
||||
}
|
||||
else
|
||||
c->setPoints(change.toDouble());
|
||||
c->setPoints(change.toDouble());
|
||||
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)
|
||||
{
|
||||
int i=1,j=1;
|
||||
int i=1,j=1;
|
||||
|
||||
j = 0;
|
||||
QTableWidgetItem *number,*year,*semester,*serial,*name,*type,*points,*hours,*grade,*addition;
|
||||
const gradeCourse * c;
|
||||
if (courseToAdd != NULL)
|
||||
j = 0;
|
||||
QTableWidgetItem *number,*year,*semester,*serial,*name,*type,*points,*hours,*grade,*addition;
|
||||
const gradeCourse * c;
|
||||
if (courseToAdd != NULL)
|
||||
{
|
||||
c = courseToAdd;
|
||||
if (!isCourseAlreadyInserted(c->getSerialNum()))
|
||||
c = courseToAdd;
|
||||
if (!isCourseAlreadyInserted(c->getSerialNum()))
|
||||
{
|
||||
courseTBL->setRowCount(courseTBL->rowCount() + 1);
|
||||
i = courseTBL->rowCount()-1;
|
||||
courseTBL->setRowCount(courseTBL->rowCount() + 1);
|
||||
i = courseTBL->rowCount()-1;
|
||||
|
||||
number = new QTableWidgetItem();
|
||||
number->setData(Qt::EditRole, c->getCourseNumInList());
|
||||
number->setFlags(number->flags() & ~Qt::ItemIsEditable);
|
||||
number = new QTableWidgetItem();
|
||||
number->setData(Qt::EditRole, c->getCourseNumInList());
|
||||
number->setFlags(number->flags() & ~Qt::ItemIsEditable);
|
||||
|
||||
year = new QTableWidgetItem();
|
||||
year->setData(Qt::EditRole,c->getYear());
|
||||
year->setFlags(year->flags() & ~Qt::ItemIsEditable);
|
||||
year = new QTableWidgetItem();
|
||||
year->setData(Qt::EditRole,c->getYear());
|
||||
year->setFlags(year->flags() & ~Qt::ItemIsEditable);
|
||||
|
||||
semester = new QTableWidgetItem();
|
||||
semester->setData(Qt::EditRole,c->getSemester());
|
||||
semester->setFlags(semester->flags() & ~Qt::ItemIsEditable);
|
||||
semester = new QTableWidgetItem();
|
||||
semester->setData(Qt::EditRole,c->getSemester());
|
||||
semester->setFlags(semester->flags() & ~Qt::ItemIsEditable);
|
||||
|
||||
serial = new QTableWidgetItem();
|
||||
serial->setData(Qt::EditRole,c->getSerialNum());
|
||||
serial->setFlags(serial->flags() & ~Qt::ItemIsEditable);
|
||||
serial = new QTableWidgetItem();
|
||||
serial->setData(Qt::EditRole,c->getSerialNum());
|
||||
serial->setFlags(serial->flags() & ~Qt::ItemIsEditable);
|
||||
|
||||
name = new QTableWidgetItem();
|
||||
name->setData(Qt::EditRole,c->getName());
|
||||
name->setFlags(name->flags() & ~Qt::ItemIsEditable);
|
||||
name = new QTableWidgetItem();
|
||||
name->setData(Qt::EditRole,c->getName());
|
||||
name->setFlags(name->flags() & ~Qt::ItemIsEditable);
|
||||
|
||||
type = new QTableWidgetItem();
|
||||
type->setData(Qt::EditRole, c->getType());
|
||||
type->setFlags(type->flags() & ~Qt::ItemIsEditable);
|
||||
type = new QTableWidgetItem();
|
||||
type->setData(Qt::EditRole, c->getType());
|
||||
type->setFlags(type->flags() & ~Qt::ItemIsEditable);
|
||||
|
||||
points = new QTableWidgetItem();
|
||||
points->setData(Qt::EditRole, c->getPoints());
|
||||
points->setFlags(points->flags() & ~Qt::ItemIsEditable);
|
||||
points = new QTableWidgetItem();
|
||||
points->setData(Qt::EditRole, c->getPoints());
|
||||
points->setFlags(points->flags() & ~Qt::ItemIsEditable);
|
||||
|
||||
hours = new QTableWidgetItem();
|
||||
hours->setData(Qt::EditRole, c->getHours());
|
||||
hours->setFlags(hours->flags() & ~Qt::ItemIsEditable);
|
||||
hours = new QTableWidgetItem();
|
||||
hours->setData(Qt::EditRole, c->getHours());
|
||||
hours->setFlags(hours->flags() & ~Qt::ItemIsEditable);
|
||||
|
||||
grade = new QTableWidgetItem();
|
||||
//grade->setData(Qt::EditRole,c->getGrade());
|
||||
//BUG QT bug
|
||||
//good for sorting, the problem is when you edit -> the cell indicator disappear
|
||||
grade->setText(QString::number(c->getGrade()));
|
||||
grade = new QTableWidgetItem();
|
||||
//grade->setData(Qt::EditRole,c->getGrade());
|
||||
//BUG QT bug
|
||||
//good for sorting, the problem is when you edit -> the cell indicator disappear
|
||||
grade->setText(QString::number(c->getGrade()));
|
||||
|
||||
addition = new QTableWidgetItem();
|
||||
addition->setData(Qt::EditRole,c->getAddidtions());
|
||||
addition = new QTableWidgetItem();
|
||||
addition->setData(Qt::EditRole,c->getAddidtions());
|
||||
|
||||
courseTBL->setItem(i,j++,number);
|
||||
courseTBL->setItem(i,j++,year);
|
||||
courseTBL->setItem(i,j++,semester);
|
||||
courseTBL->setItem(i,j++,serial);
|
||||
courseTBL->setItem(i,j++,name);
|
||||
courseTBL->setItem(i,j++,type);
|
||||
courseTBL->setItem(i,j++,points);
|
||||
courseTBL->setItem(i,j++,hours);
|
||||
courseTBL->setItem(i,j,grade);
|
||||
courseTBL->setItem(i,j++,number);
|
||||
courseTBL->setItem(i,j++,year);
|
||||
courseTBL->setItem(i,j++,semester);
|
||||
courseTBL->setItem(i,j++,serial);
|
||||
courseTBL->setItem(i,j++,name);
|
||||
courseTBL->setItem(i,j++,type);
|
||||
courseTBL->setItem(i,j++,points);
|
||||
courseTBL->setItem(i,j++,hours);
|
||||
courseTBL->setItem(i,j++,grade);
|
||||
courseTBL->setItem(i,j,addition);
|
||||
|
||||
//FIXME : make it a function, add it when cell has changed
|
||||
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);
|
||||
colorTheGrade(i);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
qCritical() << Q_FUNC_INFO << " no course to load!";
|
||||
qCritical() << Q_FUNC_INFO << " no course to load!";
|
||||
}
|
||||
|
||||
courseTBL->resizeColumnsToContents();
|
||||
courseTBL->resizeRowsToContents();
|
||||
courseTBL->resizeColumnsToContents();
|
||||
courseTBL->resizeRowsToContents();
|
||||
|
||||
}
|
||||
double coursesTableManager::getAvg()
|
||||
{
|
||||
if (this->gp != NULL)
|
||||
return gp->getAvg();
|
||||
return 0;
|
||||
if (this->gp != NULL)
|
||||
return gp->getAvg();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void coursesTableManager::showGraph()
|
||||
bool coursesTableManager::showGraph()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if (gp != NULL)
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if (gp != NULL)
|
||||
{
|
||||
this->graph->showGraph(gp);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << Q_FUNC_INFO << "open with null grade page";
|
||||
this->graph->showGraph(gp);
|
||||
return true;
|
||||
}
|
||||
qWarning() << Q_FUNC_INFO << "open with null grade page";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus)
|
||||
{
|
||||
if (ignoreCourseStatus)
|
||||
if (ignoreCourseStatus)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < courseTBL->rowCount())
|
||||
int i = 0;
|
||||
while (i < courseTBL->rowCount())
|
||||
{
|
||||
if (courseTBL->item(i,gradeCourse::CourseScheme::POINTS)->text().compare("0") == 0)
|
||||
courseTBL->removeRow(i--);
|
||||
i++;
|
||||
if (courseTBL->item(i,gradeCourse::CourseScheme::POINTS)->text().compare("0") == 0)
|
||||
courseTBL->removeRow(i--);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (this->gp != NULL)
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
{
|
||||
if (!(isCourseAlreadyInserted(c->getSerialNum())))
|
||||
if (c->getPoints() == 0)
|
||||
addRow(c);
|
||||
}
|
||||
if (this->gp != NULL)
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
{
|
||||
if (!(isCourseAlreadyInserted(c->getSerialNum())))
|
||||
if (c->getPoints() == 0)
|
||||
addRow(c);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void coursesTableManager::clearTable()
|
||||
{
|
||||
if (courseTBL->rowCount() == 0)
|
||||
return;
|
||||
if (courseTBL->rowCount() == 0)
|
||||
return;
|
||||
|
||||
int i = 0; //starting point
|
||||
while (courseTBL->rowCount() > i)
|
||||
int i = 0; //starting point
|
||||
while (courseTBL->rowCount() > i)
|
||||
{
|
||||
gp->removeCourse(courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text());
|
||||
courseTBL->removeRow(i);
|
||||
if (gp != NULL)
|
||||
gp->removeCourse(courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text());
|
||||
courseTBL->removeRow(i);
|
||||
}
|
||||
gp = NULL;
|
||||
courseTBL->repaint();
|
||||
if (gp != NULL)
|
||||
delete gp;
|
||||
gp = NULL;
|
||||
courseTBL->repaint();
|
||||
}
|
||||
|
||||
gradeCourse *coursesTableManager::getCourseByRow(int row)
|
||||
{
|
||||
QString courseSerial = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text();
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
QString courseSerial = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text();
|
||||
for (gradeCourse *c: gp->getCourses())
|
||||
{
|
||||
if (c->getSerialNum() == courseSerial.toDouble())
|
||||
return c;
|
||||
if (c->getSerialNum() == courseSerial.toDouble())
|
||||
return c;
|
||||
}
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool coursesTableManager::isCourseAlreadyInserted(double courseID)
|
||||
{
|
||||
int i;
|
||||
for (i = courseTBL->rowCount(); i >= 0; --i)
|
||||
int 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();
|
||||
if (QString::number(courseID) == courseSerial)
|
||||
return true;
|
||||
QString courseSerial = courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text();
|
||||
if (QString::number(courseID) == courseSerial)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool coursesTableManager::isCourseInfluence(const gradeCourse *courseToCheck)
|
||||
{
|
||||
if (courseToCheck->getPoints() > 0)
|
||||
return true;
|
||||
return false;
|
||||
if (courseToCheck->getPoints() > 0)
|
||||
return true;
|
||||
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
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtGlobal>
|
||||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QTableWidget>
|
||||
#include <QString>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "./src/jceData/Grades/graph/gradegraph.h"
|
||||
#include "./src/jceData/Grades/gradePage.h"
|
||||
#include "./src/jceSettings/user.h"
|
||||
|
@ -28,7 +24,7 @@ public:
|
|||
void addRow(const gradeCourse * courseToAdd = 0);
|
||||
double getAvg();
|
||||
|
||||
void showGraph();
|
||||
bool showGraph();
|
||||
|
||||
void influnceCourseChanged(bool status);
|
||||
void clearTable();
|
||||
|
@ -42,6 +38,8 @@ private:
|
|||
gradeCourse * getCourseByRow(int row);
|
||||
bool isCourseAlreadyInserted(double courseID);
|
||||
bool isCourseInfluence(const gradeCourse *courseToCheck);
|
||||
|
||||
void colorTheGrade(int rowIndex);
|
||||
};
|
||||
|
||||
#endif // COURSESTABLEMANAGER_H
|
||||
|
|
|
@ -59,6 +59,7 @@ bool loginHandler::makeConnection()
|
|||
{
|
||||
case jceLogin::JCE_YOU_ARE_IN:
|
||||
{
|
||||
statusBar->setIconConnectionStatus(jceStatusBar::LoggedIn);
|
||||
logggedInFlag = true;
|
||||
return logggedInFlag;
|
||||
}
|
||||
|
@ -145,7 +146,6 @@ int loginHandler::makeCalendarRequest(int year, int semester)
|
|||
else
|
||||
return jceLogin::JCE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
int loginHandler::makeExamsScheduleRequest(int year, int semester)
|
||||
{
|
||||
|
||||
|
|
|
@ -152,7 +152,6 @@ void MainScreen::on_ratesButton_clicked()
|
|||
statusBar->setIconConnectionStatus(jceStatusBar::Inserting);
|
||||
pageString = loginHandel->getCurrentPageContect();
|
||||
courseTableMgr->setCoursesList(pageString);
|
||||
courseTableMgr->insertJceCoursesIntoTable();
|
||||
statusBar->setIconConnectionStatus(jceStatusBar::Done);
|
||||
}
|
||||
else if (status == jceLogin::JCE_NOT_CONNECTED)
|
||||
|
@ -231,7 +230,8 @@ void MainScreen::on_clearTableButton_clicked()
|
|||
void MainScreen::on_graphButton_clicked()
|
||||
{
|
||||
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()));
|
||||
|
||||
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 << "return with flag: " << recieveLastPacket;
|
||||
|
|
|
@ -135,8 +135,10 @@ gradeCourse* GradePage::lineToCourse(QString line)
|
|||
if (year >= maxYear)
|
||||
maxYear = year;
|
||||
|
||||
if (year <= minYear)
|
||||
if ((year <= minYear) && (points > 0)) //not graded yet isnt influced year!
|
||||
{
|
||||
minYear = year;
|
||||
}
|
||||
|
||||
tempC = new gradeCourse(year,semester,courseNumInList,serial,name,type,points,hours,grade,additions);
|
||||
return tempC;
|
||||
|
@ -152,11 +154,12 @@ bool GradePage::isGradedYet(QString grade)
|
|||
if (strlen(grade.toStdString().c_str()) <= 1)
|
||||
return false;
|
||||
|
||||
for (char c: grade.toStdString())
|
||||
for (QChar c: grade)
|
||||
{
|
||||
if (c == '\0')
|
||||
break;
|
||||
if (((!isdigit((int)c)) && (!isspace((int)c)))) //48 = 0, 57 = 9
|
||||
|
||||
if (((!c.isDigit()) && (!c.isSpace()))) //48 = 0, 57 = 9
|
||||
return false;
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,8 @@ void gradegraph::showGraph(GradePage *gpPTR)
|
|||
qDebug() << Q_FUNC_INFO;
|
||||
this->gp = gpPTR;
|
||||
|
||||
clearGraph();
|
||||
if (ui->graphwidget->graphCount() > 0)
|
||||
clearGraph();
|
||||
|
||||
setVisualization();
|
||||
setGraphsData();
|
||||
|
@ -34,7 +35,7 @@ gradegraph::~gradegraph()
|
|||
|
||||
void gradegraph::setGraphsData()
|
||||
{
|
||||
int minYearInList = gp->getMinYearInList();
|
||||
int minYearInList = gp->getMinYearInList()-1;
|
||||
int maxYearInList = gp->getMaxYearInList()+1;
|
||||
int xRangeForYear = (maxYearInList - minYearInList+2)*3;
|
||||
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)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::red, Qt::red, 7));
|
||||
|
||||
|
||||
int minYearInList = gp->getMinYearInList();
|
||||
int minYearInList = gp->getMinYearInList()-1;
|
||||
int maxYearInList = gp->getMaxYearInList()+1;
|
||||
int xRangeForYear = (maxYearInList - minYearInList+2)*3;
|
||||
|
||||
|
|
|
@ -325,7 +325,10 @@ void jceLogin::reValidation()
|
|||
if (checkValidation())
|
||||
{
|
||||
if (makeSecondVisit() == true)
|
||||
{
|
||||
statusBar->setIconConnectionStatus(jceStatusBar::LoggedIn);
|
||||
qDebug() << Q_FUNC_INFO << "Validated";
|
||||
}
|
||||
else
|
||||
qWarning() << Q_FUNC_INFO << "Second visit finished with an error";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue