diff --git a/main/CourseTab/coursestablemanager.cpp b/main/CourseTab/coursestablemanager.cpp
index b778e8b..2270f3f 100644
--- a/main/CourseTab/coursestablemanager.cpp
+++ b/main/CourseTab/coursestablemanager.cpp
@@ -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)
{
diff --git a/main/CourseTab/coursestablemanager.h b/main/CourseTab/coursestablemanager.h
index bf72c42..41e8713 100644
--- a/main/CourseTab/coursestablemanager.h
+++ b/main/CourseTab/coursestablemanager.h
@@ -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);
diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp
index e6c435b..39eb484 100644
--- a/main/mainscreen.cpp
+++ b/main/mainscreen.cpp
@@ -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;
}
+
diff --git a/main/mainscreen.h b/main/mainscreen.h
index 73066b6..cc3b63e 100644
--- a/main/mainscreen.h
+++ b/main/mainscreen.h
@@ -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();
diff --git a/main/mainscreen.ui b/main/mainscreen.ui
index d0884ab..ace596d 100644
--- a/main/mainscreen.ui
+++ b/main/mainscreen.ui
@@ -508,14 +508,14 @@ font-size: 15px;
0
-
-
+
0
6
-
-
+
-
@@ -523,6 +523,12 @@ font-size: 15px;
0
+
+
+ 16777215
+ 35
+
+
<html><head/><body><p><span style=" font-weight:600;">Clear table</span></p></body></html>
@@ -537,7 +543,7 @@ font-size: 15px;
true
-
+
0
0
@@ -559,6 +565,13 @@ font-size: 15px;
+ -
+
+
+ Revert Changes
+
+
+
-
diff --git a/src/jceConnection/jcesslclient.cpp b/src/jceConnection/jcesslclient.cpp
index 4c72f16..b3e4579 100644
--- a/src/jceConnection/jcesslclient.cpp
+++ b/src/jceConnection/jcesslclient.cpp
@@ -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;
diff --git a/src/jceData/Grades/gradeCourse.cpp b/src/jceData/Grades/gradeCourse.cpp
index 13b1a8c..d280102 100644
--- a/src/jceData/Grades/gradeCourse.cpp
+++ b/src/jceData/Grades/gradeCourse.cpp
@@ -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()
{
diff --git a/src/jceData/Grades/gradeCourse.h b/src/jceData/Grades/gradeCourse.h
index 8bd67e4..9884571 100644
--- a/src/jceData/Grades/gradeCourse.h
+++ b/src/jceData/Grades/gradeCourse.h
@@ -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; }
diff --git a/src/jceData/Grades/gradePage.cpp b/src/jceData/Grades/gradePage.cpp
index 47e4307..f5703b7 100644
--- a/src/jceData/Grades/gradePage.cpp
+++ b/src/jceData/Grades/gradePage.cpp
@@ -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)
diff --git a/src/jceData/Grades/gradePage.h b/src/jceData/Grades/gradePage.h
index 727c82d..741f757 100644
--- a/src/jceData/Grades/gradePage.h
+++ b/src/jceData/Grades/gradePage.h
@@ -29,6 +29,7 @@ class GradePage : public Page
public:
GradePage(QString html);
+ GradePage(GradePage &other);
~GradePage();
void removeCourse(QString courseSerialID);
diff --git a/src/jceData/Grades/graph/gradegraph.cpp b/src/jceData/Grades/graph/gradegraph.cpp
index 025ea3a..a1ad338 100644
--- a/src/jceData/Grades/graph/gradegraph.cpp
+++ b/src/jceData/Grades/graph/gradegraph.cpp
@@ -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);