more debugging detailes from mainscreen.cpp
add version variable to .pro
changed location of jcelogger
~still need to add translations
This commit is contained in:
liranbg 2014-09-23 01:17:05 +03:00
parent fc39787eb4
commit da009ed027
11 changed files with 166 additions and 119 deletions

View file

@ -1,67 +1,68 @@
#-------------------------------------------------
#
# Project created by QtCreator 2014-05-31T19:49:42
#
#-------------------------------------------------
QT += core gui network widgets
TARGET = jceGrade
TEMPLATE = app
RC_FILE = appConfigure.rc
CONFIG += qt c++11
CONFIG += console static
TRANSLATIONS = jce_en.ts \
jce_he.ts
FORMS += \
main/mainscreen.ui \
src/jceData/Calendar/calendarDialog.ui
OTHER_FILES +=
RESOURCES += \
resources/connectionstatus.qrc
HEADERS += \
main/CalendarTab/CalendarManager.h \
main/CourseTab/coursestablemanager.h \
main/LoginTab/loginhandler.h \
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 \
src/jceData/page.h \
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/jce_logger.h
SOURCES += \
main/CalendarTab/CalendarManager.cpp \
main/CourseTab/coursestablemanager.cpp \
main/LoginTab/loginhandler.cpp \
main/main.cpp \
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/jce_logger.cpp
#-------------------------------------------------
#
# Project created by QtCreator 2014-05-31T19:49:42
#
#-------------------------------------------------
QT += core gui network widgets
CONFIG += qt c++11
CONFIG += console static
TARGET = jceManager
TEMPLATE = app
VERSION = 1.0.0
RC_FILE = appConfigure.rc
TRANSLATIONS = jce_en.ts \
jce_he.ts
FORMS += \
main/mainscreen.ui \
src/jceData/Calendar/calendarDialog.ui
RESOURCES += \
resources/connectionstatus.qrc
HEADERS += \
main/CalendarTab/CalendarManager.h \
main/CourseTab/coursestablemanager.h \
main/LoginTab/loginhandler.h \
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 \
src/jceData/page.h \
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
SOURCES += \
main/CalendarTab/CalendarManager.cpp \
main/CourseTab/coursestablemanager.cpp \
main/LoginTab/loginhandler.cpp \
main/main.cpp \
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

View file

@ -1,8 +1,9 @@
#include "CalendarManager.h"
CalendarManager::CalendarManager(calendarSchedule *ptr)
CalendarManager::CalendarManager(QGridLayout *ptr)
{
this->caliSchedPtr = ptr;
caliSchedPtr = new calendarSchedule();
ptr->addWidget(caliSchedPtr);
caliDialog = new CalendarDialog();
}

View file

@ -5,13 +5,17 @@
#include "./src/jceData/Calendar/calendarSchedule.h"
#include "./src/jceData/CSV/csv_exporter.h"
#include "./src/jceData/Calendar/calendarDialog.h"
#include <iostream>
#include <QObject>
#include <QGridLayout>
#include <QMessageBox>
class CalendarManager
class CalendarManager : public QObject
{
Q_OBJECT
public:
CalendarManager(calendarSchedule *ptr);
CalendarManager(QGridLayout *ptr);
~CalendarManager()
{
delete caliSchedPtr;

View file

@ -17,10 +17,10 @@ loginHandler::loginHandler(user *ptr, QStatusBar *statusBarPtr,QPushButton *logi
}
bool loginHandler::login(QString username,QString password)
{
qDebug() << Q_FUNC_INFO << "Login with username and password";
qDebug() << Q_FUNC_INFO << "logging in with username and password";
if (isLoggedInFlag())
{
qDebug() << Q_FUNC_INFO << "Loging out";
qDebug() << Q_FUNC_INFO << "we are already connected. Logging out and return false";
logout();
return false;
}

View file

@ -2,7 +2,7 @@
#include "ui_mainscreen.h"
MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScreen)
MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainScreen)
{
ui->setupUi(this);
//this->setFixedSize(this->size()); //main not resizeable
@ -20,28 +20,30 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
ui->statusBar->setMaximumSize(this->geometry().width(),STATUS_ICON_HEIGH);
ui->statusBar->showMessage(tr("Ready"));
//Course, Calendar Tab
calendarSchedule * calendarSchedulePtr = new calendarSchedule();
ui->calendarGridLayoutMain->addWidget(calendarSchedulePtr);
//GPA Tab
ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue));
//Pointer allocating
qDebug() << Q_FUNC_INFO << "Allocating pointers";
this->userLoginSetting = new user("","");
this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting);
this->loginHandel = new loginHandler(userLoginSetting,ui->statusBar,ui->loginButton);
this->calendar = new CalendarManager(calendarSchedulePtr);
this->calendar = new CalendarManager(ui->calendarGridLayoutMain);
this->data = new SaveData();
//check login File
if (data->isSaved())
{
qDebug() << Q_FUNC_INFO << "Loading data from file";
ui->usrnmLineEdit->setText(data->getUsername());
ui->pswdLineEdit->setText(data->getPassword());
ui->keepLogin->setChecked(true);
}
//language
qDebug() << Q_FUNC_INFO << "Checking locale";
checkLocale();
qDebug() << Q_FUNC_INFO << "Ready.";
}
MainScreen::~MainScreen()
@ -53,13 +55,11 @@ MainScreen::~MainScreen()
delete data;
delete ui;
}
//EVENTS ON STATUS BAR
//EVENTS ON LOGIN TAB
void MainScreen::on_loginButton_clicked()
{
qDebug() << Q_FUNC_INFO;
bool isSettingsOk = false;
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty()))
{
if (ui->usrnmLineEdit->text().isEmpty())
@ -80,18 +80,25 @@ void MainScreen::on_loginButton_clicked()
}
else
{
isSettingsOk = true;
ui->labelUsrInputStatus->setVisible(false);
ui->labelPswInputStatus->setVisible(false);
}
qDebug() << Q_FUNC_INFO << "login session start";
if (this->loginHandel->login(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text()) == true)
{
qDebug() << Q_FUNC_INFO << "login session end with true";
ui->pswdLineEdit->setDisabled(true);
ui->usrnmLineEdit->setDisabled(true);
if (ui->keepLogin->isChecked())
{
qDebug() << Q_FUNC_INFO << "saving data";
data->setUsername(ui->usrnmLineEdit->text());
data->setPassword(ui->pswdLineEdit->text());
}
}
else
{
qDebug() << Q_FUNC_INFO << "login session end with end";
ui->pswdLineEdit->setDisabled(false);
ui->usrnmLineEdit->setDisabled(false);
@ -99,8 +106,10 @@ void MainScreen::on_loginButton_clicked()
}
void MainScreen::on_keepLogin_clicked()
{
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
if (ui->keepLogin->isChecked())
{
qDebug() << Q_FUNC_INFO << "saving data";
data->setUsername(ui->usrnmLineEdit->text());
data->setPassword(ui->pswdLineEdit->text());
}
@ -109,15 +118,17 @@ void MainScreen::on_keepLogin_clicked()
}
void MainScreen::on_usrnmLineEdit_editingFinished()
{
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower());
}
//EVENTS ON GPA TAB
void MainScreen::on_ratesButton_clicked()
{
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
if (!checkIfValidDates())
{
qWarning() << "MainScreen::on_ratesButton_clicked; Invalid dates! ";
qWarning() << Q_FUNC_INFO << "Invalid dates! return";
QMessageBox::critical(this,tr("Error"),tr("Invalid Dates.\nMake Sure everything is correct and try again"));
return;
}
@ -127,16 +138,22 @@ void MainScreen::on_ratesButton_clicked()
{
if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),
ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(),
ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_GRADE_PAGE_PASSED)
ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_PAGE_PASSED)
{
qDebug() << Q_FUNC_INFO << "grade page is ready";
pageString = loginHandel->getCurrentPageContect();
courseTableMgr->setCoursesList(pageString);
courseTableMgr->insertJceCoursesIntoTable();
}
else if (status == jceLogin::JCE_NOT_CONNECTED)
{
qWarning() << Q_FUNC_INFO << "not connected";
QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
}
else
{
qCritical() << Q_FUNC_INFO << "grade get ended with" << status;
}
}
}
bool MainScreen::checkIfValidDates()
@ -157,6 +174,7 @@ bool MainScreen::checkIfValidDates()
}
void MainScreen::on_checkBoxCoursesInfluence_toggled(bool checked)
{
qDebug() << Q_FUNC_INFO << "only main courses toggeled" << checked;
this->userLoginSetting->setInfluenceCourseOnly(checked);
this->courseTableMgr->influnceCourseChanged(checked);
}
@ -179,38 +197,49 @@ void MainScreen::on_spinBoxCoursesToSemester_valueChanged(int arg1)
}
void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item)
{
qDebug() << Q_FUNC_INFO << "item at row:" << item->row() << " colum:" << item->column() << " text: " << item->text();
if (this->courseTableMgr->changes(item->text(),item->row(),item->column()))
ui->avgLCD->display(courseTableMgr->getAvg());
else
{
qWarning() << Q_FUNC_INFO << "missmatch data";
QMessageBox::critical(this,tr("Error"),tr("Missmatching data"));
}
}
void MainScreen::on_clearTableButton_clicked()
{
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
courseTableMgr->clearTable();
ui->avgLCD->display(courseTableMgr->getAvg());
}
//EVENTS ON CALENDAR TAB
void MainScreen::on_getCalendarBtn_clicked()
{
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
int status = 0;
if (loginHandel->isLoggedInFlag())
{
if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_GRADE_PAGE_PASSED)
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();
calendar->setCalendar(loginHandel->getCurrentPageContect());
qDebug() << Q_FUNC_INFO << "calendar is loaded";
}
else if (status == jceLogin::JCE_NOT_CONNECTED)
{
qWarning() << Q_FUNC_INFO << "not connected";
QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
}
else
qCritical() << Q_FUNC_INFO << "calendar get ended with" << status;
}
}
void MainScreen::on_exportToCVSBtn_clicked()
{
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
if (loginHandel->isLoggedInFlag())
{
this->calendar->exportCalendarCSV();
@ -220,40 +249,54 @@ void MainScreen::on_exportToCVSBtn_clicked()
//EVENTS ON MENU BAR
void MainScreen::on_actionCredits_triggered()
{
QMessageBox::about(this, "About", tr("CREDITS-ROOL-UP1") + " v1.0<br><br>"
+ tr("CREDITS-ROOL-UP2")+"<br>GNU LESSER GENERAL PUBLIC LICENSE V2<br>"
+ tr("CREDITS-ROOL-UP3")+"<br>"
"<a href='https://github.com/liranbg/jceAverageCalculator'>jceAverageCalculator Repository</a>"
"<br><br>"+tr("CREDITS-ROOL-UP4")+"<a href='https://github.com/liranbg/jceConnection'> Jce Connection</a><br><br>"
+tr("DevBy")+":"
"<ul>"
"<li><a href='mailto:liranbg@gmail.com'>"+tr("Liran")+"</a></li>"
"<li><a href='mailto:sagidayan@gmail.com'>"+tr("Sagi")+"</a></li>"
"</ul>");
qDebug() << Q_FUNC_INFO;
QMessageBox::about(this, "About",
tr("Jce Manager")+
"v1.0.0<br><br>"
+tr("License:")+
"<br>GNU LESSER GENERAL PUBLIC LICENSE V2.1<br>"
+"<br>"+
"<a href='https://github.com/liranbg/JceManager'>JceManager Repository</a>"+
"<br><br>"
+tr("powered by: ")+
"<a href='https://github.com/liranbg/jceConnection'>Jce Connection</a><br><br>"
+tr("DevBy")+
":<ul>"+
"<li><a href='mailto:liranbg@gmail.com'>"+tr("Liran")+"</a></li>"+
"<li><a href='mailto:sagidayan@gmail.com'>"+tr("Sagi")+"</a></li></ul>"
);
}
void MainScreen::on_actionExit_triggered()
{
qDebug() << Q_FUNC_INFO;
exit(0);
}
void MainScreen::on_actionHow_To_triggered()
{
qDebug() << Q_FUNC_INFO;
QMessageBox::information(this,"How To",
"<b>How To..</b>"
"<ul>"
"<br><li>"+tr("HELP1")+"</li>"
"<br><li>"+tr("HELP2")+"</li>"
"<br><li>"+tr("HELP3")+"</li>"
"<br><li>"+tr("HELP4")+"</li>"
"<br><li>"+tr("HELP5")+"</li>"
"</ul>");
"<b>"
+tr("Guide")+
"</b><ul><br><li>"
+tr("login")+
"</li><br><li>"
+tr("get gpa")+
"</li><br><li>"
+tr("changing gpa")+
"</li><br><li>"
+tr("getting calendar")+
"</li><br><li>"
+tr("exporting")+
"</li></ul>");
}
void MainScreen::on_actionHebrew_triggered()
{
qDebug() << Q_FUNC_INFO;
if (ui->actionEnglish->isChecked() || ui->actionOS_Default->isChecked())
{
ui->actionEnglish->setChecked(false);
ui->actionOS_Default->setChecked(false);
qDebug() << "Changed Language to hebrew";
qDebug() << Q_FUNC_INFO << "Changed Language to hebrew";
data->setLocal("he");
QMessageBox::information(this,tr("Settings"),tr("Your settings will take effect next time you start the program"),QMessageBox::Ok);
}
@ -262,11 +305,12 @@ void MainScreen::on_actionHebrew_triggered()
}
void MainScreen::on_actionEnglish_triggered()
{
qDebug() << Q_FUNC_INFO;
if (ui->actionHebrew->isChecked() || ui->actionOS_Default->isChecked())
{
ui->actionHebrew->setChecked(false);
ui->actionOS_Default->setChecked(false);
qDebug() << "Changed Language to English";
qDebug() << Q_FUNC_INFO << "Changed Language to English";
data->setLocal("en");
QMessageBox::information(this,"Settings",tr("Your settings will take effect next time you start the program"),QMessageBox::Ok);
}
@ -275,11 +319,12 @@ void MainScreen::on_actionEnglish_triggered()
}
void MainScreen::on_actionOS_Default_triggered()
{
qDebug() << Q_FUNC_INFO;
if (ui->actionHebrew->isChecked() || ui->actionEnglish->isChecked())
{
ui->actionHebrew->setChecked(false);
ui->actionEnglish->setChecked(false);
qDebug() << "Changed Language to OS Default";
qDebug() << Q_FUNC_INFO << "Changed Language to OS Default";
data->setLocal("default");
QMessageBox::information(this,tr("Settings"),tr("Your settings will take effect next time you start the program"),QMessageBox::Ok);
}

View file

@ -7,9 +7,6 @@
#include <QMessageBox>
#include <QTextEdit>
#include <string>
#include <iostream>
#include "./CourseTab/coursestablemanager.h"
#include "./LoginTab/loginhandler.h"
#include "./CalendarTab/CalendarManager.h"
@ -82,7 +79,6 @@ private:
CalendarManager * calendar;
coursesTableManager *courseTableMgr;
loginHandler *loginHandel;
};

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>1</number>
<number>0</number>
</property>
<property name="documentMode">
<bool>false</bool>

View file

@ -188,9 +188,9 @@ int jceLogin::getCalendar(int year, int semester)
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getCalendar(*jceA,year,semester)))))
{
if (!(JceConnector->recieveData(*recieverPage,false)))
return jceLogin::ERROR_ON_GETTING_GRADES;
return jceLogin::ERROR_ON_GETTING_PAGE;
else
return jceLogin::JCE_GRADE_PAGE_PASSED;
return jceLogin::JCE_PAGE_PASSED;
}
else
return jceLogin::ERROR_ON_SEND_REQUEST;
@ -211,9 +211,9 @@ int jceLogin::getGrades(int fromYear, int toYear, int fromSemester, int toSemest
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA,fromYear, toYear, fromSemester, toSemester)))))
{
if (!(JceConnector->recieveData(*recieverPage,false)))
return jceLogin::ERROR_ON_GETTING_GRADES;
return jceLogin::ERROR_ON_GETTING_PAGE;
else
return jceLogin::JCE_GRADE_PAGE_PASSED;
return jceLogin::JCE_PAGE_PASSED;
}
else
return jceLogin::ERROR_ON_SEND_REQUEST;

View file

@ -24,12 +24,12 @@ public:
ERROR_ON_OPEN_SOCKET,
ERROR_ON_SEND_REQUEST,
ERROR_ON_GETTING_INFO,
ERROR_ON_GETTING_GRADES,
ERROR_ON_GETTING_PAGE,
JCE_START_VALIDATING_PROGRESS,
JCE_VALIDATION_PASSED,
JCE_YOU_ARE_IN,
JCE_GRADE_PAGE_PASSED
JCE_PAGE_PASSED
};
int makeConnection();