diff --git a/jceGrade.pro b/jceGrade.pro index 280d5b2..4ba14b3 100644 --- a/jceGrade.pro +++ b/jceGrade.pro @@ -25,8 +25,9 @@ TRANSLATIONS = jce_en.ts \ FORMS += \ main/mainscreen.ui \ - src/jceData/Calendar/calendarDialog.ui \ - src/jceData/Grades/graph/gradegraph.ui + src/jceData/Grades/graph/gradegraph.ui \ + src/jceData/Calendar/Exams/examDialog.ui \ + src/jceData/Calendar/coursesSchedule/calendarDialog.ui RESOURCES += \ resources/connectionstatus.qrc @@ -38,7 +39,6 @@ HEADERS += \ main/mainscreen.h \ src/appDatabase/savedata.h \ src/jceConnection/jcesslclient.h \ - src/jceData/Calendar/calendarPage.h \ src/jceData/Grades/gradeCourse.h \ src/jceData/Grades/gradePage.h \ src/jceData/course.h \ @@ -46,15 +46,19 @@ HEADERS += \ src/jceSettings/jcelogin.h \ src/jceSettings/jceLoginHtmlScripts.h \ src/jceSettings/user.h \ - src/jceData/Calendar/calendarCourse.h \ - src/jceData/Calendar/calendarSchedule.h \ src/jceData/CSV/csv_exporter.h \ src/appDatabase/simplecrypt.h \ - src/jceData/Calendar/calendarDialog.h \ src/appDatabase/jce_logger.h \ src/jceData/Grades/graph/qcustomplot.h \ src/jceData/Grades/graph/gradegraph.h \ - src/jceData/Calendar/calendarExam.h + src/jceData/Calendar/calendarPageCourse.h \ + src/jceData/Calendar/Exams/examDialog.h \ + src/jceData/Calendar/Exams/calendarExam.h \ + src/jceData/Calendar/Exams/calendarExamCourse.h \ + src/jceData/Calendar/coursesSchedule/calendarDialog.h \ + src/jceData/Calendar/coursesSchedule/calendarPage.h \ + src/jceData/Calendar/coursesSchedule/calendarPageCourse.h \ + src/jceData/Calendar/coursesSchedule/calendarSchedule.h SOURCES += \ main/CalendarTab/CalendarManager.cpp \ @@ -64,18 +68,20 @@ SOURCES += \ main/mainscreen.cpp \ src/appDatabase/savedata.cpp \ src/jceConnection/jcesslclient.cpp \ - src/jceData/Calendar/calendarPage.cpp \ src/jceData/Grades/gradeCourse.cpp \ src/jceData/Grades/gradePage.cpp \ src/jceData/page.cpp \ src/jceSettings/jcelogin.cpp \ src/jceSettings/user.cpp \ - src/jceData/Calendar/calendarCourse.cpp \ - src/jceData/Calendar/calendarSchedule.cpp \ src/jceData/CSV/csv_exporter.cpp \ src/appDatabase/simplecrypt.cpp \ - src/jceData/Calendar/calendarDialog.cpp \ src/appDatabase/jce_logger.cpp \ src/jceData/Grades/graph/qcustomplot.cpp \ src/jceData/Grades/graph/gradegraph.cpp \ - src/jceData/Calendar/calendarExam.cpp + src/jceData/Calendar/Exams/examDialog.cpp \ + src/jceData/Calendar/Exams/calendarExam.cpp \ + src/jceData/Calendar/Exams/calendarExamCourse.cpp \ + src/jceData/Calendar/coursesSchedule/calendarDialog.cpp \ + src/jceData/Calendar/coursesSchedule/calendarPage.cpp \ + src/jceData/Calendar/coursesSchedule/calendarPageCourse.cpp \ + src/jceData/Calendar/coursesSchedule/calendarSchedule.cpp diff --git a/main/CalendarTab/CalendarManager.cpp b/main/CalendarTab/CalendarManager.cpp index d6c5041..ac408a3 100644 --- a/main/CalendarTab/CalendarManager.cpp +++ b/main/CalendarTab/CalendarManager.cpp @@ -1,15 +1,25 @@ #include "CalendarManager.h" -CalendarManager::CalendarManager(QGridLayout *ptr) +CalendarManager::CalendarManager(QWidget *parent, QGridLayout *ptr) : QWidget(parent) { - caliSchedPtr = new calendarSchedule(); + caliSchedPtr = new calendarSchedule(this); + examSchePtr = new calendarExam(); ptr->addWidget(caliSchedPtr); - caliDialog = new CalendarDialog(); + caliDialog = new CalendarDialog(this); + examDialogPtr = new examDialog(this,examSchePtr); } void CalendarManager::setCalendar(QString html) { caliSchedPtr->setPage(html); + +} + +void CalendarManager::setExamsSchedule(QString html) +{ + examSchePtr->setPage(html); + examDialogPtr->initializingDataIntoTable(); + examDialogPtr->show(); } void CalendarManager::exportCalendarCSV() //need to add fix to the null pointer bug { diff --git a/main/CalendarTab/CalendarManager.h b/main/CalendarTab/CalendarManager.h index a0ce3b1..182a527 100644 --- a/main/CalendarTab/CalendarManager.h +++ b/main/CalendarTab/CalendarManager.h @@ -1,21 +1,25 @@ #ifndef CALENDARMANAGER_H #define CALENDARMANAGER_H -#include "./src/jceData/Calendar/calendarPage.h" -#include "./src/jceData/Calendar/calendarSchedule.h" +#include "./src/jceData/Calendar/coursesSchedule/calendarPage.h" +#include "./src/jceData/Calendar/coursesSchedule/calendarSchedule.h" +#include "./src/jceData/Calendar/coursesSchedule/calendarDialog.h" #include "./src/jceData/CSV/csv_exporter.h" -#include "./src/jceData/Calendar/calendarDialog.h" + +#include "./src/jceData/Calendar/Exams/calendarExam.h" +#include "./src/jceData/Calendar/Exams/examDialog.h" #include +#include #include #include -class CalendarManager : public QObject +class CalendarManager : public QWidget { Q_OBJECT public: - CalendarManager(QGridLayout *ptr); + CalendarManager(QWidget *parent = 0, QGridLayout *ptr = 0); ~CalendarManager() { delete caliSchedPtr; @@ -23,9 +27,15 @@ public: } void exportCalendarCSV(); void setCalendar(QString html); + void setExamsSchedule(QString html); + void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); } private: + calendarExam * examSchePtr; + examDialog * examDialogPtr; + + calendarSchedule * caliSchedPtr; CalendarDialog * caliDialog; diff --git a/main/LoginTab/loginhandler.cpp b/main/LoginTab/loginhandler.cpp index 68061d5..c0c70e5 100644 --- a/main/LoginTab/loginhandler.cpp +++ b/main/LoginTab/loginhandler.cpp @@ -146,6 +146,14 @@ int loginHandler::makeCalendarRequest(int year, int semester) else return jceLogin::JCE_NOT_CONNECTED; } + +int loginHandler::makeExamsScheduleRequest(int year, int semester) +{ + if (isLoggedInFlag()) + return jceLog->getExams(year,semester); + else + return jceLogin::JCE_NOT_CONNECTED; +} void loginHandler::setIconConnectionStatus(jceLogin::jceStatus statusDescription) { QPixmap iconPix; diff --git a/main/LoginTab/loginhandler.h b/main/LoginTab/loginhandler.h index 8512ec1..5b7d154 100644 --- a/main/LoginTab/loginhandler.h +++ b/main/LoginTab/loginhandler.h @@ -37,6 +37,7 @@ public: int makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester); int makeCalendarRequest(int year,int semester); + int makeExamsScheduleRequest(int year, int semester); private slots: void readyAfterConnectionLost(); diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index e32ddc3..96e7988 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -31,7 +31,7 @@ MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainSc this->userLoginSetting = new user("",""); this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting); this->loginHandel = new loginHandler(userLoginSetting,ui->statusBar,ui->loginButton,ui->progressBar); - this->calendar = new CalendarManager(ui->calendarGridLayoutMain); + this->calendar = new CalendarManager(this,ui->calendarGridLayoutMain); this->data = new SaveData(); //check login File @@ -247,12 +247,42 @@ void MainScreen::on_graphButton_clicked() //EVENTS ON CALENDAR TAB +void MainScreen::on_examsBtn_clicked() +{ + ui->progressBar->setValue(0); + qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); + int status = 0; + QString page; + QApplication::setOverrideCursor(Qt::WaitCursor); + if (loginHandel->isLoggedInFlag()) + { + ui->statusBar->showMessage(tr("Getting exams...")); + if ((status = loginHandel->makeExamsScheduleRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED) + { + ui->statusBar->showMessage(tr("Done."),1000); + page = loginHandel->getCurrentPageContect(); + calendar->setExamsSchedule(page); + ui->progressBar->setValue(100); + qDebug() << Q_FUNC_INFO << "exams schedule is loaded"; + ui->statusBar->showMessage(tr("Done")); + } + else if (status == jceLogin::JCE_NOT_CONNECTED) + { + qWarning() << Q_FUNC_INFO << "not connected"; + QApplication::restoreOverrideCursor(); + QMessageBox::critical(this,tr("Error"),tr("Not Connected")); + } + else + qCritical() << Q_FUNC_INFO << "exams request get ended with" << status; + } + QApplication::restoreOverrideCursor(); +} void MainScreen::on_getCalendarBtn_clicked() { ui->progressBar->setValue(0); qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); int status = 0; - QString page; + QString page; QApplication::setOverrideCursor(Qt::WaitCursor); if (loginHandel->isLoggedInFlag()) { @@ -404,3 +434,5 @@ void MainScreen::on_progressBar_valueChanged(int value) else ui->progressBar->setVisible(true); } + + diff --git a/main/mainscreen.h b/main/mainscreen.h index 62da771..3f9a7f9 100644 --- a/main/mainscreen.h +++ b/main/mainscreen.h @@ -71,6 +71,8 @@ private slots: void on_progressBar_valueChanged(int value); + void on_examsBtn_clicked(); + private: void checkLocale(); diff --git a/main/mainscreen.ui b/main/mainscreen.ui index 4f6482c..be6b6ae 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -64,7 +64,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r QTabWidget::Rounded - 0 + 2 false @@ -606,6 +606,13 @@ font-size: 15px; + + + + Show Exams + + + @@ -690,7 +697,7 @@ background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop: 0 0 1133 - 23 + 22 diff --git a/src/jceData/CSV/csv_exporter.h b/src/jceData/CSV/csv_exporter.h index 52d8dc8..d83ddac 100644 --- a/src/jceData/CSV/csv_exporter.h +++ b/src/jceData/CSV/csv_exporter.h @@ -16,8 +16,8 @@ #include #include -#include "../Calendar/calendarSchedule.h" -#include "../Calendar/calendarDialog.h" +#include "../Calendar/coursesSchedule/calendarSchedule.h" +#include "../Calendar/coursesSchedule/calendarDialog.h" #define CSV_CALENDAR_HEADER "Subject,Start Date,Start Time,End Date,End Time,Description,Location" diff --git a/src/jceData/Calendar/Exams/calendarExam.cpp b/src/jceData/Calendar/Exams/calendarExam.cpp new file mode 100644 index 0000000..70141b1 --- /dev/null +++ b/src/jceData/Calendar/Exams/calendarExam.cpp @@ -0,0 +1,116 @@ +#include "calendarExam.h" + +calendarExam::calendarExam() +{ + exams = NULL; + htmlDataHolderParsed = ""; +} + +/** + * @brief calendarExam::setPage - getting a html page and stripping it into a exams schedule in a list + * @param html - html page with tags + */ +void calendarExam::setPage(QString html) +{ + examsCounter = 0; + if (exams == NULL) + exams = new QList(); + else + exams->clear(); + this->htmlDataHolderParsed = getString(html); + examListInit(htmlDataHolderParsed); +} + +/** + * @brief calendarExam::examListInit spliting the stripped html into lines, and using linetocourse function to make it an object + * @param linesTokinzedString - list of lines, each line has differen exam information + */ +void calendarExam::examListInit(QString &linesTokinzedString) +{ + QString tempToken; + + QStringList holder = linesTokinzedString.split("\n"); + QStringList::iterator iterator; + for (iterator = holder.begin(); iterator != holder.end(); ++iterator) + { + tempToken = (*iterator); + if (!tempToken.isEmpty()) + { + calendarExamCourse *cTemp = lineToCourse(tempToken); + if (cTemp != NULL) + this->exams->push_back(cTemp); + } + } +} + +/** + * @brief calendarExam::lineToCourse getting line of exam with data and make it an object containing data (date, time, course name and etc) + * @param line + * @return + */ +calendarExamCourse *calendarExam::lineToCourse(QString line) +{ + calendarExamCourse *tempC = NULL; + QString templinearray[EXAM_SCHEDULE_FIELDS]; + //SERIAL, NAME, LECTURER, FIELD, TYPE, FIRST_DATE, FIRST_HOUR_BEGIN, SECOND_DATE, SECOND_HOUR_BEGIN + + int serial; + QString name, lecturer, field, type, firstDate, firstHourbegin, secondDate, secondHourbegin; + + QString tempToken; + int i = 0; + QStringList holder = line.split("\t"); + QStringList::iterator iterator; + for (iterator = holder.begin(); iterator != holder.end(); ++iterator) + { + + tempToken = (*iterator); + templinearray[i] = tempToken.trimmed(); + i++; + if (i >= EXAM_SCHEDULE_FIELDS) + break; + } + + if (templinearray[0] == "") //empty parsing + return NULL; + + + serial = templinearray[calendarExamCourse::ExamScheme::SERIAL].toInt(); + name = templinearray[calendarExamCourse::ExamScheme::NAME]; + + lecturer = templinearray[calendarExamCourse::ExamScheme::LECTURER]; + if (lecturer.isEmpty()) + lecturer = LECTURER_DEFAULT_STRING; + + field = templinearray[calendarExamCourse::ExamScheme::FIELD]; + type = templinearray[calendarExamCourse::ExamScheme::TYPE]; + + firstDate = templinearray[calendarExamCourse::ExamScheme::FIRST_DATE]; + if (firstDate.isEmpty()) + return NULL; //can't set a default date to an exam. must be an error + + firstHourbegin = templinearray[calendarExamCourse::ExamScheme::FIRST_HOUR_BEGIN]; + if (firstHourbegin.isEmpty()) + firstHourbegin = HOUR_DEFAULT_STRING; + secondDate = templinearray[calendarExamCourse::ExamScheme::SECOND_DATE]; + if (secondDate.isEmpty()) + { + secondDate = SECOND_DATE_DEFAULT_STRING; + secondHourbegin = HOUR_DEFAULT_STRING; + } + else + { + secondHourbegin = templinearray[calendarExamCourse::ExamScheme::SECOND_HOUR_BEGIN]; + if (secondHourbegin.isEmpty()) + secondHourbegin = HOUR_DEFAULT_STRING; + } + + tempC = new calendarExamCourse(serial,name,lecturer,field,type,firstDate,firstHourbegin,secondDate,secondHourbegin); + examsCounter++; + return tempC; +} +int calendarExam::getExamsCounter() const +{ + return examsCounter; +} + diff --git a/src/jceData/Calendar/Exams/calendarExam.h b/src/jceData/Calendar/Exams/calendarExam.h new file mode 100644 index 0000000..20f5a3f --- /dev/null +++ b/src/jceData/Calendar/Exams/calendarExam.h @@ -0,0 +1,34 @@ +#ifndef CALENDAREXAM_H +#define CALENDAREXAM_H + +#include "../../page.h" +#include "calendarExamCourse.h" + +#include +#include +#include + + +class calendarExam : public Page +{ +public: + calendarExam(); + void setPage(QString html); + + QList* getExams() { return exams; } + int getExamsCounter() const; + + + +private: + + void examListInit(QString &linesTokinzedString); + calendarExamCourse * lineToCourse(QString line); + + QString htmlDataHolderParsed; + QList *exams; + + int examsCounter; //not including madei b +}; + +#endif // CALENDAREXAM_H diff --git a/src/jceData/Calendar/Exams/calendarExamCourse.cpp b/src/jceData/Calendar/Exams/calendarExamCourse.cpp new file mode 100644 index 0000000..7e9859b --- /dev/null +++ b/src/jceData/Calendar/Exams/calendarExamCourse.cpp @@ -0,0 +1,100 @@ +#include "calendarExamCourse.h" + + +calendarExamCourse::calendarExamCourse(int serial, QString name, QString lecturer, QString field, + QString type, QString firstDate, QString firstHourbegin, + QString secondDate, QString secondHourbegin) : Course (serial,name,type) +{ + this->lecturer = lecturer; + this->field = field; + setDate(firstDate,true); + setDate(secondDate,false); + setTime(firstHourbegin,true); + setTime(secondHourbegin,false); + +} +/** + * @brief calendarExamCourse::setDate + * @param date + * @param isFirst if true > first. otherwise > second + */ +void calendarExamCourse::setDate(QString date, bool isFirst) +{ + if (isFirst) + this->firstDate = QDate::fromString(date,"dd/MM/yyyy"); + else + this->secondDate = QDate::fromString(date,"dd/MM/yyyy"); +} +/** + * @brief calendarExamCourse::setTime + * @param time + * @param isFirst if true > first. otherwise > second + */ +void calendarExamCourse::setTime(QString time, bool isFirst) +{ +// qDebug() << "time string is: " << time; + if (isFirst) + this->firstHourbegin = QTime::fromString(time,"hh:mm"); + else + this->secondHourbegin = QTime::fromString(time,"hh:mm"); +} +QTime calendarExamCourse::getSecondHourbegin() const +{ + return secondHourbegin; +} + +void calendarExamCourse::setSecondHourbegin(const QTime &value) +{ + secondHourbegin = value; +} + +QDate calendarExamCourse::getSecondDate() const +{ + return secondDate; +} + +void calendarExamCourse::setSecondDate(const QDate &value) +{ + secondDate = value; +} + +QTime calendarExamCourse::getFirstHourbegin() const +{ + return firstHourbegin; +} + +void calendarExamCourse::setFirstHourbegin(const QTime &value) +{ + firstHourbegin = value; +} + +QDate calendarExamCourse::getFirstDate() const +{ + return firstDate; +} + +void calendarExamCourse::setFirstDate(const QDate &value) +{ + firstDate = value; +} + +QString calendarExamCourse::getField() const +{ + return field; +} + +void calendarExamCourse::setField(const QString &value) +{ + field = value; +} + +QString calendarExamCourse::getLecturer() const +{ + return lecturer; +} + +void calendarExamCourse::setLecturer(const QString &value) +{ + lecturer = value; +} + diff --git a/src/jceData/Calendar/Exams/calendarExamCourse.h b/src/jceData/Calendar/Exams/calendarExamCourse.h new file mode 100644 index 0000000..4127074 --- /dev/null +++ b/src/jceData/Calendar/Exams/calendarExamCourse.h @@ -0,0 +1,70 @@ +#ifndef CALENDAREXAMCOURSE_H +#define CALENDAREXAMCOURSE_H + +#include "../../course.h" + +#include +#include +#include + +#define EXAM_SCHEDULE_FIELDS 9 + +#define LECTURER_DEFAULT_STRING "nullLecturer" +#define HOUR_DEFAULT_STRING "00:00" +#define SECOND_DATE_DEFAULT_STRING "nullSECOND_DATE" + +class calendarExamCourse : public Course +{ + +public: + + enum ExamScheme + { + SERIAL, + NAME, + LECTURER, + FIELD, + TYPE, + FIRST_DATE, + FIRST_HOUR_BEGIN, + SECOND_DATE, + SECOND_HOUR_BEGIN + }; + + calendarExamCourse(int serial, QString name, QString lecturer, QString field, + QString type, QString firstDate, QString firstHourbegin, + QString secondDate, QString secondHourbegin); + + + QString getLecturer() const; + void setLecturer(const QString &value); + + QString getField() const; + void setField(const QString &value); + + QDate getFirstDate() const; + void setFirstDate(const QDate &value); + + QTime getFirstHourbegin() const; + void setFirstHourbegin(const QTime &value); + + QDate getSecondDate() const; + void setSecondDate(const QDate &value); + + QTime getSecondHourbegin() const; + void setSecondHourbegin(const QTime &value); + +private: + + void setDate(QString date, bool isFirst); //isFirst = true > first. otherwise > second + void setTime(QString time, bool isFirst); //isFirst = true > first. otherwise > second + + QString lecturer; + QString field; + QDate firstDate; + QTime firstHourbegin; + QDate secondDate; + QTime secondHourbegin; +}; + +#endif // CALENDAREXAMCOURSE_H diff --git a/src/jceData/Calendar/Exams/examDialog.cpp b/src/jceData/Calendar/Exams/examDialog.cpp new file mode 100644 index 0000000..eb7d076 --- /dev/null +++ b/src/jceData/Calendar/Exams/examDialog.cpp @@ -0,0 +1,74 @@ +#include "examDialog.h" +#include "ui_examDialog.h" + +examDialog::examDialog(QWidget *parent, calendarExam *calSchedPtr) : QDialog(parent), + ui(new Ui::examDialog) +{ + ui->setupUi(this); + exams = calSchedPtr; + QStringList headLine; + //SERIAL, NAME, LECTURER, FIELD, TYPE, FIRST_DATE, FIRST_HOUR_BEGIN, SECOND_DATE, SECOND_HOUR_BEGIN + + headLine << tr("Serial") << tr("Course") << tr("Lecturer") << tr("Field") << tr("Type") << tr("First") << tr("Begin") << tr("Second") << tr("Begin"); + + ui->tableWidget->setColumnCount(EXAM_SCHEDULE_FIELDS); + ui->tableWidget->setHorizontalHeaderLabels(headLine); + ui->tableWidget->setLayoutDirection(Qt::LayoutDirection::RightToLeft); + + this->setModal(true); +} + +void examDialog::initializingDataIntoTable() +{ + ui->tableWidget->setRowCount(exams->getExamsCounter()); + int i=0,j=0; + QTableWidgetItem *lecturer,*name,*type; + QTableWidgetItem *serial; + QTableWidgetItem *field; + QDateEdit *firstDate; + QTimeEdit *firstHourbegin; + QDateEdit *secondDate; + QTimeEdit *secondHourbegin; + + for (calendarExamCourse * tempExam: *exams->getExams()) + { + j=0; + lecturer = new QTableWidgetItem(); + lecturer->setData(Qt::EditRole, tempExam->getLecturer()); + name = new QTableWidgetItem(); + name->setData(Qt::EditRole, tempExam->getName()); + type = new QTableWidgetItem(); + type->setData(Qt::EditRole, tempExam->getType()); + serial = new QTableWidgetItem(); + serial->setData(Qt::EditRole, tempExam->getSerialNum()); + field = new QTableWidgetItem(); + field->setData(Qt::EditRole, tempExam->getField()); + firstDate = new QDateEdit(); + firstDate->setDate(tempExam->getFirstDate()); + secondDate = new QDateEdit(); + secondDate->setDate(tempExam->getSecondDate()); + firstHourbegin = new QTimeEdit(); + firstHourbegin->setTime(tempExam->getFirstHourbegin()); + secondHourbegin = new QTimeEdit(); + secondHourbegin->setTime(tempExam->getSecondHourbegin()); + + ui->tableWidget->setItem(i,j++,lecturer); + ui->tableWidget->setItem(i,j++,name); + ui->tableWidget->setItem(i,j++,type); + ui->tableWidget->setItem(i,j++,serial); + ui->tableWidget->setItem(i,j++,field); + ui->tableWidget->setCellWidget(i,j++,firstDate); + ui->tableWidget->setCellWidget(i,j++,firstHourbegin); + ui->tableWidget->setCellWidget(i,j++,secondDate); + ui->tableWidget->setCellWidget(i,j++,secondHourbegin); + i++; + } + ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + + +} +examDialog::~examDialog() +{ + delete ui; +} diff --git a/src/jceData/Calendar/Exams/examDialog.h b/src/jceData/Calendar/Exams/examDialog.h new file mode 100644 index 0000000..43d4341 --- /dev/null +++ b/src/jceData/Calendar/Exams/examDialog.h @@ -0,0 +1,27 @@ +#ifndef EXAMDIALOG_H +#define EXAMDIALOG_H + +#include +#include + +#include "calendarExam.h" + +namespace Ui { +class examDialog; +} + +class examDialog : public QDialog +{ + Q_OBJECT + +public: + explicit examDialog(QWidget *parent,calendarExam * calSchedPtr); + void initializingDataIntoTable(); + ~examDialog(); + +private: + Ui::examDialog *ui; + calendarExam * exams; +}; + +#endif // EXAMDIALOG_H diff --git a/src/jceData/Calendar/Exams/examDialog.ui b/src/jceData/Calendar/Exams/examDialog.ui new file mode 100644 index 0000000..06fe26e --- /dev/null +++ b/src/jceData/Calendar/Exams/examDialog.ui @@ -0,0 +1,86 @@ + + + examDialog + + + + 0 + 0 + 810 + 257 + + + + Dialog + + + + + + + 0 + 0 + + + + <html><head/><body><p align="center"><span style=" font-size:14pt;">Exams Schedule</span></p></body></html> + + + + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + examDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + examDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/jceData/Calendar/calendarExam.cpp b/src/jceData/Calendar/calendarExam.cpp deleted file mode 100644 index dfbf567..0000000 --- a/src/jceData/Calendar/calendarExam.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "calendarExam.h" - -calendarExam::calendarExam() -{ -} diff --git a/src/jceData/Calendar/calendarExam.h b/src/jceData/Calendar/calendarExam.h deleted file mode 100644 index 9a8640d..0000000 --- a/src/jceData/Calendar/calendarExam.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CALENDAREXAM_H -#define CALENDAREXAM_H - -#include "../page.h" - -class calendarExam : public Page -{ -public: - calendarExam(); -}; - -#endif // CALENDAREXAM_H diff --git a/src/jceData/Calendar/calendarDialog.cpp b/src/jceData/Calendar/coursesSchedule/calendarDialog.cpp similarity index 100% rename from src/jceData/Calendar/calendarDialog.cpp rename to src/jceData/Calendar/coursesSchedule/calendarDialog.cpp diff --git a/src/jceData/Calendar/calendarDialog.h b/src/jceData/Calendar/coursesSchedule/calendarDialog.h similarity index 100% rename from src/jceData/Calendar/calendarDialog.h rename to src/jceData/Calendar/coursesSchedule/calendarDialog.h diff --git a/src/jceData/Calendar/calendarDialog.ui b/src/jceData/Calendar/coursesSchedule/calendarDialog.ui similarity index 100% rename from src/jceData/Calendar/calendarDialog.ui rename to src/jceData/Calendar/coursesSchedule/calendarDialog.ui diff --git a/src/jceData/Calendar/calendarPage.cpp b/src/jceData/Calendar/coursesSchedule/calendarPage.cpp similarity index 83% rename from src/jceData/Calendar/calendarPage.cpp rename to src/jceData/Calendar/coursesSchedule/calendarPage.cpp index 0a68e38..8aafa4c 100644 --- a/src/jceData/Calendar/calendarPage.cpp +++ b/src/jceData/Calendar/coursesSchedule/calendarPage.cpp @@ -1,10 +1,9 @@ #include "calendarPage.h" -QString CalendarPage::htmlToString() -{ - return tempHtml; -} - +/** + * @brief CalendarPage::setPage getting the html and stripping it into a courses schedule in a list + * @param html + */ void CalendarPage::setPage(QString html) { @@ -13,7 +12,10 @@ void CalendarPage::setPage(QString html) calendarListInit(tempHtml); } - +/** + * @brief CalendarPage::calendarListInit - make an object from each line of course + * @param linesTokinzedString - string contain lines of coureses. each string contain single course information + */ void CalendarPage::calendarListInit(QString &linesTokinzedString) { std::list stringHolder; @@ -36,6 +38,11 @@ void CalendarPage::calendarListInit(QString &linesTokinzedString) } } +/** + * @brief CalendarPage::lineToCourse + * @param line - line of course contain its data and information + * @return calendarcourse object with its information + */ calendarCourse *CalendarPage::lineToCourse(QString line) { diff --git a/src/jceData/Calendar/calendarPage.h b/src/jceData/Calendar/coursesSchedule/calendarPage.h similarity index 76% rename from src/jceData/Calendar/calendarPage.h rename to src/jceData/Calendar/coursesSchedule/calendarPage.h index d4935bd..b4b9077 100644 --- a/src/jceData/Calendar/calendarPage.h +++ b/src/jceData/Calendar/coursesSchedule/calendarPage.h @@ -1,8 +1,8 @@ #ifndef CALENDARPAGE_H #define CALENDARPAGE_H -#include "../page.h" -#include "calendarCourse.h" +#include "../../page.h" +#include "calendarPageCourse.h" #include #define ROOM_DEFAULT_STRING "nullRoom" @@ -12,18 +12,19 @@ class CalendarPage : public Page { public: - QString htmlToString(); std::list* getCourses() { return courses; } protected: + virtual void setPage(QString html); CalendarPage() { courses = NULL; } private: + void calendarListInit(QString &linesTokinzedString); - calendarCourse* lineToCourse(QString line); + calendarCourse * lineToCourse(QString line); QString tempHtml; std::list* courses; diff --git a/src/jceData/Calendar/calendarCourse.cpp b/src/jceData/Calendar/coursesSchedule/calendarPageCourse.cpp similarity index 68% rename from src/jceData/Calendar/calendarCourse.cpp rename to src/jceData/Calendar/coursesSchedule/calendarPageCourse.cpp index 129a46f..a97fbe0 100644 --- a/src/jceData/Calendar/calendarCourse.cpp +++ b/src/jceData/Calendar/coursesSchedule/calendarPageCourse.cpp @@ -1,23 +1,22 @@ -#include "calendarCourse.h" +#include "calendarPageCourse.h" calendarCourse::calendarCourse(int serial, QString name, QString type, QString lecturer, double points, double semesterHours, QString dayAndHour, - QString room, calendarCourse::CourseCalendarType courseType) : Course(serial,name, type,points) + QString room) : Course(serial,name, type) { + this->points = points; this->lecturer = lecturer; this->semesterHours = semesterHours; this->room = room; - setDayAndHour(dayAndHour,courseType); + setDayAndHour(dayAndHour); } /** * @brief calendarCourse::setDayAndHour * given a string of time and day - parsing it into day, hour it begins and hour it ends seperated * @param parse - */ -void calendarCourse::setDayAndHour(QString parse, calendarCourse::CourseCalendarType courseType) +void calendarCourse::setDayAndHour(QString parse) { - if (courseType == calendarCourse::CourseCalendarType::CoursesSchedule) - { int ctr = 0; QString temp = ""; QTime timetemp; @@ -47,11 +46,6 @@ void calendarCourse::setDayAndHour(QString parse, calendarCourse::CourseCalendar ctr++; tok = strtok(NULL, " -"); } - } - if (courseType == calendarCourse::CourseCalendarType::ExamSchedule) - { - - } } QString calendarCourse::getLecturer() const @@ -108,26 +102,6 @@ void calendarCourse::setMinutesEnd(int value) { minutesEnd = value; } -/** - * @brief calendarCourse::courseToString - * @return prints the course into string pattern - */ -QString calendarCourse::courseToString() -{ - QString courseText = ""; - courseText += " " + QString::number(this->getSerialNum()); - courseText += " " + this->getName(); - courseText += " " + this->getType(); - courseText += " " + this->lecturer; - courseText += " " + QString::number(this->getPoints()); - courseText += " " + QString::number(this->semesterHours); - courseText += " " + QString::number(this->day); - courseText += " " + QString::number(this->hourBegin) + ":" + QString::number(this->minutesBegin) + "-" + QString::number(this->hourEnd) + ":" + QString::number(this->minutesEnd); - courseText += " " + this->room; - courseText += "\n"; - return courseText; - -} int calendarCourse::getDay() const { return day; @@ -171,3 +145,13 @@ void calendarCourse::setRoom(const QString &value) + +double calendarCourse::getPoints() const +{ + return points; +} + +void calendarCourse::setPoints(double value) +{ + points = value; +} diff --git a/src/jceData/Calendar/calendarCourse.h b/src/jceData/Calendar/coursesSchedule/calendarPageCourse.h similarity index 75% rename from src/jceData/Calendar/calendarCourse.h rename to src/jceData/Calendar/coursesSchedule/calendarPageCourse.h index 789d1b2..1a2929b 100644 --- a/src/jceData/Calendar/calendarCourse.h +++ b/src/jceData/Calendar/coursesSchedule/calendarPageCourse.h @@ -1,7 +1,7 @@ #ifndef CALENDARCOURSE_H #define CALENDARCOURSE_H -#include "../course.h" +#include "../../course.h" #include #define CALENDAR_COURSE_FIELDS 8 @@ -9,11 +9,6 @@ class calendarCourse : public Course { public: - enum CourseCalendarType - { - ExamSchedule, - CoursesSchedule - }; enum CourseScheme { @@ -26,9 +21,11 @@ public: DAY_AND_HOURS, ROOM }; + calendarCourse(int serial, QString name, QString type, QString lecturer, double points, double semesterHours, QString dayAndHour, - QString room, calendarCourse::CourseCalendarType courseType = calendarCourse::CourseCalendarType::CoursesSchedule); + QString room); + ~calendarCourse(){} int getDay() const; @@ -39,6 +36,7 @@ public: int getMinutesBegin() const; int getHourEnd() const; int getMinutesEnd() const; + double getPoints() const; void setDay(const QString &value); void setLecturer(const QString &value); @@ -48,14 +46,13 @@ public: void setMinutesBegin(int value); void setHourEnd(int value); void setMinutesEnd(int value); - - QString courseToString(); - + void setPoints(double value); private: - void setDayAndHour(QString parse, CourseCalendarType courseType); + void setDayAndHour(QString parse); + double points; QString lecturer; double semesterHours; int day; diff --git a/src/jceData/Calendar/calendarSchedule.cpp b/src/jceData/Calendar/coursesSchedule/calendarSchedule.cpp similarity index 93% rename from src/jceData/Calendar/calendarSchedule.cpp rename to src/jceData/Calendar/coursesSchedule/calendarSchedule.cpp index 06e1837..7850984 100644 --- a/src/jceData/Calendar/calendarSchedule.cpp +++ b/src/jceData/Calendar/coursesSchedule/calendarSchedule.cpp @@ -1,6 +1,6 @@ #include "calendarSchedule.h" -calendarSchedule::calendarSchedule() +calendarSchedule::calendarSchedule(QWidget *parent) : QTableWidget(parent) { QStringList days,hours; QTextStream hourString; @@ -22,7 +22,7 @@ calendarSchedule::calendarSchedule() days << QObject::tr("Sunday") << QObject::tr("Monday") << QObject::tr("Tuesday") << QObject::tr("Wednesday") << QObject::tr("Thursday") << QObject::tr("Friday"); setRowCount(endingHour - startingHour + 1); - setColumnCount(6); + setColumnCount(6); //number of days not including saturday ofcourse :) setLayoutDirection(Qt::LayoutDirection::RightToLeft);\ diff --git a/src/jceData/Calendar/calendarSchedule.h b/src/jceData/Calendar/coursesSchedule/calendarSchedule.h similarity index 87% rename from src/jceData/Calendar/calendarSchedule.h rename to src/jceData/Calendar/coursesSchedule/calendarSchedule.h index 14749cd..cf6f948 100644 --- a/src/jceData/Calendar/calendarSchedule.h +++ b/src/jceData/Calendar/coursesSchedule/calendarSchedule.h @@ -16,7 +16,7 @@ class calendarSchedule : public QTableWidget, public CalendarPage { Q_OBJECT public: - calendarSchedule(); + calendarSchedule(QWidget *parent = 0); ~calendarSchedule() { clearTableItems(); } void setPage(QString html); void clearTableItems(); diff --git a/src/jceData/Grades/gradeCourse.cpp b/src/jceData/Grades/gradeCourse.cpp index 16bca5b..2f9656f 100644 --- a/src/jceData/Grades/gradeCourse.cpp +++ b/src/jceData/Grades/gradeCourse.cpp @@ -1,7 +1,8 @@ #include "gradeCourse.h" -gradeCourse::gradeCourse(int year, int semester, int courseNumInList, int serial, QString name, QString type, double points,double hours, double grade, QString additions) : Course(serial,name,type,points) +gradeCourse::gradeCourse(int year, int semester, int courseNumInList, int serial, QString name, QString type, double points,double hours, double grade, QString additions) : Course(serial,name,type) { + this->points = points; this->hours = hours; this->grade = grade; this->additions = additions; @@ -56,4 +57,14 @@ void gradeCourse::setCourseNumInList(int value) { courseNumInList = value; } +double gradeCourse::getPoints() const +{ + return points; +} + +void gradeCourse::setPoints(double value) +{ + points = value; +} + diff --git a/src/jceData/Grades/gradeCourse.h b/src/jceData/Grades/gradeCourse.h index d62356a..bcdeff6 100644 --- a/src/jceData/Grades/gradeCourse.h +++ b/src/jceData/Grades/gradeCourse.h @@ -41,18 +41,20 @@ public: double getHours() const {return this->hours;} double getGrade() const; QString getAddidtions() const {return this->additions;} + int getCourseNumInList() const; + double getPoints() const; void setHours(double hours); void setGrade(double grade); void setAdditions(QString additions); void setYear(int year); void setSemester(int semester); - - int getCourseNumInList() const; void setCourseNumInList(int value); + void setPoints(double value); private: + double points; double hours; double grade; QString additions; diff --git a/src/jceData/Grades/graph/gradegraph.cpp b/src/jceData/Grades/graph/gradegraph.cpp index 0706efe..27e13a0 100644 --- a/src/jceData/Grades/graph/gradegraph.cpp +++ b/src/jceData/Grades/graph/gradegraph.cpp @@ -16,6 +16,7 @@ void gradegraph::showGraph(GradePage *gpPTR) setVisualization(); setGraphsData(); this->show(); + this->setModal(true); //makes it on top of application } diff --git a/src/jceData/course.h b/src/jceData/course.h index 3c90351..b4cdf07 100644 --- a/src/jceData/course.h +++ b/src/jceData/course.h @@ -15,22 +15,19 @@ class Course { public: - Course(int serial,QString name, QString type, double points) { + Course(int serial,QString name, QString type) { this->serialNum = serial; this->name = name; this->type = type; - this->points = points; } virtual ~Course() { } int getSerialNum() const {return this->serialNum;} virtual QString getName() const {return this->name;} virtual QString getType() const {return this->type;} - virtual double getPoints() const {return this->points;} virtual void setName(QString name) { this->name = name;} virtual void setType(QString type){ this->type = type;} - virtual void setPoints(double points){ this->points = points;} private: @@ -38,7 +35,6 @@ private: int serialNum; QString name; QString type; - double points; }; diff --git a/src/jceSettings/jceLoginHtmlScripts.h b/src/jceSettings/jceLoginHtmlScripts.h index 293017b..2eba6c3 100644 --- a/src/jceSettings/jceLoginHtmlScripts.h +++ b/src/jceSettings/jceLoginHtmlScripts.h @@ -84,6 +84,17 @@ public: parameters += "R1C2=" + QString::number(semester) + "&"; return parameters; } + const static QString getExamSchedule(const user &usr,int year, int semester) + { + QString parameters; + parameters = "PRGNAME=HADPASAT_TOCHNIT_BEHINOT&ARGUMENTS=TZ,UNIQ,R1C1,R1C2,R1C3&"; + parameters += "TZ=" + usr.getUserID() + "&"; + parameters += "UNIQ=" + usr.getHashedPassword() + "&"; + parameters += "R1C1=" + QString::number(year) + "&"; + parameters += "R1C2=" + QString::number(semester) + "&"; + parameters += "R1C3=0"; + return parameters; + } }; diff --git a/src/jceSettings/jcelogin.cpp b/src/jceSettings/jcelogin.cpp index 79e852c..c9c5062 100644 --- a/src/jceSettings/jcelogin.cpp +++ b/src/jceSettings/jcelogin.cpp @@ -199,6 +199,20 @@ int jceLogin::getCalendar(int year, int semester) return true; } +int jceLogin::getExams(int year, int semester) +{ + if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getExamSchedule(*jceA,year,semester))))) + { + if (!(JceConnector->recieveData(*recieverPage,false))) + return jceLogin::ERROR_ON_GETTING_PAGE; + else + return jceLogin::JCE_PAGE_PASSED; + } + else + return jceLogin::ERROR_ON_SEND_REQUEST; + + return true; +} /** * @brief jceLogin::getGrades according to parameters, we make an HTML request and send it over socket to server * @param fromYear - from year diff --git a/src/jceSettings/jcelogin.h b/src/jceSettings/jcelogin.h index 44310a8..66d1ca6 100644 --- a/src/jceSettings/jcelogin.h +++ b/src/jceSettings/jcelogin.h @@ -40,6 +40,7 @@ public: bool checkConnection() const; bool isLoginFlag() const; + int getExams(int year, int semester); int getCalendar(int year, int semester); int getGrades(int fromYear, int toYear, int fromSemester, int toSemester);