added #27. changed directories (overloaded), added some checkings.

This commit is contained in:
liranbg 2014-10-08 07:14:50 +03:00
parent 5a287a25ef
commit 6d623b7800
34 changed files with 697 additions and 106 deletions

View file

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

View file

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

View file

@ -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 <QObject>
#include <QWidget>
#include <QGridLayout>
#include <QMessageBox>
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;

View file

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

View file

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

View file

@ -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,6 +247,36 @@ 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);
@ -404,3 +434,5 @@ void MainScreen::on_progressBar_valueChanged(int value)
else
ui->progressBar->setVisible(true);
}

View file

@ -71,6 +71,8 @@ private slots:
void on_progressBar_valueChanged(int value);
void on_examsBtn_clicked();
private:
void checkLocale();

View file

@ -64,7 +64,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>
@ -606,6 +606,13 @@ font-size: 15px;
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="examsBtn">
<property name="text">
<string>Show Exams</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="exportToCVSBtn">
<property name="text">
@ -690,7 +697,7 @@ background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop:
<x>0</x>
<y>0</y>
<width>1133</width>
<height>23</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuA_about">

View file

@ -16,8 +16,8 @@
#include <QDebug>
#include <QMessageBox>
#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"

View file

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

View file

@ -0,0 +1,34 @@
#ifndef CALENDAREXAM_H
#define CALENDAREXAM_H
#include "../../page.h"
#include "calendarExamCourse.h"
#include <QString>
#include <QStringList>
#include <QList>
class calendarExam : public Page
{
public:
calendarExam();
void setPage(QString html);
QList<calendarExamCourse*>* getExams() { return exams; }
int getExamsCounter() const;
private:
void examListInit(QString &linesTokinzedString);
calendarExamCourse * lineToCourse(QString line);
QString htmlDataHolderParsed;
QList<calendarExamCourse*> *exams;
int examsCounter; //not including madei b
};
#endif // CALENDAREXAM_H

View file

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

View file

@ -0,0 +1,70 @@
#ifndef CALENDAREXAMCOURSE_H
#define CALENDAREXAMCOURSE_H
#include "../../course.h"
#include <QTime>
#include <QString>
#include <QDate>
#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

View file

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

View file

@ -0,0 +1,27 @@
#ifndef EXAMDIALOG_H
#define EXAMDIALOG_H
#include <QDialog>
#include <QDateEdit>
#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

View file

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>examDialog</class>
<widget class="QDialog" name="examDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>810</width>
<height>257</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:14pt;&quot;&gt;Exams Schedule&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>examDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>examDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -1,5 +0,0 @@
#include "calendarExam.h"
calendarExam::calendarExam()
{
}

View file

@ -1,12 +0,0 @@
#ifndef CALENDAREXAM_H
#define CALENDAREXAM_H
#include "../page.h"
class calendarExam : public Page
{
public:
calendarExam();
};
#endif // CALENDAREXAM_H

View file

@ -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<QString> 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)
{

View file

@ -1,8 +1,8 @@
#ifndef CALENDARPAGE_H
#define CALENDARPAGE_H
#include "../page.h"
#include "calendarCourse.h"
#include "../../page.h"
#include "calendarPageCourse.h"
#include <list>
#define ROOM_DEFAULT_STRING "nullRoom"
@ -12,18 +12,19 @@ class CalendarPage : public Page
{
public:
QString htmlToString();
std::list<calendarCourse*>* 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<calendarCourse*>* courses;

View file

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

View file

@ -1,7 +1,7 @@
#ifndef CALENDARCOURSE_H
#define CALENDARCOURSE_H
#include "../course.h"
#include "../../course.h"
#include <QTime>
#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;

View file

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

View file

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

View file

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

View file

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

View file

@ -16,6 +16,7 @@ void gradegraph::showGraph(GradePage *gpPTR)
setVisualization();
setGraphsData();
this->show();
this->setModal(true); //makes it on top of application
}

View file

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

View file

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

View file

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

View file

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