diff --git a/main/CourseTab/coursestablemanager.cpp b/main/CourseTab/coursestablemanager.cpp index 2270f3f..60ef490 100644 --- a/main/CourseTab/coursestablemanager.cpp +++ b/main/CourseTab/coursestablemanager.cpp @@ -1,8 +1,4 @@ #include "coursestablemanager.h" -/* - * TODO: revert gpa to origin - * - */ coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr) { this->gp = NULL; @@ -322,7 +318,7 @@ void coursesTableManager::revertChanges() (temp->getSerialNum() == notChangedCourse->getSerialNum())) { courseTBL->item(i,gradeCourse::CourseScheme::GRADE)->setText(QString::number(notChangedCourse->getGrade())); - + break; } } } diff --git a/src/jceData/CSV/csv_exporter.cpp b/src/jceData/CSV/csv_exporter.cpp index f1843c8..7f22f69 100644 --- a/src/jceData/CSV/csv_exporter.cpp +++ b/src/jceData/CSV/csv_exporter.cpp @@ -2,8 +2,8 @@ /* * - * Class doc can be bound in csv_exporter.h - * + * Class doc can be found in csv_exporter.h + * TODO: add exam exportation */ CSV_Exporter::CSV_Exporter() { diff --git a/src/jceData/Calendar/Exams/calendarExam.cpp b/src/jceData/Calendar/Exams/calendarExam.cpp index 39b19b9..79d866f 100644 --- a/src/jceData/Calendar/Exams/calendarExam.cpp +++ b/src/jceData/Calendar/Exams/calendarExam.cpp @@ -4,6 +4,21 @@ calendarExam::calendarExam() { htmlDataHolderParsed = ""; } +/** + * @brief calendarExam::calendarExam + * copy constructor + * @param other + */ +calendarExam::calendarExam(calendarExam &other) +{ + examsCounter = 0; + exams.clear(); + for (calendarExamCourse * tempExam: other.getExams()) + { + this->exams.push_back(new calendarExamCourse(*tempExam)); + examsCounter++; + } +} /** * @brief calendarExam::setPage - getting a html page and stripping it into a exams schedule in a list diff --git a/src/jceData/Calendar/Exams/calendarExam.h b/src/jceData/Calendar/Exams/calendarExam.h index b538da4..dd43e46 100644 --- a/src/jceData/Calendar/Exams/calendarExam.h +++ b/src/jceData/Calendar/Exams/calendarExam.h @@ -20,6 +20,7 @@ class calendarExam : public Page { public: calendarExam(); + calendarExam(calendarExam &other); void setPage(QString html); QList getExams() { return exams; } diff --git a/src/jceData/Calendar/Exams/calendarExamCourse.cpp b/src/jceData/Calendar/Exams/calendarExamCourse.cpp index 7e9859b..b613fd0 100644 --- a/src/jceData/Calendar/Exams/calendarExamCourse.cpp +++ b/src/jceData/Calendar/Exams/calendarExamCourse.cpp @@ -12,6 +12,19 @@ calendarExamCourse::calendarExamCourse(int serial, QString name, QString lecture setTime(firstHourbegin,true); setTime(secondHourbegin,false); +} + +calendarExamCourse::calendarExamCourse(calendarExamCourse &other) + :Course (other.getSerialNum(),other.getName(),other.getType()) +{ + this->lecturer = other.lecturer; + this->field = other.field; + this->firstDate = other.getFirstDate(); + this->firstHourbegin = other.firstHourbegin; + this->secondDate = other.secondDate; + this->secondHourbegin = other.secondHourbegin; + + } /** * @brief calendarExamCourse::setDate diff --git a/src/jceData/Calendar/Exams/calendarExamCourse.h b/src/jceData/Calendar/Exams/calendarExamCourse.h index 8cb3776..3512627 100644 --- a/src/jceData/Calendar/Exams/calendarExamCourse.h +++ b/src/jceData/Calendar/Exams/calendarExamCourse.h @@ -45,6 +45,7 @@ public: calendarExamCourse(int serial, QString name, QString lecturer, QString field, QString type, QString firstDate, QString firstHourbegin, QString secondDate, QString secondHourbegin); + calendarExamCourse(calendarExamCourse &other); QString getLecturer() const; diff --git a/src/jceData/Calendar/Exams/examDialog.cpp b/src/jceData/Calendar/Exams/examDialog.cpp index 2214363..c95cbbe 100644 --- a/src/jceData/Calendar/Exams/examDialog.cpp +++ b/src/jceData/Calendar/Exams/examDialog.cpp @@ -1,18 +1,17 @@ #include "examDialog.h" #include "ui_examDialog.h" -/* - *TODO: exam revert, add to csv exportation, dialog size - */ /** * @brief examDialog::examDialog * @param parent * @param calSchedPtr - list of courses with information about each exam */ -examDialog::examDialog(QWidget *parent, calendarExam *calSchedPtr) : QDialog(parent), +examDialog::examDialog(QWidget *parent, calendarExam *calExamPtr) : QDialog(parent), ui(new Ui::examDialog) { ui->setupUi(this); - exams = calSchedPtr; + exams = calExamPtr; + this->examsCpy = NULL; + QStringList headLine; //SERIAL, NAME, LECTURER, FIELD, TYPE, FIRST_DATE, FIRST_HOUR_BEGIN, SECOND_DATE, SECOND_HOUR_BEGIN @@ -42,6 +41,8 @@ void examDialog::initializingDataIntoTable() { disconnect(ui->tableWidget,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(upgradeExamsTime(QTableWidgetItem*))); ui->tableWidget->setRowCount(exams->getExamsCounter()); + this->examsCpy = new calendarExam(*exams); + int i=0,j=0; int year,month,day; //for constructin qdate by setdate QTableWidgetItem *lecturer,*name,*type; @@ -180,11 +181,65 @@ void examDialog::resetGeo() mHeight += ui->tableWidget->rowHeight(i) + 4; } - mHeight += ui->buttonBox->height() + 4; + mHeight += ui->frameBtns->height() + 30; mHeight += ui->labelHeader->height() + 4; this->setMinimumHeight(mHeight); -// this->setMaximumHeight(mHeight); } + +void examDialog::on_pushButtonOk_clicked() +{ + qDebug() << Q_FUNC_INFO; + this->hide(); +} + +void examDialog::on_pushButtonRevert_clicked() +{ + qDebug() << Q_FUNC_INFO; + + if (ui->tableWidget->rowCount() <= 0) + return; + if (this->exams == NULL) + return; + if (this->examsCpy == NULL) + return; + for (int i = 0; i < ui->tableWidget->rowCount(); ++i) + { + calendarExamCourse * temp = getExamByRow(i); + for (calendarExamCourse * notChangedCourse: examsCpy->getExams()) + { + if (temp->getSerialNum() == notChangedCourse->getSerialNum()) + { + if (temp->getFirstHourbegin() != notChangedCourse->getFirstHourbegin()) + { + ui->tableWidget->item(i,calendarExamCourse::CourseScheme::FIRST_HOUR_BEGIN)->setData(Qt::EditRole, QTime(notChangedCourse->getFirstHourbegin().hour(),notChangedCourse->getFirstHourbegin().minute()).toString("hh:mm")); + } + if (temp->getSecondHourbegin() != notChangedCourse->getSecondHourbegin()) + { + ui->tableWidget->item(i,calendarExamCourse::CourseScheme::SECOND_HOUR_BEGIN)->setData(Qt::EditRole, QTime(notChangedCourse->getSecondHourbegin().hour(),notChangedCourse->getSecondHourbegin().minute()).toString("hh:mm")); + } + break; //done with course. go to next row + } + } + } + +} + +calendarExamCourse *examDialog::getExamByRow(int row) +{ + int serialNum = ui->tableWidget->item(row,calendarExamCourse::CourseScheme::SERIAL)->text().toInt(); + for (calendarExamCourse * temp : exams->getExams()) + { + if (serialNum == temp->getSerialNum()) + return temp; + } + return NULL; +} + +void examDialog::on_pushButtonCancel_clicked() +{ + on_pushButtonRevert_clicked(); //make revert to discard all changes + this->hide(); +} diff --git a/src/jceData/Calendar/Exams/examDialog.h b/src/jceData/Calendar/Exams/examDialog.h index 04bc9d3..cf1160a 100644 --- a/src/jceData/Calendar/Exams/examDialog.h +++ b/src/jceData/Calendar/Exams/examDialog.h @@ -27,7 +27,7 @@ class examDialog : public QDialog Q_OBJECT public: - explicit examDialog(QWidget *parent,calendarExam * calSchedPtr); + explicit examDialog(QWidget *parent, calendarExam * calExamPtr); void initializingDataIntoTable(); ~examDialog(); @@ -35,12 +35,20 @@ private slots: bool upgradeExamsTime(QTableWidgetItem* item); + void on_pushButtonOk_clicked(); + + void on_pushButtonRevert_clicked(); + + void on_pushButtonCancel_clicked(); + private: + calendarExamCourse *getExamByRow(int row); void resetGeo(); Ui::examDialog *ui; calendarExam * exams; + calendarExam * examsCpy; }; #endif // EXAMDIALOG_H diff --git a/src/jceData/Calendar/Exams/examDialog.ui b/src/jceData/Calendar/Exams/examDialog.ui index 53829eb..981b1c8 100644 --- a/src/jceData/Calendar/Exams/examDialog.ui +++ b/src/jceData/Calendar/Exams/examDialog.ui @@ -19,81 +19,119 @@ Dialog - + - - - - 0 - 0 - + + + #frameAll { + border: 0px solids; +} - - <html><head/><body><p align="center"><span style=" font-size:14pt;">Exams Schedule</span></p></body></html> + + QFrame::StyledPanel - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + QFrame::Raised + + + + + #frameBtns { + border: 0px solids; +} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + + + + + <html><head/><body><p>Revert changes</p></body></html> + + + Revert + + + + + + + <html><head/><body><p>Discard and hide</p></body></html> + + + Cancel + + + + + + + <html><head/><body><p>Save and hide</p></body></html> + + + Ok + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + pushButtonRevert + + horizontalSpacer + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + <html><head/><body><p align="center"><span style=" font-size:14pt;">Exams Schedule</span></p></body></html> + + + + - - - buttonBox - accepted() - examDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - examDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - +