From 377c885d8a02778123200ef00b9be9cc60d8f573 Mon Sep 17 00:00:00 2001 From: Liran BN Date: Mon, 1 Sep 2014 20:06:58 +0300 Subject: [PATCH 1/2] ops --- jceGrade.pro.user | 267 ------------------------------------- jceGrade.pro.user.3.2-pre1 | 251 ---------------------------------- 2 files changed, 518 deletions(-) delete mode 100644 jceGrade.pro.user delete mode 100644 jceGrade.pro.user.3.2-pre1 diff --git a/jceGrade.pro.user b/jceGrade.pro.user deleted file mode 100644 index f606ccd..0000000 --- a/jceGrade.pro.user +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - EnvironmentId - {27d037c7-80c2-4adc-9ebd-7fcaa787aa69} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop - Desktop - {5099a051-769d-496c-9c12-be2a0d9569cf} - 0 - 0 - 0 - - /home/sagi/Development/SocialDev/build-jceGrade-Desktop-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - /home/sagi/Development/SocialDev/build-jceGrade-Desktop-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 2 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy locally - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - jceGrade - - Qt4ProjectManager.Qt4RunConfiguration:/home/sagi/Development/SocialDev/jceAverageCalculator/jceGrade.pro - - jceGrade.pro - false - false - - 3768 - false - true - false - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 16 - - - Version - 16 - - diff --git a/jceGrade.pro.user.3.2-pre1 b/jceGrade.pro.user.3.2-pre1 deleted file mode 100644 index c29c631..0000000 --- a/jceGrade.pro.user.3.2-pre1 +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.3.0 MinGW 32bit - Desktop Qt 5.3.0 MinGW 32bit - qt.53.win32_mingw482_kit - 0 - 0 - 0 - - D:/Dropbox/cpp/jceConQT/build-jceGrade-Desktop_Qt_5_3_0_MinGW_32bit-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - D:/Dropbox/cpp/jceConQT/build-jceGrade-Desktop_Qt_5_3_0_MinGW_32bit-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 2 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy locally - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - jceGrade - - Qt4ProjectManager.Qt4RunConfiguration:D:/Dropbox/cpp/jceConQT/jceAverageCalculator/jceGrade.pro - - jceGrade.pro - false - false - - 3768 - false - true - false - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.EnvironmentId - {f3f3b933-8225-47b3-aa78-fc5de0bd714b} - - - ProjectExplorer.Project.Updater.FileVersion - 15 - - From 556367767140fb5e190c0f4e06b67988528302e9 Mon Sep 17 00:00:00 2001 From: Liran BN Date: Tue, 2 Sep 2014 01:19:24 +0300 Subject: [PATCH 2/2] schedule is almost done! --- jceGrade.pro | 14 ++-- main/CalendarTab/CalendarManager.cpp | 12 +--- main/CalendarTab/CalendarManager.h | 11 ++- main/mainscreen.cpp | 8 ++- main/mainscreen.ui | 11 +-- src/jceData/Calendar/calendarCourse.cpp | 18 ++++- src/jceData/Calendar/calendarCourse.h | 5 +- src/jceData/Calendar/calendarPage.cpp | 21 +++--- src/jceData/Calendar/calendarPage.h | 10 ++- src/jceData/Calendar/calendarSchedule.cpp | 86 +++++++++++++++++++++++ src/jceData/Calendar/calendarSchedule.h | 34 +++++++++ src/jceSettings/jceLoginHtmlScripts.h | 2 +- 12 files changed, 179 insertions(+), 53 deletions(-) create mode 100644 src/jceData/Calendar/calendarSchedule.cpp create mode 100644 src/jceData/Calendar/calendarSchedule.h 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";