fixed bugs. ready to make graph feature

This commit is contained in:
Liran BN 2014-10-06 19:15:24 +03:00
parent fd612169d7
commit 72dfc10778
13 changed files with 411 additions and 1591 deletions

View file

@ -130,7 +130,6 @@ QString loginHandler::getCurrentPageContect()
parse.setText(jceLog->getPage());
else
throw jceLogin::ERROR_ON_GETTING_INFO;
return parse.toPlainText();
}
int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester)

View file

@ -2,7 +2,7 @@
#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);
@ -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->calendar = new CalendarManager(ui->calendarGridLayoutMain);
this->data = new SaveData();
busyFlag = false;
//check login File
if (data->isSaved())
@ -145,7 +144,7 @@ void MainScreen::on_ratesButton_clicked()
QString pageString;
int status = 0;
QApplication::setOverrideCursor(Qt::WaitCursor);
if (loginHandel->isLoggedInFlag() && !busyFlag)
if (loginHandel->isLoggedInFlag())
{
ui->statusBar->showMessage(tr("Getting grades..."));
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;
}
busyFlag = true;
}
QApplication::restoreOverrideCursor();
}
@ -237,43 +235,34 @@ void MainScreen::on_graphButton_clicked()
//EVENTS ON CALENDAR TAB
void MainScreen::on_getCalendarBtn_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 schedule..."));
if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED)
{
calendar->resetTable();
page = ui->plainTextEdit->toPlainText();
ui->statusBar->showMessage(tr("Done. Inserting schdule into table..."),1000);
page = loginHandel->getCurrentPageContect();
calendar->setCalendar(page);
// 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 schedule..."));
// if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED)
// {
// //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();
// 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();
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()
{

View file

@ -85,8 +85,6 @@ private:
coursesTableManager *courseTableMgr;
loginHandler *loginHandel;
bool busyFlag;
};
#endif // MAINSCREEN_H

File diff suppressed because it is too large Load diff

View file

@ -61,7 +61,7 @@ void CalendarDialog::on_calStart_selectionChanged()
void CalendarDialog::on_buttonBox_accepted()
{
if(this->isOK)
qDebug() << "CalendarDialog: Valid input";
qDebug() << Q_FUNC_INFO << "CalendarDialog: Valid input";
}
void CalendarDialog::on_calEnd_selectionChanged()

View file

@ -8,37 +8,12 @@ QString CalendarPage::htmlToString()
void CalendarPage::setPage(QString html)
{
qDebug() << "parsing calendar";
courses = new std::list<calendarCourse*>();
tempHtml = getString(html);
tempHtml = tokenToLines(tempHtml);
qDebug() << "creating courses list";
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)
{
std::list<QString> stringHolder;
@ -78,7 +53,7 @@ calendarCourse *CalendarPage::lineToCourse(QString line)
{
tempS = QString(tok);
if (i >= 1)
if (i >= 1) //skips on semester character
{
templinearray[i-1] = tempS.trimmed();
}
@ -117,8 +92,18 @@ calendarCourse *CalendarPage::lineToCourse(QString line)
else
room = ROOM_DEFAULT_STRING;
qDebug() << 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;
}

View file

@ -22,7 +22,6 @@ protected:
private:
QString tokenToLines(QString &textToParse);
void calendarListInit(QString &linesTokinzedString);
calendarCourse* lineToCourse(QString line);

View file

@ -38,7 +38,7 @@ void calendarSchedule::setPage(QString html)
{
CalendarPage::setPage(html);
qDebug() << Q_FUNC_INFO << "inserting into table";
// insertCourseIntoTable();
insertCourseIntoTable();
}
void calendarSchedule::clearTableItems()
@ -61,12 +61,10 @@ void calendarSchedule::insertCourseIntoTable()
int row,col;
for (calendarCourse *coursePtr: *getCourses())
{
qDebug() << coursePtr->getSerialNum();
courseString = "";
currentHour = coursePtr->getHourBegin();
currentDay = coursePtr->getDay();
blocksNumber = coursePtr->getHourEnd() - coursePtr->getHourBegin(); //every hour is a block to fill!
qDebug() << blocksNumber;
while (blocksNumber >= 0)
{
row = currentHour - HOURS_BEGIN;

View file

@ -4,7 +4,6 @@ GradePage::GradePage(QString html) : Page()
{
courses = new std::list<gradeCourse*>();
tempHtml = getString(html);
tempHtml = tokenToLines(tempHtml);
coursesListInit(tempHtml);
}
@ -49,26 +48,6 @@ void GradePage::coursesListInit(QString &linesTokinzedString)
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 *tempC = NULL;

View file

@ -27,7 +27,6 @@ public:
private:
QString tokenToLines(QString &textToPhrase);
void coursesListInit(QString &linesTokinzedString);
gradeCourse* lineToCourse(QString line);

View file

@ -67,23 +67,35 @@ void Page::manageTableContent(QString &html, int index)
if (i == -1) //EOF
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())
{
//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.lastIndexOf(dateHeader) == temp.length()-dateHeader.length())
{
temp.chop(dateHeader.length()+1);
temp.chop(dateHeader.length()+5);
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;
}
else if ((html.at(i) == '>') && (html.mid(i+4,3) != "<b>")) //for calendar. day and hours
{
i += 1; //lenght of >
break;
}
i++;
}
i = stitchText(html, temp, i);
temp += "\t";
}
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)
{
if (from.at(index) == '<')
if (from.mid(index,3) == "<b>")
{
QString bTag = from.mid(index, 3);
QString dateline = from.mid(index,from.indexOf("</b>",index+4)-index);

View file

@ -33,6 +33,7 @@ public:
JCE_PAGE_PASSED
};
int makeConnection();
void closeAll();