add revert button in gpa tab
This commit is contained in:
parent
10f53aa3f3
commit
ae7d20beda
11 changed files with 88 additions and 8 deletions
|
@ -6,6 +6,7 @@
|
||||||
coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
|
coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
|
||||||
{
|
{
|
||||||
this->gp = NULL;
|
this->gp = NULL;
|
||||||
|
this->gpCpy = NULL;
|
||||||
this->us = usrPtr;
|
this->us = usrPtr;
|
||||||
this->courseTBL = ptr;
|
this->courseTBL = ptr;
|
||||||
|
|
||||||
|
@ -29,6 +30,8 @@ coursesTableManager::~coursesTableManager()
|
||||||
{
|
{
|
||||||
courseTBL = NULL;
|
courseTBL = NULL;
|
||||||
delete gp;
|
delete gp;
|
||||||
|
delete gpCpy;
|
||||||
|
gpCpy = NULL;
|
||||||
gp = NULL;
|
gp = NULL;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -55,6 +58,7 @@ void coursesTableManager::setCoursesList(QString &html)
|
||||||
{
|
{
|
||||||
clearTable();
|
clearTable();
|
||||||
gp = new GradePage(html);
|
gp = new GradePage(html);
|
||||||
|
this->gpCpy = new GradePage(*gp);
|
||||||
insertJceCoursesIntoTable();
|
insertJceCoursesIntoTable();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -294,6 +298,36 @@ void coursesTableManager::clearTable()
|
||||||
gp = NULL;
|
gp = NULL;
|
||||||
courseTBL->repaint();
|
courseTBL->repaint();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief coursesTableManager::revertChanges
|
||||||
|
*
|
||||||
|
* restored data from the copy of grade page
|
||||||
|
* TODO: revert-> make it efficient
|
||||||
|
*/
|
||||||
|
void coursesTableManager::revertChanges()
|
||||||
|
{
|
||||||
|
if (courseTBL->rowCount() <= 0)
|
||||||
|
return;
|
||||||
|
if (this->gpCpy == NULL)
|
||||||
|
return;
|
||||||
|
if (this->gp == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < courseTBL->rowCount(); ++i)
|
||||||
|
{
|
||||||
|
gradeCourse * temp = getCourseByRow(i);
|
||||||
|
for (gradeCourse * notChangedCourse: gpCpy->getCourses())
|
||||||
|
{
|
||||||
|
if ((temp->getGrade() != notChangedCourse->getGrade()) &&
|
||||||
|
(temp->getSerialNum() == notChangedCourse->getSerialNum()))
|
||||||
|
{
|
||||||
|
courseTBL->item(i,gradeCourse::CourseScheme::GRADE)->setText(QString::number(notChangedCourse->getGrade()));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
gradeCourse *coursesTableManager::getCourseByRow(int row)
|
gradeCourse *coursesTableManager::getCourseByRow(int row)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,10 +29,13 @@ public:
|
||||||
void influnceCourseChanged(bool status);
|
void influnceCourseChanged(bool status);
|
||||||
void clearTable();
|
void clearTable();
|
||||||
|
|
||||||
|
void revertChanges();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gradegraph *graph;
|
gradegraph *graph;
|
||||||
QTableWidget *courseTBL;
|
QTableWidget *courseTBL;
|
||||||
GradePage *gp;
|
GradePage *gp;
|
||||||
|
GradePage *gpCpy;
|
||||||
user *us;
|
user *us;
|
||||||
|
|
||||||
gradeCourse * getCourseByRow(int row);
|
gradeCourse * getCourseByRow(int row);
|
||||||
|
|
|
@ -233,6 +233,16 @@ void MainScreen::on_graphButton_clicked()
|
||||||
if (!courseTableMgr->showGraph())
|
if (!courseTableMgr->showGraph())
|
||||||
QMessageBox::critical(this,tr("Error"),tr("You must to load GPA first\nClick on 'Get GPA'"));
|
QMessageBox::critical(this,tr("Error"),tr("You must to load GPA first\nClick on 'Get GPA'"));
|
||||||
}
|
}
|
||||||
|
void MainScreen::on_revertBtn_clicked()
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
if (!isBusy())
|
||||||
|
{
|
||||||
|
lock();
|
||||||
|
courseTableMgr->revertChanges();
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//EVENTS ON CALENDAR TAB
|
//EVENTS ON CALENDAR TAB
|
||||||
|
@ -425,3 +435,4 @@ bool MainScreen::isBusy()
|
||||||
{
|
{
|
||||||
return this->isBlocked;
|
return this->isBlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,8 @@ private slots:
|
||||||
void on_labelMadeBy_linkActivated(const QString &link);
|
void on_labelMadeBy_linkActivated(const QString &link);
|
||||||
// void on_progressBar_valueChanged(int value);
|
// void on_progressBar_valueChanged(int value);
|
||||||
|
|
||||||
|
void on_revertBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void checkLocale();
|
void checkLocale();
|
||||||
|
|
|
@ -508,14 +508,14 @@ font-size: 15px;
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayoutBtns">
|
<layout class="QGridLayout" name="gridLayoutBtn">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="1">
|
<item row="0" column="2">
|
||||||
<widget class="QPushButton" name="clearTableButton">
|
<widget class="QPushButton" name="clearTableButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
@ -523,6 +523,12 @@ font-size: 15px;
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>35</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p><span style=" font-weight:600;">Clear table</span></p></body></html></string>
|
<string><html><head/><body><p><span style=" font-weight:600;">Clear table</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -537,7 +543,7 @@ font-size: 15px;
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
|
@ -559,6 +565,13 @@ font-size: 15px;
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="revertBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Revert Changes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -11,6 +11,17 @@ gradeCourse::gradeCourse(int year, int semester, int courseNumInList, int serial
|
||||||
this->courseNumInList = courseNumInList;
|
this->courseNumInList = courseNumInList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gradeCourse::gradeCourse(gradeCourse &other) : Course(other.getSerialNum(),other.getName(),other.getType())
|
||||||
|
{
|
||||||
|
this->points = other.points;
|
||||||
|
this->hours = other.hours;
|
||||||
|
this->grade = other.grade;
|
||||||
|
this->additions = other.additions;
|
||||||
|
this->year = other.year;
|
||||||
|
this->semester = other.semester;
|
||||||
|
this->courseNumInList = other.courseNumInList;
|
||||||
|
}
|
||||||
|
|
||||||
gradeCourse::~gradeCourse()
|
gradeCourse::~gradeCourse()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
gradeCourse(int year, int semester, int courseNumInList, int serial, QString name, QString type, double points,double hours, double grade, QString additions);
|
gradeCourse(int year, int semester, int courseNumInList, int serial, QString name, QString type, double points,double hours, double grade, QString additions);
|
||||||
|
gradeCourse(gradeCourse &other);
|
||||||
~gradeCourse();
|
~gradeCourse();
|
||||||
|
|
||||||
int getYear() const { return this->year; }
|
int getYear() const { return this->year; }
|
||||||
|
|
|
@ -8,6 +8,14 @@ GradePage::GradePage(QString html) : Page()
|
||||||
tempHtml = getString(html);
|
tempHtml = getString(html);
|
||||||
coursesListInit(tempHtml);
|
coursesListInit(tempHtml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GradePage::GradePage(GradePage &other)
|
||||||
|
{
|
||||||
|
for(gradeCourse* c : other.getCourses())
|
||||||
|
{
|
||||||
|
courses.push_back(new gradeCourse(*c));
|
||||||
|
}
|
||||||
|
}
|
||||||
GradePage::~GradePage()
|
GradePage::~GradePage()
|
||||||
{
|
{
|
||||||
for (Course* c : courses)
|
for (Course* c : courses)
|
||||||
|
|
|
@ -29,6 +29,7 @@ class GradePage : public Page
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GradePage(QString html);
|
GradePage(QString html);
|
||||||
|
GradePage(GradePage &other);
|
||||||
~GradePage();
|
~GradePage();
|
||||||
|
|
||||||
void removeCourse(QString courseSerialID);
|
void removeCourse(QString courseSerialID);
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
#include "gradegraph.h"
|
#include "gradegraph.h"
|
||||||
#include "ui_gradegraph.h"
|
#include "ui_gradegraph.h"
|
||||||
/*
|
|
||||||
* TODO: make graph understandable
|
|
||||||
* BUG: graph bug when theres small range of years
|
|
||||||
*/
|
|
||||||
gradegraph::gradegraph(QWidget *parent) : QDialog(parent), ui(new Ui::gradegraph)
|
gradegraph::gradegraph(QWidget *parent) : QDialog(parent), ui(new Ui::gradegraph)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
Loading…
Reference in a new issue