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)
|
||||
{
|
||||
this->gp = NULL;
|
||||
this->gpCpy = NULL;
|
||||
this->us = usrPtr;
|
||||
this->courseTBL = ptr;
|
||||
|
||||
|
@ -29,6 +30,8 @@ coursesTableManager::~coursesTableManager()
|
|||
{
|
||||
courseTBL = NULL;
|
||||
delete gp;
|
||||
delete gpCpy;
|
||||
gpCpy = NULL;
|
||||
gp = NULL;
|
||||
}
|
||||
/**
|
||||
|
@ -55,6 +58,7 @@ void coursesTableManager::setCoursesList(QString &html)
|
|||
{
|
||||
clearTable();
|
||||
gp = new GradePage(html);
|
||||
this->gpCpy = new GradePage(*gp);
|
||||
insertJceCoursesIntoTable();
|
||||
}
|
||||
/**
|
||||
|
@ -294,6 +298,36 @@ void coursesTableManager::clearTable()
|
|||
gp = NULL;
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -29,10 +29,13 @@ public:
|
|||
void influnceCourseChanged(bool status);
|
||||
void clearTable();
|
||||
|
||||
void revertChanges();
|
||||
|
||||
private:
|
||||
gradegraph *graph;
|
||||
QTableWidget *courseTBL;
|
||||
GradePage *gp;
|
||||
GradePage *gpCpy;
|
||||
user *us;
|
||||
|
||||
gradeCourse * getCourseByRow(int row);
|
||||
|
|
|
@ -233,6 +233,16 @@ void MainScreen::on_graphButton_clicked()
|
|||
if (!courseTableMgr->showGraph())
|
||||
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
|
||||
|
@ -425,3 +435,4 @@ bool MainScreen::isBusy()
|
|||
{
|
||||
return this->isBlocked;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ private slots:
|
|||
void on_labelMadeBy_linkActivated(const QString &link);
|
||||
// void on_progressBar_valueChanged(int value);
|
||||
|
||||
void on_revertBtn_clicked();
|
||||
|
||||
private:
|
||||
|
||||
void checkLocale();
|
||||
|
|
|
@ -508,14 +508,14 @@ font-size: 15px;
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayoutBtns">
|
||||
<layout class="QGridLayout" name="gridLayoutBtn">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="clearTableButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
|
@ -523,6 +523,12 @@ font-size: 15px;
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p><span style=" font-weight:600;">Clear table</span></p></body></html></string>
|
||||
</property>
|
||||
|
@ -537,7 +543,7 @@ font-size: 15px;
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -559,6 +565,13 @@ font-size: 15px;
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="revertBtn">
|
||||
<property name="text">
|
||||
<string>Revert Changes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -11,6 +11,17 @@ gradeCourse::gradeCourse(int year, int semester, int courseNumInList, int serial
|
|||
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()
|
||||
{
|
||||
|
||||
|
|
|
@ -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(gradeCourse &other);
|
||||
~gradeCourse();
|
||||
|
||||
int getYear() const { return this->year; }
|
||||
|
|
|
@ -8,6 +8,14 @@ GradePage::GradePage(QString html) : Page()
|
|||
tempHtml = getString(html);
|
||||
coursesListInit(tempHtml);
|
||||
}
|
||||
|
||||
GradePage::GradePage(GradePage &other)
|
||||
{
|
||||
for(gradeCourse* c : other.getCourses())
|
||||
{
|
||||
courses.push_back(new gradeCourse(*c));
|
||||
}
|
||||
}
|
||||
GradePage::~GradePage()
|
||||
{
|
||||
for (Course* c : courses)
|
||||
|
|
|
@ -29,6 +29,7 @@ class GradePage : public Page
|
|||
|
||||
public:
|
||||
GradePage(QString html);
|
||||
GradePage(GradePage &other);
|
||||
~GradePage();
|
||||
|
||||
void removeCourse(QString courseSerialID);
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
#include "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)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
Loading…
Reference in a new issue