diff --git a/jceGrade.pro b/jceGrade.pro index b341c1b..a2c9e16 100644 --- a/jceGrade.pro +++ b/jceGrade.pro @@ -4,13 +4,13 @@ # #------------------------------------------------- -QT += core gui network - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +QT += core gui network widgets TARGET = jceGrade TEMPLATE = app RC_FILE = appConfigure.rc -CONFIG += c++11 static +CONFIG += qt c++11 +CONFIG += console + FORMS += \ main/mainscreen.ui @@ -35,7 +35,8 @@ HEADERS += \ src/jceSettings/jcelogin.h \ src/jceSettings/jceLoginHtmlScripts.h \ src/jceSettings/user.h \ - src/jceData/Calendar/calendarCourse.h + src/jceData/Calendar/calendarCourse.h \ + src/jceData/Calendar/calendarSchedule.h SOURCES += \ main/CalendarTab/CalendarManager.cpp \ @@ -51,5 +52,6 @@ SOURCES += \ src/jceData/page.cpp \ src/jceSettings/jcelogin.cpp \ src/jceSettings/user.cpp \ - src/jceData/Calendar/calendarCourse.cpp + src/jceData/Calendar/calendarCourse.cpp \ + src/jceData/Calendar/calendarSchedule.cpp diff --git a/main/CalendarTab/CalendarManager.cpp b/main/CalendarTab/CalendarManager.cpp index 80dce68..ebb9899 100644 --- a/main/CalendarTab/CalendarManager.cpp +++ b/main/CalendarTab/CalendarManager.cpp @@ -1,17 +1,11 @@ #include "CalendarManager.h" -CalendarManager::CalendarManager(QPlainTextEdit *ptr) +CalendarManager::CalendarManager(calendarSchedule *ptr) { - this->ptr = ptr; + this->caliSchedPtr = ptr; } void CalendarManager::setCalendar(std::string html) { - cali = new CalendarPage(html); - QString text; - for (calendarCourse *a: *cali->getCourses()) - { - text += QString::fromStdString(a->courseToString()); - } - ptr->setPlainText(text); + caliSchedPtr->setPage(html); } diff --git a/main/CalendarTab/CalendarManager.h b/main/CalendarTab/CalendarManager.h index dc91bf4..042e831 100644 --- a/main/CalendarTab/CalendarManager.h +++ b/main/CalendarTab/CalendarManager.h @@ -2,23 +2,22 @@ #define CALENDARMANAGER_H #include "./src/jceData/Calendar/calendarPage.h" +#include "./src/jceData/Calendar/calendarSchedule.h" #include -#include - class CalendarManager { public: - CalendarManager(QPlainTextEdit *ptr); + CalendarManager(calendarSchedule *ptr); ~CalendarManager() { - delete cali; + delete caliSchedPtr; } void setCalendar(std::string html); + void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); } private: - QPlainTextEdit * ptr; - CalendarPage * cali; + calendarSchedule * caliSchedPtr; }; #endif // CALENDARMANAGER_H diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index 3d29cf1..bb26fc3 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -22,16 +22,19 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED); //Course, Setting, Calendar Tab + calendarSchedule * calendarSchedulePtr = new calendarSchedule(); + ui->calendarGridLayoutMain->addWidget(calendarSchedulePtr); ui->CoursesTab->setDisabled(true); ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue)); //Pointer allocating + this->userLoginSetting = new user("",""); this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting); this->loginHandel = new loginHandler(userLoginSetting); - this->calendar = new CalendarManager(ui->calendartext); + this->calendar = new CalendarManager(calendarSchedulePtr); this->data = new SaveData(); //check login File @@ -71,6 +74,7 @@ void MainScreen::on_pushButton_clicked() { //Use it for debug. add plain text and change the object name to 'plainTextEdit' so you will get the html request //ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect()); + calendar->resetTable(); calendar->setCalendar(loginHandel->getCurrentPageContect().toStdString()); } @@ -287,5 +291,3 @@ void MainScreen::on_actionHow_To_triggered() ""); } - - diff --git a/main/mainscreen.ui b/main/mainscreen.ui index 71993fc..df3cece 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -61,7 +61,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r QTabWidget::Rounded - 0 + 2 false @@ -550,7 +550,7 @@ font-size: 15px; - + @@ -603,13 +603,6 @@ font-size: 15px; - - - - Qt::RightToLeft - - - diff --git a/src/jceData/Calendar/calendarCourse.cpp b/src/jceData/Calendar/calendarCourse.cpp index 5927a53..8e534b5 100644 --- a/src/jceData/Calendar/calendarCourse.cpp +++ b/src/jceData/Calendar/calendarCourse.cpp @@ -114,14 +114,28 @@ std::string calendarCourse::courseToString() return courseText; } -std::string calendarCourse::getDay() const +int calendarCourse::getDay() const { return day; } void calendarCourse::setDay(const std::string &value) { - day = value; + std::string dayTemp = value.substr(0,2); + if (dayTemp.compare("\u05D0") == 0) //alef + day = 1; + else if (dayTemp.compare("\u05D1") == 0) //bet + day = 2; + else if (dayTemp.compare("\u05D2") == 0) //gimel + day = 3; + else if (dayTemp.compare("\u05D3") == 0) //dalet + day = 4; + else if (dayTemp.compare("\u05D4") == 0) //hey + day = 5; + else if (dayTemp.compare("\u05D5") == 0) //vav + day = 6; + else + day= -1; } std::string calendarCourse::getRoom() const diff --git a/src/jceData/Calendar/calendarCourse.h b/src/jceData/Calendar/calendarCourse.h index 4ecb18a..9c585a5 100644 --- a/src/jceData/Calendar/calendarCourse.h +++ b/src/jceData/Calendar/calendarCourse.h @@ -24,12 +24,11 @@ public: DAY_AND_HOURS, ROOM }; - calendarCourse(int serial, std::string name, std::string type, std::string lecturer, double points, double semesterHours, std::string dayAndHour, std::string room); ~calendarCourse(){} - std::string getDay() const; + int getDay() const; std::string getLecturer() const; std::string getRoom() const; double getSemesterHours() const; @@ -56,7 +55,7 @@ private: std::string lecturer; double semesterHours; - std::string day; + int day; int hourBegin; int minutesBegin; int hourEnd; diff --git a/src/jceData/Calendar/calendarPage.cpp b/src/jceData/Calendar/calendarPage.cpp index 917fb8c..71d93d4 100644 --- a/src/jceData/Calendar/calendarPage.cpp +++ b/src/jceData/Calendar/calendarPage.cpp @@ -1,19 +1,18 @@ #include "calendarPage.h" -CalendarPage::CalendarPage(std::string html) -{ - courses = new std::list(); - tempHtml = getString(html); - tempHtml = tokenToLines(tempHtml); - std::cout << "last one..." << std::endl; - calendarListInit(tempHtml); -} - std::string CalendarPage::htmlToString() { return tempHtml; } +void CalendarPage::setPage(std::string html) +{ + courses = new std::list(); + tempHtml = getString(html); + tempHtml = tokenToLines(tempHtml); + calendarListInit(tempHtml); +} + std::string CalendarPage::tokenToLines(std::string &textToPhrase) { int ctr = 0; @@ -84,10 +83,6 @@ calendarCourse *CalendarPage::lineToCourse(std::string line) } if (templinearray[0] == "") //empty phrasing return NULL; - for (int p = 0; p < 8; ++p) - { - std::cout << "index : " << p << " is: " << templinearray[p] << std::endl; - } serial = stoi(templinearray[calendarCourse::CourseScheme::SERIAL]); name = templinearray[calendarCourse::CourseScheme::NAME]; type = templinearray[calendarCourse::CourseScheme::TYPE]; diff --git a/src/jceData/Calendar/calendarPage.h b/src/jceData/Calendar/calendarPage.h index 00f5187..d1e7e38 100644 --- a/src/jceData/Calendar/calendarPage.h +++ b/src/jceData/Calendar/calendarPage.h @@ -10,10 +10,16 @@ class CalendarPage : public Page { public: - CalendarPage(std::string html); + std::string htmlToString(); std::list* getCourses() { return courses; } + +protected: + virtual void setPage(std::string html); +CalendarPage() { } + + private: std::string tokenToLines(std::string& textToPhrase); void calendarListInit(std::string& linesTokinzedString); @@ -21,6 +27,8 @@ private: std::string tempHtml; std::list* courses; + + }; #endif // CALENDARPAGE_H diff --git a/src/jceData/Calendar/calendarSchedule.cpp b/src/jceData/Calendar/calendarSchedule.cpp new file mode 100644 index 0000000..887c5eb --- /dev/null +++ b/src/jceData/Calendar/calendarSchedule.cpp @@ -0,0 +1,86 @@ +#include "calendarSchedule.h" + +calendarSchedule::calendarSchedule() +{ + QStringList days,hours; + QTextStream hourString; + QString a; + int startingHour = HOURS_BEGIN; + int endingHour = HOURS_END; + int academicHour = ACADEMIN_HOUR; + hourString.setString(&a); + for (int i = startingHour;i <= endingHour; ++i) + { + if (i < 10) + hourString << "0" << i << ":" << "00" << " - " << "0" << i << ":" << academicHour; + else + hourString << i << ":" << "00" << " - " << i << ":" << academicHour; + hours << QObject::tr(hourString.string()->toStdString().c_str()); + a = ""; + } + + 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); + + setLayoutDirection(Qt::LayoutDirection::RightToLeft);\ + + setHorizontalHeaderLabels(days); + setVerticalHeaderLabels(hours); + setEditTriggers(QAbstractItemView::NoEditTriggers); + horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); + +} + +void calendarSchedule::setPage(std::string html) +{ + CalendarPage::setPage(html); + + insertCourseIntoTable(); +} + +void calendarSchedule::clearTableItems() +{ + int i,j; + for (i = 0; i < rowCount(); i++) + for (j = 0; j < columnCount(); j++) + if (this->takeItem(i,j) != NULL) + delete this->takeItem(i,j); + horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); +} + +void calendarSchedule::insertCourseIntoTable() +{ + + QTableWidgetItem *item; + QString courseString; + int currentHour,currentDay,blocksNumer; + int row,col; + for (calendarCourse *coursePtr: *getCourses()) + { + courseString = ""; + currentHour = coursePtr->getHourBegin(); + currentDay = coursePtr->getDay(); + blocksNumer = coursePtr->getHourEnd() - coursePtr->getHourBegin(); + while (blocksNumer >= 0) + { + row = currentHour % HOURS_BEGIN; + col = currentDay-1; + courseString = (QString::fromStdString(coursePtr->getName() + " \n" + coursePtr->getLecturer() + " \n" + coursePtr->getRoom())); + item = new QTableWidgetItem(courseString); + if (this->takeItem(row,col) != NULL) + delete this->takeItem(row,col); + this->setItem(row,col,item); + + currentHour++; + --blocksNumer; + } + } + horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); +} + + diff --git a/src/jceData/Calendar/calendarSchedule.h b/src/jceData/Calendar/calendarSchedule.h new file mode 100644 index 0000000..df27daf --- /dev/null +++ b/src/jceData/Calendar/calendarSchedule.h @@ -0,0 +1,34 @@ +#ifndef CALENDARSCHEDULE_H +#define CALENDARSCHEDULE_H + +#include +#include +#include + +#include "calendarPage.h" +#include +#include + +#define HOURS_BEGIN 8 +#define HOURS_END 20 +#define ACADEMIN_HOUR 45 + +class calendarSchedule : public QTableWidget, public CalendarPage +{ + Q_OBJECT +public: + calendarSchedule(); + ~calendarSchedule() { clearTableItems(); } + void setPage(std::string html); + void clearTableItems(); + +signals: + +public slots: +private: + + void insertCourseIntoTable(); + +}; + +#endif // CALENDARSCHEDULE_H diff --git a/src/jceSettings/jceLoginHtmlScripts.h b/src/jceSettings/jceLoginHtmlScripts.h index 62f44b3..5b9f8a7 100644 --- a/src/jceSettings/jceLoginHtmlScripts.h +++ b/src/jceSettings/jceLoginHtmlScripts.h @@ -25,7 +25,7 @@ public: msg += "Content-Type: application/x-www-form-urlencoded\r\n"; msg += "Content-Length: " + to_string(parameters.length()) + "\r\n"; msg += "Proxy-Connection: Keep-Alive\r\n"; - msg += "Accept-Charset: utf-8"; + msg += "Accept-Charset: UTF-8"; msg += "Accept: text/plain\r\n"; msg += "Connection: Keep-Alive\r\n"; msg += "\r\n";