schedule is almost done!

This commit is contained in:
Liran BN 2014-09-02 01:19:24 +03:00
parent 377c885d8a
commit 5563677671
12 changed files with 179 additions and 53 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -2,23 +2,22 @@
#define CALENDARMANAGER_H
#include "./src/jceData/Calendar/calendarPage.h"
#include "./src/jceData/Calendar/calendarSchedule.h"
#include <iostream>
#include <QPlainTextEdit>
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

View file

@ -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()
"</ul>");
}

View file

@ -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>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<property name="documentMode">
<bool>false</bool>
@ -550,7 +550,7 @@ font-size: 15px;
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="calendarGridLayoutMain">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
@ -603,13 +603,6 @@ font-size: 15px;
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="calendartext">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View file

@ -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

View file

@ -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;

View file

@ -1,19 +1,18 @@
#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()
{
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)
{
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];

View file

@ -10,10 +10,16 @@
class CalendarPage : public Page
{
public:
CalendarPage(std::string html);
std::string htmlToString();
std::list<calendarCourse*>* 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<calendarCourse*>* courses;
};
#endif // CALENDARPAGE_H

View 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);
}

View 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

View file

@ -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";