fixed bugs. ready to make graph feature
This commit is contained in:
parent
fd612169d7
commit
72dfc10778
|
@ -130,7 +130,6 @@ QString loginHandler::getCurrentPageContect()
|
||||||
parse.setText(jceLog->getPage());
|
parse.setText(jceLog->getPage());
|
||||||
else
|
else
|
||||||
throw jceLogin::ERROR_ON_GETTING_INFO;
|
throw jceLogin::ERROR_ON_GETTING_INFO;
|
||||||
|
|
||||||
return parse.toPlainText();
|
return parse.toPlainText();
|
||||||
}
|
}
|
||||||
int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester)
|
int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "ui_mainscreen.h"
|
#include "ui_mainscreen.h"
|
||||||
|
|
||||||
|
|
||||||
MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainScreen), busyFlag()
|
MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainScreen)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainSc
|
||||||
this->loginHandel = new loginHandler(userLoginSetting,ui->statusBar,ui->loginButton,ui->progressBar);
|
this->loginHandel = new loginHandler(userLoginSetting,ui->statusBar,ui->loginButton,ui->progressBar);
|
||||||
this->calendar = new CalendarManager(ui->calendarGridLayoutMain);
|
this->calendar = new CalendarManager(ui->calendarGridLayoutMain);
|
||||||
this->data = new SaveData();
|
this->data = new SaveData();
|
||||||
busyFlag = false;
|
|
||||||
|
|
||||||
//check login File
|
//check login File
|
||||||
if (data->isSaved())
|
if (data->isSaved())
|
||||||
|
@ -145,7 +144,7 @@ void MainScreen::on_ratesButton_clicked()
|
||||||
QString pageString;
|
QString pageString;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
if (loginHandel->isLoggedInFlag() && !busyFlag)
|
if (loginHandel->isLoggedInFlag())
|
||||||
{
|
{
|
||||||
ui->statusBar->showMessage(tr("Getting grades..."));
|
ui->statusBar->showMessage(tr("Getting grades..."));
|
||||||
if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),
|
if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),
|
||||||
|
@ -170,7 +169,6 @@ void MainScreen::on_ratesButton_clicked()
|
||||||
{
|
{
|
||||||
qCritical() << Q_FUNC_INFO << "grade get ended with" << status;
|
qCritical() << Q_FUNC_INFO << "grade get ended with" << status;
|
||||||
}
|
}
|
||||||
busyFlag = true;
|
|
||||||
}
|
}
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
@ -237,43 +235,34 @@ void MainScreen::on_graphButton_clicked()
|
||||||
//EVENTS ON CALENDAR TAB
|
//EVENTS ON CALENDAR TAB
|
||||||
void MainScreen::on_getCalendarBtn_clicked()
|
void MainScreen::on_getCalendarBtn_clicked()
|
||||||
{
|
{
|
||||||
|
ui->progressBar->setValue(0);
|
||||||
|
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
|
||||||
|
int status = 0;
|
||||||
QString page;
|
QString page;
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
if (loginHandel->isLoggedInFlag())
|
||||||
|
{
|
||||||
|
ui->statusBar->showMessage(tr("Getting schedule..."));
|
||||||
|
if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED)
|
||||||
|
{
|
||||||
calendar->resetTable();
|
calendar->resetTable();
|
||||||
page = ui->plainTextEdit->toPlainText();
|
ui->statusBar->showMessage(tr("Done. Inserting schdule into table..."),1000);
|
||||||
|
page = loginHandel->getCurrentPageContect();
|
||||||
calendar->setCalendar(page);
|
calendar->setCalendar(page);
|
||||||
// ui->progressBar->setValue(0);
|
ui->progressBar->setValue(100);
|
||||||
// qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
|
qDebug() << Q_FUNC_INFO << "calendar is loaded";
|
||||||
// int status = 0;
|
ui->statusBar->showMessage(tr("Done"));
|
||||||
// QString page;
|
}
|
||||||
// QApplication::setOverrideCursor(Qt::WaitCursor);
|
else if (status == jceLogin::JCE_NOT_CONNECTED)
|
||||||
// if (loginHandel->isLoggedInFlag())
|
{
|
||||||
// {
|
qWarning() << Q_FUNC_INFO << "not connected";
|
||||||
// ui->statusBar->showMessage(tr("Getting schedule..."));
|
QApplication::restoreOverrideCursor();
|
||||||
// if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED)
|
QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
|
||||||
// {
|
}
|
||||||
|
else
|
||||||
// //Use it for debug. add plain text and change the object name to 'plainTextEdit' so you will get the html request
|
qCritical() << Q_FUNC_INFO << "calendar get ended with" << status;
|
||||||
// //ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect());
|
}
|
||||||
// calendar->resetTable();
|
QApplication::restoreOverrideCursor();
|
||||||
// ui->statusBar->showMessage(tr("Done. Inserting schdule into table..."),1000);
|
|
||||||
|
|
||||||
// page = loginHandel->getCurrentPageContect();
|
|
||||||
// calendar->setCalendar(page);
|
|
||||||
// ui->progressBar->setValue(100);
|
|
||||||
// qDebug() << Q_FUNC_INFO << "calendar 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 << "calendar get ended with" << status;
|
|
||||||
// }
|
|
||||||
// QApplication::restoreOverrideCursor();
|
|
||||||
}
|
}
|
||||||
void MainScreen::on_exportToCVSBtn_clicked()
|
void MainScreen::on_exportToCVSBtn_clicked()
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,8 +85,6 @@ private:
|
||||||
coursesTableManager *courseTableMgr;
|
coursesTableManager *courseTableMgr;
|
||||||
loginHandler *loginHandel;
|
loginHandler *loginHandel;
|
||||||
|
|
||||||
bool busyFlag;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINSCREEN_H
|
#endif // MAINSCREEN_H
|
||||||
|
|
1141
main/mainscreen.ui
1141
main/mainscreen.ui
File diff suppressed because it is too large
Load diff
|
@ -61,7 +61,7 @@ void CalendarDialog::on_calStart_selectionChanged()
|
||||||
void CalendarDialog::on_buttonBox_accepted()
|
void CalendarDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
if(this->isOK)
|
if(this->isOK)
|
||||||
qDebug() << "CalendarDialog: Valid input";
|
qDebug() << Q_FUNC_INFO << "CalendarDialog: Valid input";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarDialog::on_calEnd_selectionChanged()
|
void CalendarDialog::on_calEnd_selectionChanged()
|
||||||
|
|
|
@ -8,37 +8,12 @@ QString CalendarPage::htmlToString()
|
||||||
void CalendarPage::setPage(QString html)
|
void CalendarPage::setPage(QString html)
|
||||||
{
|
{
|
||||||
|
|
||||||
qDebug() << "parsing calendar";
|
|
||||||
courses = new std::list<calendarCourse*>();
|
courses = new std::list<calendarCourse*>();
|
||||||
tempHtml = getString(html);
|
tempHtml = getString(html);
|
||||||
tempHtml = tokenToLines(tempHtml);
|
|
||||||
qDebug() << "creating courses list";
|
|
||||||
calendarListInit(tempHtml);
|
calendarListInit(tempHtml);
|
||||||
qDebug() << "done";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CalendarPage::tokenToLines(QString &textToParse)
|
|
||||||
{
|
|
||||||
int ctr = 0;
|
|
||||||
QString temp = "";
|
|
||||||
char *tok;
|
|
||||||
char* textToTok = strdup(textToParse.toStdString().c_str());
|
|
||||||
tok = strtok(textToTok, "\n");
|
|
||||||
while(tok != NULL)
|
|
||||||
{
|
|
||||||
//amount of data before the actual needed data and no empty lines
|
|
||||||
if (strcmp(tok," \t ") != 0)
|
|
||||||
{
|
|
||||||
temp += tok;
|
|
||||||
temp += "\n";
|
|
||||||
}
|
|
||||||
ctr++;
|
|
||||||
tok = strtok(NULL, "\n");
|
|
||||||
}
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarPage::calendarListInit(QString &linesTokinzedString)
|
void CalendarPage::calendarListInit(QString &linesTokinzedString)
|
||||||
{
|
{
|
||||||
std::list<QString> stringHolder;
|
std::list<QString> stringHolder;
|
||||||
|
@ -78,7 +53,7 @@ calendarCourse *CalendarPage::lineToCourse(QString line)
|
||||||
{
|
{
|
||||||
tempS = QString(tok);
|
tempS = QString(tok);
|
||||||
|
|
||||||
if (i >= 1)
|
if (i >= 1) //skips on semester character
|
||||||
{
|
{
|
||||||
templinearray[i-1] = tempS.trimmed();
|
templinearray[i-1] = tempS.trimmed();
|
||||||
}
|
}
|
||||||
|
@ -117,8 +92,18 @@ calendarCourse *CalendarPage::lineToCourse(QString line)
|
||||||
else
|
else
|
||||||
room = ROOM_DEFAULT_STRING;
|
room = ROOM_DEFAULT_STRING;
|
||||||
|
|
||||||
qDebug() << serial << name << type << lecturer << points << semesterHours << dayAndHour << room;
|
|
||||||
tempC = new calendarCourse(serial,name,type,lecturer,points,semesterHours,dayAndHour,room);
|
tempC = new calendarCourse(serial,name,type,lecturer,points,semesterHours,dayAndHour,room);
|
||||||
|
// qDebug() << "serial is: " << tempC->getSerialNum();
|
||||||
|
// qDebug() << tempC->getName();
|
||||||
|
// qDebug() << tempC->getType();
|
||||||
|
// qDebug() << tempC->getLecturer();
|
||||||
|
// qDebug() << tempC->getPoints();
|
||||||
|
// qDebug() << tempC->getHourBegin() << ":" << tempC->getMinutesBegin();
|
||||||
|
// qDebug() << tempC->getHourEnd() << ":" << tempC->getMinutesEnd();
|
||||||
|
|
||||||
|
// qDebug() << tempC->getDay();
|
||||||
|
// qDebug() << tempC->getRoom();
|
||||||
|
|
||||||
return tempC;
|
return tempC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString tokenToLines(QString &textToParse);
|
|
||||||
void calendarListInit(QString &linesTokinzedString);
|
void calendarListInit(QString &linesTokinzedString);
|
||||||
calendarCourse* lineToCourse(QString line);
|
calendarCourse* lineToCourse(QString line);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ void calendarSchedule::setPage(QString html)
|
||||||
{
|
{
|
||||||
CalendarPage::setPage(html);
|
CalendarPage::setPage(html);
|
||||||
qDebug() << Q_FUNC_INFO << "inserting into table";
|
qDebug() << Q_FUNC_INFO << "inserting into table";
|
||||||
// insertCourseIntoTable();
|
insertCourseIntoTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void calendarSchedule::clearTableItems()
|
void calendarSchedule::clearTableItems()
|
||||||
|
@ -61,12 +61,10 @@ void calendarSchedule::insertCourseIntoTable()
|
||||||
int row,col;
|
int row,col;
|
||||||
for (calendarCourse *coursePtr: *getCourses())
|
for (calendarCourse *coursePtr: *getCourses())
|
||||||
{
|
{
|
||||||
qDebug() << coursePtr->getSerialNum();
|
|
||||||
courseString = "";
|
courseString = "";
|
||||||
currentHour = coursePtr->getHourBegin();
|
currentHour = coursePtr->getHourBegin();
|
||||||
currentDay = coursePtr->getDay();
|
currentDay = coursePtr->getDay();
|
||||||
blocksNumber = coursePtr->getHourEnd() - coursePtr->getHourBegin(); //every hour is a block to fill!
|
blocksNumber = coursePtr->getHourEnd() - coursePtr->getHourBegin(); //every hour is a block to fill!
|
||||||
qDebug() << blocksNumber;
|
|
||||||
while (blocksNumber >= 0)
|
while (blocksNumber >= 0)
|
||||||
{
|
{
|
||||||
row = currentHour - HOURS_BEGIN;
|
row = currentHour - HOURS_BEGIN;
|
||||||
|
|
|
@ -4,7 +4,6 @@ GradePage::GradePage(QString html) : Page()
|
||||||
{
|
{
|
||||||
courses = new std::list<gradeCourse*>();
|
courses = new std::list<gradeCourse*>();
|
||||||
tempHtml = getString(html);
|
tempHtml = getString(html);
|
||||||
tempHtml = tokenToLines(tempHtml);
|
|
||||||
coursesListInit(tempHtml);
|
coursesListInit(tempHtml);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,26 +48,6 @@ void GradePage::coursesListInit(QString &linesTokinzedString)
|
||||||
courses->push_back(cTemp);
|
courses->push_back(cTemp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GradePage::tokenToLines(QString &textToPhrase)
|
|
||||||
{
|
|
||||||
QString temp = "";
|
|
||||||
char *tok;
|
|
||||||
char* textToTok = strdup(textToPhrase.toStdString().c_str());
|
|
||||||
tok = strtok(textToTok, "\n");
|
|
||||||
while(tok != NULL)
|
|
||||||
{
|
|
||||||
//amount of data before the actual needed data and no empty lines
|
|
||||||
if (strcmp(tok," \t ") != 0)
|
|
||||||
{
|
|
||||||
temp += tok;
|
|
||||||
temp += "\n";
|
|
||||||
}
|
|
||||||
tok = strtok(NULL, "\n");
|
|
||||||
}
|
|
||||||
return temp;
|
|
||||||
|
|
||||||
}
|
|
||||||
gradeCourse* GradePage::lineToCourse(QString line)
|
gradeCourse* GradePage::lineToCourse(QString line)
|
||||||
{
|
{
|
||||||
gradeCourse *tempC = NULL;
|
gradeCourse *tempC = NULL;
|
||||||
|
|
|
@ -27,7 +27,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString tokenToLines(QString &textToPhrase);
|
|
||||||
void coursesListInit(QString &linesTokinzedString);
|
void coursesListInit(QString &linesTokinzedString);
|
||||||
gradeCourse* lineToCourse(QString line);
|
gradeCourse* lineToCourse(QString line);
|
||||||
|
|
||||||
|
|
|
@ -67,23 +67,35 @@ void Page::manageTableContent(QString &html, int index)
|
||||||
if (i == -1) //EOF
|
if (i == -1) //EOF
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (tableTag == "<td ") // a Year title (in grades table)
|
else if (tableTag == "<td ") // a Year title (in grades table) or Day and Hour (in calendar page)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!dateHeader.isEmpty())
|
if (!dateHeader.isEmpty())
|
||||||
|
{
|
||||||
|
//checking if theres a need to fill a timestamp of course
|
||||||
|
//if the string is not empty, then we will chop the last date stamp to avoid multiple date stamp in empty rows
|
||||||
if (!temp.isEmpty())
|
if (!temp.isEmpty())
|
||||||
if (temp.lastIndexOf(dateHeader) == temp.length()-dateHeader.length())
|
if (temp.lastIndexOf(dateHeader) == temp.length()-dateHeader.length())
|
||||||
{
|
{
|
||||||
temp.chop(dateHeader.length()+1);
|
temp.chop(dateHeader.length()+5);
|
||||||
temp += "\t";
|
temp += "\t";
|
||||||
}
|
}
|
||||||
while ((html.mid(i,3) != "<b>") && (i < (int)html.length()))
|
}
|
||||||
|
while ((html.mid(i,5) != "</td>") && (i < (int)html.length()))
|
||||||
|
{
|
||||||
|
if (html.mid(i,3) == "<b>") //for gpa. year & semester title
|
||||||
{
|
{
|
||||||
if (html.mid(i,5) == "</td>")
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
else if ((html.at(i) == '>') && (html.mid(i+4,3) != "<b>")) //for calendar. day and hours
|
||||||
|
{
|
||||||
|
i += 1; //lenght of >
|
||||||
|
break;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
i = stitchText(html, temp, i);
|
i = stitchText(html, temp, i);
|
||||||
|
temp += "\t";
|
||||||
}
|
}
|
||||||
if (html.mid(i,(endofTable).length()) == endofTable) //is end of table
|
if (html.mid(i,(endofTable).length()) == endofTable) //is end of table
|
||||||
{
|
{
|
||||||
|
@ -98,7 +110,7 @@ void Page::manageTableContent(QString &html, int index)
|
||||||
|
|
||||||
int Page::stitchText(QString &from, QString &to, int index)
|
int Page::stitchText(QString &from, QString &to, int index)
|
||||||
{
|
{
|
||||||
if (from.at(index) == '<')
|
if (from.mid(index,3) == "<b>")
|
||||||
{
|
{
|
||||||
QString bTag = from.mid(index, 3);
|
QString bTag = from.mid(index, 3);
|
||||||
QString dateline = from.mid(index,from.indexOf("</b>",index+4)-index);
|
QString dateline = from.mid(index,from.indexOf("</b>",index+4)-index);
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
JCE_PAGE_PASSED
|
JCE_PAGE_PASSED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int makeConnection();
|
int makeConnection();
|
||||||
void closeAll();
|
void closeAll();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue