schedule is almost done!
This commit is contained in:
parent
377c885d8a
commit
5563677671
12 changed files with 179 additions and 53 deletions
14
jceGrade.pro
14
jceGrade.pro
|
@ -4,13 +4,13 @@
|
||||||
#
|
#
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui network
|
QT += core gui network widgets
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|
||||||
TARGET = jceGrade
|
TARGET = jceGrade
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
RC_FILE = appConfigure.rc
|
RC_FILE = appConfigure.rc
|
||||||
CONFIG += c++11 static
|
CONFIG += qt c++11
|
||||||
|
CONFIG += console
|
||||||
|
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
main/mainscreen.ui
|
main/mainscreen.ui
|
||||||
|
@ -35,7 +35,8 @@ HEADERS += \
|
||||||
src/jceSettings/jcelogin.h \
|
src/jceSettings/jcelogin.h \
|
||||||
src/jceSettings/jceLoginHtmlScripts.h \
|
src/jceSettings/jceLoginHtmlScripts.h \
|
||||||
src/jceSettings/user.h \
|
src/jceSettings/user.h \
|
||||||
src/jceData/Calendar/calendarCourse.h
|
src/jceData/Calendar/calendarCourse.h \
|
||||||
|
src/jceData/Calendar/calendarSchedule.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main/CalendarTab/CalendarManager.cpp \
|
main/CalendarTab/CalendarManager.cpp \
|
||||||
|
@ -51,5 +52,6 @@ SOURCES += \
|
||||||
src/jceData/page.cpp \
|
src/jceData/page.cpp \
|
||||||
src/jceSettings/jcelogin.cpp \
|
src/jceSettings/jcelogin.cpp \
|
||||||
src/jceSettings/user.cpp \
|
src/jceSettings/user.cpp \
|
||||||
src/jceData/Calendar/calendarCourse.cpp
|
src/jceData/Calendar/calendarCourse.cpp \
|
||||||
|
src/jceData/Calendar/calendarSchedule.cpp
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
#include "CalendarManager.h"
|
#include "CalendarManager.h"
|
||||||
|
|
||||||
CalendarManager::CalendarManager(QPlainTextEdit *ptr)
|
CalendarManager::CalendarManager(calendarSchedule *ptr)
|
||||||
{
|
{
|
||||||
this->ptr = ptr;
|
this->caliSchedPtr = ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarManager::setCalendar(std::string html)
|
void CalendarManager::setCalendar(std::string html)
|
||||||
{
|
{
|
||||||
cali = new CalendarPage(html);
|
caliSchedPtr->setPage(html);
|
||||||
QString text;
|
|
||||||
for (calendarCourse *a: *cali->getCourses())
|
|
||||||
{
|
|
||||||
text += QString::fromStdString(a->courseToString());
|
|
||||||
}
|
|
||||||
ptr->setPlainText(text);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,22 @@
|
||||||
#define CALENDARMANAGER_H
|
#define CALENDARMANAGER_H
|
||||||
|
|
||||||
#include "./src/jceData/Calendar/calendarPage.h"
|
#include "./src/jceData/Calendar/calendarPage.h"
|
||||||
|
#include "./src/jceData/Calendar/calendarSchedule.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <QPlainTextEdit>
|
|
||||||
|
|
||||||
class CalendarManager
|
class CalendarManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CalendarManager(QPlainTextEdit *ptr);
|
CalendarManager(calendarSchedule *ptr);
|
||||||
~CalendarManager()
|
~CalendarManager()
|
||||||
{
|
{
|
||||||
delete cali;
|
delete caliSchedPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCalendar(std::string html);
|
void setCalendar(std::string html);
|
||||||
|
void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); }
|
||||||
private:
|
private:
|
||||||
QPlainTextEdit * ptr;
|
calendarSchedule * caliSchedPtr;
|
||||||
CalendarPage * cali;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CALENDARMANAGER_H
|
#endif // CALENDARMANAGER_H
|
||||||
|
|
|
@ -22,16 +22,19 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
|
||||||
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
|
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
|
||||||
|
|
||||||
//Course, Setting, Calendar Tab
|
//Course, Setting, Calendar Tab
|
||||||
|
calendarSchedule * calendarSchedulePtr = new calendarSchedule();
|
||||||
|
ui->calendarGridLayoutMain->addWidget(calendarSchedulePtr);
|
||||||
ui->CoursesTab->setDisabled(true);
|
ui->CoursesTab->setDisabled(true);
|
||||||
ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue));
|
ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Pointer allocating
|
//Pointer allocating
|
||||||
|
|
||||||
this->userLoginSetting = new user("","");
|
this->userLoginSetting = new user("","");
|
||||||
this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting);
|
this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting);
|
||||||
this->loginHandel = new loginHandler(userLoginSetting);
|
this->loginHandel = new loginHandler(userLoginSetting);
|
||||||
this->calendar = new CalendarManager(ui->calendartext);
|
this->calendar = new CalendarManager(calendarSchedulePtr);
|
||||||
this->data = new SaveData();
|
this->data = new SaveData();
|
||||||
|
|
||||||
//check login File
|
//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
|
//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());
|
//ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect());
|
||||||
|
calendar->resetTable();
|
||||||
calendar->setCalendar(loginHandel->getCurrentPageContect().toStdString());
|
calendar->setCalendar(loginHandel->getCurrentPageContect().toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,5 +291,3 @@ void MainScreen::on_actionHow_To_triggered()
|
||||||
"</ul>");
|
"</ul>");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r
|
||||||
<enum>QTabWidget::Rounded</enum>
|
<enum>QTabWidget::Rounded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="documentMode">
|
<property name="documentMode">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
@ -550,7 +550,7 @@ font-size: 15px;
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_6">
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="calendarGridLayoutMain">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
|
@ -603,13 +603,6 @@ font-size: 15px;
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPlainTextEdit" name="calendartext">
|
|
||||||
<property name="layoutDirection">
|
|
||||||
<enum>Qt::RightToLeft</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -114,14 +114,28 @@ std::string calendarCourse::courseToString()
|
||||||
return courseText;
|
return courseText;
|
||||||
|
|
||||||
}
|
}
|
||||||
std::string calendarCourse::getDay() const
|
int calendarCourse::getDay() const
|
||||||
{
|
{
|
||||||
return day;
|
return day;
|
||||||
}
|
}
|
||||||
|
|
||||||
void calendarCourse::setDay(const std::string &value)
|
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
|
std::string calendarCourse::getRoom() const
|
||||||
|
|
|
@ -24,12 +24,11 @@ public:
|
||||||
DAY_AND_HOURS,
|
DAY_AND_HOURS,
|
||||||
ROOM
|
ROOM
|
||||||
};
|
};
|
||||||
|
|
||||||
calendarCourse(int serial, std::string name, std::string type, std::string lecturer,
|
calendarCourse(int serial, std::string name, std::string type, std::string lecturer,
|
||||||
double points, double semesterHours, std::string dayAndHour, std::string room);
|
double points, double semesterHours, std::string dayAndHour, std::string room);
|
||||||
~calendarCourse(){}
|
~calendarCourse(){}
|
||||||
|
|
||||||
std::string getDay() const;
|
int getDay() const;
|
||||||
std::string getLecturer() const;
|
std::string getLecturer() const;
|
||||||
std::string getRoom() const;
|
std::string getRoom() const;
|
||||||
double getSemesterHours() const;
|
double getSemesterHours() const;
|
||||||
|
@ -56,7 +55,7 @@ private:
|
||||||
|
|
||||||
std::string lecturer;
|
std::string lecturer;
|
||||||
double semesterHours;
|
double semesterHours;
|
||||||
std::string day;
|
int day;
|
||||||
int hourBegin;
|
int hourBegin;
|
||||||
int minutesBegin;
|
int minutesBegin;
|
||||||
int hourEnd;
|
int hourEnd;
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
#include "calendarPage.h"
|
#include "calendarPage.h"
|
||||||
|
|
||||||
CalendarPage::CalendarPage(std::string html)
|
|
||||||
{
|
|
||||||
courses = new std::list<calendarCourse*>();
|
|
||||||
tempHtml = getString(html);
|
|
||||||
tempHtml = tokenToLines(tempHtml);
|
|
||||||
std::cout << "last one..." << std::endl;
|
|
||||||
calendarListInit(tempHtml);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CalendarPage::htmlToString()
|
std::string CalendarPage::htmlToString()
|
||||||
{
|
{
|
||||||
return tempHtml;
|
return tempHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalendarPage::setPage(std::string html)
|
||||||
|
{
|
||||||
|
courses = new std::list<calendarCourse*>();
|
||||||
|
tempHtml = getString(html);
|
||||||
|
tempHtml = tokenToLines(tempHtml);
|
||||||
|
calendarListInit(tempHtml);
|
||||||
|
}
|
||||||
|
|
||||||
std::string CalendarPage::tokenToLines(std::string &textToPhrase)
|
std::string CalendarPage::tokenToLines(std::string &textToPhrase)
|
||||||
{
|
{
|
||||||
int ctr = 0;
|
int ctr = 0;
|
||||||
|
@ -84,10 +83,6 @@ calendarCourse *CalendarPage::lineToCourse(std::string line)
|
||||||
}
|
}
|
||||||
if (templinearray[0] == "") //empty phrasing
|
if (templinearray[0] == "") //empty phrasing
|
||||||
return NULL;
|
return NULL;
|
||||||
for (int p = 0; p < 8; ++p)
|
|
||||||
{
|
|
||||||
std::cout << "index : " << p << " is: " << templinearray[p] << std::endl;
|
|
||||||
}
|
|
||||||
serial = stoi(templinearray[calendarCourse::CourseScheme::SERIAL]);
|
serial = stoi(templinearray[calendarCourse::CourseScheme::SERIAL]);
|
||||||
name = templinearray[calendarCourse::CourseScheme::NAME];
|
name = templinearray[calendarCourse::CourseScheme::NAME];
|
||||||
type = templinearray[calendarCourse::CourseScheme::TYPE];
|
type = templinearray[calendarCourse::CourseScheme::TYPE];
|
||||||
|
|
|
@ -10,10 +10,16 @@
|
||||||
class CalendarPage : public Page
|
class CalendarPage : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CalendarPage(std::string html);
|
|
||||||
std::string htmlToString();
|
std::string htmlToString();
|
||||||
std::list<calendarCourse*>* getCourses() { return courses; }
|
std::list<calendarCourse*>* getCourses() { return courses; }
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void setPage(std::string html);
|
||||||
|
CalendarPage() { }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string tokenToLines(std::string& textToPhrase);
|
std::string tokenToLines(std::string& textToPhrase);
|
||||||
void calendarListInit(std::string& linesTokinzedString);
|
void calendarListInit(std::string& linesTokinzedString);
|
||||||
|
@ -21,6 +27,8 @@ private:
|
||||||
|
|
||||||
std::string tempHtml;
|
std::string tempHtml;
|
||||||
std::list<calendarCourse*>* courses;
|
std::list<calendarCourse*>* courses;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CALENDARPAGE_H
|
#endif // CALENDARPAGE_H
|
||||||
|
|
86
src/jceData/Calendar/calendarSchedule.cpp
Normal file
86
src/jceData/Calendar/calendarSchedule.cpp
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
34
src/jceData/Calendar/calendarSchedule.h
Normal file
34
src/jceData/Calendar/calendarSchedule.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef CALENDARSCHEDULE_H
|
||||||
|
#define CALENDARSCHEDULE_H
|
||||||
|
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "calendarPage.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
#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
|
|
@ -25,7 +25,7 @@ public:
|
||||||
msg += "Content-Type: application/x-www-form-urlencoded\r\n";
|
msg += "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||||
msg += "Content-Length: " + to_string(parameters.length()) + "\r\n";
|
msg += "Content-Length: " + to_string(parameters.length()) + "\r\n";
|
||||||
msg += "Proxy-Connection: Keep-Alive\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 += "Accept: text/plain\r\n";
|
||||||
msg += "Connection: Keep-Alive\r\n";
|
msg += "Connection: Keep-Alive\r\n";
|
||||||
msg += "\r\n";
|
msg += "\r\n";
|
||||||
|
|
Loading…
Reference in a new issue