diff --git a/main/CourseTab/coursestablemanager.cpp b/main/CourseTab/coursestablemanager.cpp
index f49bf87..6c7404c 100644
--- a/main/CourseTab/coursestablemanager.cpp
+++ b/main/CourseTab/coursestablemanager.cpp
@@ -5,46 +5,46 @@
*/
coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
{
- this->gp = NULL;
- this->us = usrPtr;
- this->courseTBL = ptr;
+ this->gp = NULL;
+ this->us = usrPtr;
+ this->courseTBL = ptr;
- /*
+ /*
* Initilizing Table
*/
- courseTBL->setRowCount(0);
- courseTBL->setColumnCount(COURSE_FIELDS);
- QStringList mz;
- mz << QObject::tr("Number") << QObject::tr("Year") << QObject::tr("Semester") << QObject::tr("Serial") << QObject::tr("Name") << QObject::tr("Type") << QObject::tr("Points") << QObject::tr("Hours") << QObject::tr("Grade") << QObject::tr("Additions");
- courseTBL->setHorizontalHeaderLabels(mz);
- courseTBL->verticalHeader()->setVisible(false);
- courseTBL->setSelectionMode(QAbstractItemView::SingleSelection);
- courseTBL->setShowGrid(true);
- courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
+ courseTBL->setRowCount(0);
+ courseTBL->setColumnCount(COURSE_FIELDS);
+ QStringList mz;
+ mz << QObject::tr("Number") << QObject::tr("Year") << QObject::tr("Semester") << QObject::tr("Serial") << QObject::tr("Name") << QObject::tr("Type") << QObject::tr("Points") << QObject::tr("Hours") << QObject::tr("Grade") << QObject::tr("Additions");
+ courseTBL->setHorizontalHeaderLabels(mz);
+ courseTBL->verticalHeader()->setVisible(false);
+ courseTBL->setSelectionMode(QAbstractItemView::SingleSelection);
+ courseTBL->setShowGrid(true);
+ courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
- graph = new gradegraph(NULL);
+ graph = new gradegraph(ptr);
}
coursesTableManager::~coursesTableManager()
{
- courseTBL = NULL;
- delete gp;
- gp = NULL;
+ courseTBL = NULL;
+ delete gp;
+ gp = NULL;
}
/**
* @brief coursesTableManager::insertJceCoursesIntoTable phrasing the course list to rows in table
*/
void coursesTableManager::insertJceCoursesIntoTable()
{
- for (gradeCourse *c: gp->getCourses())
+ for (gradeCourse *c: gp->getCourses())
{
- if (us->getInfluenceCourseOnly())
+ if (us->getInfluenceCourseOnly())
{
- if (isCourseInfluence(c))
- addRow(c);
- }
- else
+ if (isCourseInfluence(c))
addRow(c);
+ }
+ else
+ addRow(c);
}
}
/**
@@ -53,9 +53,9 @@ void coursesTableManager::insertJceCoursesIntoTable()
*/
void coursesTableManager::setCoursesList(QString &html)
{
- if (gp != NULL)
- gp->~GradePage();
- gp = new GradePage(html);
+ if (gp != NULL)
+ gp->~GradePage();
+ gp = new GradePage(html);
}
/**
* @brief coursesTableManager::changes when user changes the table manually it updates it
@@ -67,81 +67,81 @@ void coursesTableManager::setCoursesList(QString &html)
bool coursesTableManager::changes(QString change, int row, int col)
{
- bool isNumFlag = true;
- if (courseTBL->item(row,gradeCourse::CourseScheme::SERIAL) == NULL)
- return true;
+ bool isNumFlag = true;
+ if (courseTBL->item(row,gradeCourse::CourseScheme::SERIAL) == NULL)
+ return true;
- int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt();
- for (gradeCourse *c: gp->getCourses())
+ int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt();
+ for (gradeCourse *c: gp->getCourses())
{
- if (c->getSerialNum() == serialCourse)
+ if (c->getSerialNum() == serialCourse)
{
- switch (col)
+ switch (col)
{
case (gradeCourse::CourseScheme::COURSE_NUMBER_IN_LIST):
- c->setCourseNumInList(change.toInt());
- break;
+ c->setCourseNumInList(change.toInt());
+ break;
case (gradeCourse::CourseScheme::YEAR):
- c->setYear(change.toInt());
- break;
+ c->setYear(change.toInt());
+ break;
case (gradeCourse::CourseScheme::SEMESTER):
- c->setSemester(change.toInt());
- break;
+ c->setSemester(change.toInt());
+ break;
case (gradeCourse::CourseScheme::NAME):
- c->setName(change);
- break;
+ c->setName(change);
+ break;
case (gradeCourse::CourseScheme::TYPE):
- c->setType(change);
- break;
+ c->setType(change);
+ break;
case (gradeCourse::CourseScheme::POINTS):
- {
+ {
change.toDouble(&isNumFlag);
if (!isNumFlag)
- {
+ {
courseTBL->item(row,col)->setText(QString::number(c->getPoints()));
- }
+ }
else
- c->setPoints(change.toDouble());
+ c->setPoints(change.toDouble());
break;
- }
+ }
case (gradeCourse::CourseScheme::HOURS):
- {
+ {
change.toDouble(&isNumFlag);
if (!isNumFlag)
- {
+ {
courseTBL->item(row,col)->setText(QString::number(c->getHours()));
- }
+ }
else
- c->setHours(change.toDouble());
+ c->setHours(change.toDouble());
break;
- }
+ }
case (gradeCourse::CourseScheme::GRADE):
- {
+ {
change.toDouble(&isNumFlag);
if (!isNumFlag)
- {
+ {
courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
- }
+ }
else
- {
+ {
if ((change.toDouble() >= 0) && (change.toDouble() <= 100))
- c->setGrade(change.toDouble());
+ c->setGrade(change.toDouble());
else
- courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
- }
+ courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
+ }
break;
- }
+ }
case (gradeCourse::CourseScheme::ADDITION):
- c->setAdditions(change);
- break;
+ c->setAdditions(change);
+ break;
}
- break;
+ break;
}
}
- return isNumFlag;
+ return isNumFlag;
}
/**
@@ -150,183 +150,190 @@ bool coursesTableManager::changes(QString change, int row, int col)
*/
void coursesTableManager::addRow(const gradeCourse *courseToAdd)
{
- int i=1,j=1;
+ int i=1,j=1;
- j = 0;
- QTableWidgetItem *number,*year,*semester,*serial,*name,*type,*points,*hours,*grade,*addition;
- const gradeCourse * c;
- if (courseToAdd != NULL)
+ j = 0;
+ QTableWidgetItem *number,*year,*semester,*serial,*name,*type,*points,*hours,*grade,*addition;
+ const gradeCourse * c;
+ if (courseToAdd != NULL)
{
- c = courseToAdd;
- if (!isCourseAlreadyInserted(c->getSerialNum()))
+ c = courseToAdd;
+ if (!isCourseAlreadyInserted(c->getSerialNum()))
{
- courseTBL->setRowCount(courseTBL->rowCount() + 1);
- i = courseTBL->rowCount()-1;
+ courseTBL->setRowCount(courseTBL->rowCount() + 1);
+ i = courseTBL->rowCount()-1;
- number = new QTableWidgetItem();
- number->setData(Qt::EditRole, c->getCourseNumInList());
- number->setFlags(number->flags() & ~Qt::ItemIsEditable);
+ number = new QTableWidgetItem();
+ number->setData(Qt::EditRole, c->getCourseNumInList());
+ number->setFlags(number->flags() & ~Qt::ItemIsEditable);
- year = new QTableWidgetItem();
- year->setData(Qt::EditRole,c->getYear());
- year->setFlags(year->flags() & ~Qt::ItemIsEditable);
+ year = new QTableWidgetItem();
+ year->setData(Qt::EditRole,c->getYear());
+ year->setFlags(year->flags() & ~Qt::ItemIsEditable);
- semester = new QTableWidgetItem();
- semester->setData(Qt::EditRole,c->getSemester());
- semester->setFlags(semester->flags() & ~Qt::ItemIsEditable);
+ semester = new QTableWidgetItem();
+ semester->setData(Qt::EditRole,c->getSemester());
+ semester->setFlags(semester->flags() & ~Qt::ItemIsEditable);
- serial = new QTableWidgetItem();
- serial->setData(Qt::EditRole,c->getSerialNum());
- serial->setFlags(serial->flags() & ~Qt::ItemIsEditable);
+ serial = new QTableWidgetItem();
+ serial->setData(Qt::EditRole,c->getSerialNum());
+ serial->setFlags(serial->flags() & ~Qt::ItemIsEditable);
- name = new QTableWidgetItem();
- name->setData(Qt::EditRole,c->getName());
- name->setFlags(name->flags() & ~Qt::ItemIsEditable);
+ name = new QTableWidgetItem();
+ name->setData(Qt::EditRole,c->getName());
+ name->setFlags(name->flags() & ~Qt::ItemIsEditable);
- type = new QTableWidgetItem();
- type->setData(Qt::EditRole, c->getType());
- type->setFlags(type->flags() & ~Qt::ItemIsEditable);
+ type = new QTableWidgetItem();
+ type->setData(Qt::EditRole, c->getType());
+ type->setFlags(type->flags() & ~Qt::ItemIsEditable);
- points = new QTableWidgetItem();
- points->setData(Qt::EditRole, c->getPoints());
- points->setFlags(points->flags() & ~Qt::ItemIsEditable);
+ points = new QTableWidgetItem();
+ points->setData(Qt::EditRole, c->getPoints());
+ points->setFlags(points->flags() & ~Qt::ItemIsEditable);
- hours = new QTableWidgetItem();
- hours->setData(Qt::EditRole, c->getHours());
- hours->setFlags(hours->flags() & ~Qt::ItemIsEditable);
+ hours = new QTableWidgetItem();
+ hours->setData(Qt::EditRole, c->getHours());
+ hours->setFlags(hours->flags() & ~Qt::ItemIsEditable);
- grade = new QTableWidgetItem();
- grade->setData(Qt::EditRole,c->getGrade());
+ grade = new QTableWidgetItem();
+ // grade->setData(Qt::EditRole,c->getGrade()); //BUG good for sorting, the problem is when you edit -> the cell indicator disappear
+ grade->setText(QString::number(c->getGrade()));
- addition = new QTableWidgetItem();
- addition->setData(Qt::EditRole,c->getAddidtions());
+ addition = new QTableWidgetItem();
+ addition->setData(Qt::EditRole,c->getAddidtions());
- courseTBL->setItem(i,j++,number);
- courseTBL->setItem(i,j++,year);
- courseTBL->setItem(i,j++,semester);
- courseTBL->setItem(i,j++,serial);
- courseTBL->setItem(i,j++,name);
- courseTBL->setItem(i,j++,type);
- courseTBL->setItem(i,j++,points);
- courseTBL->setItem(i,j++,hours);
- courseTBL->setItem(i,j,grade);
- if(c->getGrade() < 55 && c->getGrade() != 0)
+ courseTBL->setItem(i,j++,number);
+ courseTBL->setItem(i,j++,year);
+ courseTBL->setItem(i,j++,semester);
+ courseTBL->setItem(i,j++,serial);
+ courseTBL->setItem(i,j++,name);
+ courseTBL->setItem(i,j++,type);
+ courseTBL->setItem(i,j++,points);
+ courseTBL->setItem(i,j++,hours);
+ courseTBL->setItem(i,j,grade);
+
+ //FIXME : make it a function, add it when cell has changed
+ if(c->getGrade() < 55 && c->getGrade() != 0)
{
- courseTBL->item(i, j)->setBackground(Qt::darkRed);
- courseTBL->item(i,j)->setTextColor(Qt::white);
+ courseTBL->item(i, j)->setBackground(Qt::darkRed);
+ courseTBL->item(i,j)->setTextColor(Qt::white);
}
- else if(55 <= c->getGrade() && c->getGrade() < 70 )
+ else if(55 <= c->getGrade() && c->getGrade() < 70 )
{
- courseTBL->item(i, j)->setBackground(Qt::darkYellow);
- courseTBL->item(i,j)->setTextColor(Qt::white);
+ courseTBL->item(i, j)->setBackground(Qt::darkYellow);
+ courseTBL->item(i,j)->setTextColor(Qt::white);
}
- // else if(70 < c->getGrade() && c->getGrade() <= 80 )
- // courseTBL->item(i, j)->setBackground(Qt::darkGreen); //They Look Bad!!
- // else if(c->getGrade() > 80)
- // courseTBL->item(i, j)->setBackground(Qt::green);
+ // else if(70 < c->getGrade() && c->getGrade() <= 80 )
+ // courseTBL->item(i, j)->setBackground(Qt::darkGreen); //They Look Bad!!
+ // else if(c->getGrade() > 80)
+ // courseTBL->item(i, j)->setBackground(Qt::green);
- j++;
+ j++;
- courseTBL->setItem(i,j,addition);
+ courseTBL->setItem(i,j,addition);
}
}
- else
+ else
{
- qCritical() << Q_FUNC_INFO << " no course to load!";
+ qCritical() << Q_FUNC_INFO << " no course to load!";
}
- courseTBL->resizeColumnsToContents();
- courseTBL->resizeRowsToContents();
+ courseTBL->resizeColumnsToContents();
+ courseTBL->resizeRowsToContents();
}
double coursesTableManager::getAvg()
{
- if (this->gp != NULL)
- return gp->getAvg();
- return 0;
+ if (this->gp != NULL)
+ return gp->getAvg();
+ return 0;
}
void coursesTableManager::showGraph()
{
- if (gp != NULL)
+ qDebug() << Q_FUNC_INFO;
+ if (gp != NULL)
{
- qDebug() << Q_FUNC_INFO << " Graph Dialog Opened. gp != NULL";
- this->graph->showGraph(gp);
+ this->graph->showGraph(gp);
+ }
+ else
+ {
+ qWarning() << Q_FUNC_INFO << "open with null grade page";
}
}
void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus)
{
- if (ignoreCourseStatus)
+ if (ignoreCourseStatus)
{
- int i = 0;
- while (i < courseTBL->rowCount())
+ int i = 0;
+ while (i < courseTBL->rowCount())
{
- if (courseTBL->item(i,gradeCourse::CourseScheme::POINTS)->text().compare("0") == 0)
- courseTBL->removeRow(i--);
- i++;
+ if (courseTBL->item(i,gradeCourse::CourseScheme::POINTS)->text().compare("0") == 0)
+ courseTBL->removeRow(i--);
+ i++;
}
}
- else
+ else
{
- if (this->gp != NULL)
- for (gradeCourse *c: gp->getCourses())
- {
- if (!(isCourseAlreadyInserted(c->getSerialNum())))
- if (c->getPoints() == 0)
- addRow(c);
- }
+ if (this->gp != NULL)
+ for (gradeCourse *c: gp->getCourses())
+ {
+ if (!(isCourseAlreadyInserted(c->getSerialNum())))
+ if (c->getPoints() == 0)
+ addRow(c);
+ }
}
}
void coursesTableManager::clearTable()
{
- if (courseTBL->rowCount() == 0)
- return;
+ if (courseTBL->rowCount() == 0)
+ return;
- int i = 0; //starting point
- while (courseTBL->rowCount() > i)
+ int i = 0; //starting point
+ while (courseTBL->rowCount() > i)
{
- gp->removeCourse(courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text());
- courseTBL->removeRow(i);
+ gp->removeCourse(courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text());
+ courseTBL->removeRow(i);
}
- gp = NULL;
- courseTBL->repaint();
+ gp = NULL;
+ courseTBL->repaint();
}
gradeCourse *coursesTableManager::getCourseByRow(int row)
{
- QString courseSerial = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text();
- for (gradeCourse *c: gp->getCourses())
+ QString courseSerial = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text();
+ for (gradeCourse *c: gp->getCourses())
{
- if (c->getSerialNum() == courseSerial.toDouble())
- return c;
+ if (c->getSerialNum() == courseSerial.toDouble())
+ return c;
}
- return NULL;
+ return NULL;
}
bool coursesTableManager::isCourseAlreadyInserted(double courseID)
{
- int i;
- for (i = courseTBL->rowCount(); i >= 0; --i)
+ int i;
+ for (i = courseTBL->rowCount(); i >= 0; --i)
{
- if (courseTBL->item(i,gradeCourse::CourseScheme::SERIAL) != NULL)
+ if (courseTBL->item(i,gradeCourse::CourseScheme::SERIAL) != NULL)
{
- QString courseSerial = courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text();
- if (QString::number(courseID) == courseSerial)
- return true;
+ QString courseSerial = courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text();
+ if (QString::number(courseID) == courseSerial)
+ return true;
}
}
- return false;
+ return false;
}
bool coursesTableManager::isCourseInfluence(const gradeCourse *courseToCheck)
{
- if (courseToCheck->getPoints() > 0)
- return true;
- return false;
+ if (courseToCheck->getPoints() > 0)
+ return true;
+ return false;
}
diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp
index 45d3390..b344918 100644
--- a/main/mainscreen.cpp
+++ b/main/mainscreen.cpp
@@ -1,416 +1,417 @@
#include "mainscreen.h"
#include "ui_mainscreen.h"
-//TODO: busy flag to aboid overload request
+//TODO: busy flag to avoid overload request
MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainScreen)
{
- ui->setupUi(this);
+ ui->setupUi(this);
- ui->labelMadeBy->setOpenExternalLinks(true);
+ ui->labelMadeBy->setOpenExternalLinks(true);
- //Login Tab
- iconPix.load(":/icons/iconX.png");
- ui->pswdLineEdit->setEchoMode((QLineEdit::Password));
- ui->labelUsrInputStatus->setVisible(false);
- ui->labelPswInputStatus->setVisible(false);
- ui->labelUsrInputStatus->setPixmap(iconPix);
- ui->labelPswInputStatus->setPixmap(iconPix);
+ //Login Tab
+ iconPix.load(":/icons/iconX.png");
+ ui->pswdLineEdit->setEchoMode((QLineEdit::Password));
+ ui->labelUsrInputStatus->setVisible(false);
+ ui->labelPswInputStatus->setVisible(false);
+ ui->labelUsrInputStatus->setPixmap(iconPix);
+ ui->labelPswInputStatus->setPixmap(iconPix);
- //StatusBar & progressbar
- ui->progressBar->setFixedHeight(STATUS_ICON_HEIGH);
- ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };");
- ui->statusBar->setFixedHeight(STATUS_ICON_HEIGH+5);
- ui->statusBar->showMessage(tr("Ready"));
+ //StatusBar & progressbar
+ ui->progressBar->setFixedHeight(STATUS_ICON_HEIGH);
+ ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };");
+ ui->statusBar->setFixedHeight(STATUS_ICON_HEIGH+5);
+ ui->statusBar->showMessage(tr("Ready"));
- //GPA Tab
- ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue));
+ //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,ui->progressBar);
- this->calendar = new CalendarManager(this,ui->calendarGridLayoutMain);
- this->data = new SaveData();
+ //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,ui->progressBar);
+ this->calendar = new CalendarManager(this,ui->calendarGridLayoutMain);
+ this->data = new SaveData();
- //check login File
- if (data->isSaved())
+ //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);
+ 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();
- ui->statusBar->repaint();
- qDebug() << Q_FUNC_INFO << "Ready.";
+ //language
+ qDebug() << Q_FUNC_INFO << "Checking locale";
+ checkLocale();
+ ui->statusBar->repaint();
+ qDebug() << Q_FUNC_INFO << "Ready.";
- //set the progress bar to be invisible (It will show only if value !=0 or !=100)
- ui->progressBar->setVisible(false);
+ //set the progress bar to be invisible (It will show only if value !=0 or !=100)
+ ui->progressBar->setVisible(false);
}
MainScreen::~MainScreen()
{
- delete calendar;
- delete courseTableMgr;
- delete userLoginSetting;
- delete loginHandel;
- delete data;
- delete ui;
+ delete calendar;
+ delete courseTableMgr;
+ delete userLoginSetting;
+ delete loginHandel;
+ delete data;
+ delete ui;
}
//EVENTS ON LOGIN TAB
void MainScreen::on_loginButton_clicked()
{
- ui->progressBar->setValue(0);
- qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
- if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty()))
+ ui->progressBar->setValue(0);
+ qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
+ if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty()))
{
- if (ui->usrnmLineEdit->text().isEmpty())
+ if (ui->usrnmLineEdit->text().isEmpty())
{
- ui->labelUsrInputStatus->setVisible(true);
- qDebug() << Q_FUNC_INFO << "username input is empty";
+ ui->labelUsrInputStatus->setVisible(true);
+ qDebug() << Q_FUNC_INFO << "username input is empty";
}
- else
- ui->labelUsrInputStatus->setVisible(false);
- if (ui->pswdLineEdit->text().isEmpty())
- {
- ui->labelPswInputStatus->setVisible(true);
- qDebug() << Q_FUNC_INFO << "password input is empty";
- }
- else
- ui->labelPswInputStatus->setVisible(false);
- return;
- }
- else
- {
+ else
ui->labelUsrInputStatus->setVisible(false);
- ui->labelPswInputStatus->setVisible(false);
- }
- qDebug() << Q_FUNC_INFO << "login session start";
- QApplication::setOverrideCursor(Qt::WaitCursor);
- if (this->loginHandel->login(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text()) == true)
- {
- ui->progressBar->setValue(100);
- qDebug() << Q_FUNC_INFO << "login session end with true";
- ui->pswdLineEdit->setDisabled(true);
- ui->usrnmLineEdit->setDisabled(true);
- if (ui->keepLogin->isChecked())
+ if (ui->pswdLineEdit->text().isEmpty())
{
- qDebug() << Q_FUNC_INFO << "saving data";
- data->setUsername(ui->usrnmLineEdit->text());
- data->setPassword(ui->pswdLineEdit->text());
+ ui->labelPswInputStatus->setVisible(true);
+ qDebug() << Q_FUNC_INFO << "password input is empty";
+ }
+ else
+ ui->labelPswInputStatus->setVisible(false);
+ return;
+ }
+ else
+ {
+ ui->labelUsrInputStatus->setVisible(false);
+ ui->labelPswInputStatus->setVisible(false);
+ }
+ qDebug() << Q_FUNC_INFO << "login session start";
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ if (this->loginHandel->login(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text()) == true)
+ {
+ ui->progressBar->setValue(100);
+ 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
+ else
{
- qDebug() << Q_FUNC_INFO << "login session end with false";
- ui->pswdLineEdit->setDisabled(false);
- ui->usrnmLineEdit->setDisabled(false);
+ qDebug() << Q_FUNC_INFO << "login session end with false";
+ ui->pswdLineEdit->setDisabled(false);
+ ui->usrnmLineEdit->setDisabled(false);
}
- QApplication::restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
}
void MainScreen::on_keepLogin_clicked()
{
- qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
- if (ui->keepLogin->isChecked())
+ 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());
+ qDebug() << Q_FUNC_INFO << "saving data";
+ data->setUsername(ui->usrnmLineEdit->text());
+ data->setPassword(ui->pswdLineEdit->text());
}
- else
- data->reset();
+ else
+ data->reset();
}
void MainScreen::on_usrnmLineEdit_editingFinished()
{
- qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
- ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower());
+ 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()
{
- ui->progressBar->setValue(0);
- qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
- if (!checkIfValidDates())
+
+ ui->progressBar->setValue(0);
+ qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
+ if (!checkIfValidDates())
{
- qWarning() << Q_FUNC_INFO << "Invalid dates! return";
- QMessageBox::critical(this,tr("Error"),tr("Invalid Dates.\nMake Sure everything is correct and try again"));
- return;
+ qWarning() << Q_FUNC_INFO << "Invalid dates! return";
+ QMessageBox::critical(this,tr("Error"),tr("Invalid Dates.\nMake Sure everything is correct and try again"));
+ return;
}
- QString pageString;
- int status = 0;
- QApplication::setOverrideCursor(Qt::WaitCursor);
- if (loginHandel->isLoggedInFlag())
+ QString pageString;
+ int status = 0;
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ if (loginHandel->isLoggedInFlag())
{
- ui->statusBar->showMessage(tr("Getting grades..."));
- if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),
- ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(),
- ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_PAGE_PASSED)
+ ui->statusBar->showMessage(tr("Getting grades..."));
+ if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),
+ ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(),
+ ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_PAGE_PASSED)
{
- qDebug() << Q_FUNC_INFO << "grade page is ready";
- ui->statusBar->showMessage(tr("Done. Inserting data into table..."),1000);
- pageString = loginHandel->getCurrentPageContect();
- courseTableMgr->setCoursesList(pageString);
- courseTableMgr->insertJceCoursesIntoTable();
- ui->progressBar->setValue(100);
- ui->statusBar->showMessage(tr("Done"));
+ qDebug() << Q_FUNC_INFO << "grade page is ready";
+ ui->statusBar->showMessage(tr("Done. Inserting data into table..."),1000);
+ pageString = loginHandel->getCurrentPageContect();
+ courseTableMgr->setCoursesList(pageString);
+ courseTableMgr->insertJceCoursesIntoTable();
+ ui->progressBar->setValue(100);
+ ui->statusBar->showMessage(tr("Done"));
}
- else if (status == jceLogin::JCE_NOT_CONNECTED)
+ else if (status == jceLogin::JCE_NOT_CONNECTED)
{
- qWarning() << Q_FUNC_INFO << "not connected";
- QApplication::restoreOverrideCursor();
- QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
+ qWarning() << Q_FUNC_INFO << "not connected";
+ QApplication::restoreOverrideCursor();
+ QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
}
- else
+ else
{
- qCritical() << Q_FUNC_INFO << "grade get ended with" << status;
+ qCritical() << Q_FUNC_INFO << "grade get ended with" << status;
}
}
- QApplication::restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
}
bool MainScreen::checkIfValidDates()
{
- bool flag = false;
- if (ui->spinBoxCoursesFromYear->value() < ui->spinBoxCoursesToYear->value())
+ bool flag = false;
+ if (ui->spinBoxCoursesFromYear->value() < ui->spinBoxCoursesToYear->value())
{
- //doesnt matter what is the semester, its valid!
+ //doesnt matter what is the semester, its valid!
+ flag = true;
+ }
+ else if ((ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value()))
+ {
+ //semester from must be equal or less than to semester
+ if (ui->spinBoxCoursesFromSemester->value() <= ui->spinBoxCoursesToSemester->value())
flag = true;
}
- else if ((ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value()))
- {
- //semester from must be equal or less than to semester
- if (ui->spinBoxCoursesFromSemester->value() <= ui->spinBoxCoursesToSemester->value())
- flag = true;
- }
- return flag;
+ return flag;
}
void MainScreen::on_checkBoxCoursesInfluence_toggled(bool checked)
{
- qDebug() << Q_FUNC_INFO << "only main courses toggeled" << checked;
- this->userLoginSetting->setInfluenceCourseOnly(checked);
- this->courseTableMgr->influnceCourseChanged(checked);
+ qDebug() << Q_FUNC_INFO << "only main courses toggeled" << checked;
+ this->userLoginSetting->setInfluenceCourseOnly(checked);
+ this->courseTableMgr->influnceCourseChanged(checked);
}
void MainScreen::on_spinBoxCoursesFromYear_valueChanged(int arg1)
{
- ui->spinBoxCoursesFromYear->setValue(arg1);
+ ui->spinBoxCoursesFromYear->setValue(arg1);
}
void MainScreen::on_spinBoxCoursesToYear_valueChanged(int arg1)
{
- ui->spinBoxCoursesToYear->setValue(arg1);
+ ui->spinBoxCoursesToYear->setValue(arg1);
}
void MainScreen::on_spinBoxCoursesFromSemester_valueChanged(int arg1)
{
- ui->spinBoxCoursesFromSemester->setValue(arg1%4);
+ ui->spinBoxCoursesFromSemester->setValue(arg1%4);
}
void MainScreen::on_spinBoxCoursesToSemester_valueChanged(int arg1)
{
- ui->spinBoxCoursesToSemester->setValue(arg1%4);
+ ui->spinBoxCoursesToSemester->setValue(arg1%4);
}
void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item)
{
- if (this->courseTableMgr->changes(item->text(),item->row(),item->column()))
- ui->avgLCD->display(courseTableMgr->getAvg());
- else
+ 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"));
+ 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());
+ qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
+ courseTableMgr->clearTable();
+ ui->avgLCD->display(courseTableMgr->getAvg());
}
void MainScreen::on_graphButton_clicked()
{
- qDebug() << "Show Graph button clicked";
- courseTableMgr->showGraph();
+ qDebug() << Q_FUNC_INFO;
+ courseTableMgr->showGraph();
}
//EVENTS ON CALENDAR TAB
void MainScreen::on_examsBtn_clicked()
{
- calendar->showExamDialog();
+ calendar->showExamDialog();
}
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->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)
+ ui->statusBar->showMessage(tr("Getting schedule..."));
+ if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED)
{
- calendar->resetTable();
- ui->statusBar->showMessage(tr("Done. Inserting schdule into table..."),1000);
- page = loginHandel->getCurrentPageContect();
- calendar->setCalendar(page);
+ calendar->resetTable();
+ ui->statusBar->showMessage(tr("Done. Inserting schdule into table..."),1000);
+ page = loginHandel->getCurrentPageContect();
+ calendar->setCalendar(page);
- qDebug() << Q_FUNC_INFO << "calendar is loaded";
+ qDebug() << Q_FUNC_INFO << "calendar is loaded";
- //auto getting exam
- if (loginHandel->isLoggedInFlag())
+ //auto getting exam
+ 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("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);
- qDebug() << Q_FUNC_INFO << "exams schedule is loaded";
+ ui->statusBar->showMessage(tr("Done."),1000);
+ page = loginHandel->getCurrentPageContect();
+ calendar->setExamsSchedule(page);
+ qDebug() << Q_FUNC_INFO << "exams schedule is loaded";
}
- else if (status == jceLogin::JCE_NOT_CONNECTED)
+ else if (status == jceLogin::JCE_NOT_CONNECTED)
{
- qWarning() << Q_FUNC_INFO << "not connected";
- QApplication::restoreOverrideCursor();
- QMessageBox::critical(this,tr("Error"),tr("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;
+ else
+ qCritical() << Q_FUNC_INFO << "exams request get ended with" << status;
- ui->progressBar->setValue(100);
- ui->statusBar->showMessage(tr("Done"));
+ ui->progressBar->setValue(100);
+ ui->statusBar->showMessage(tr("Done"));
}
- else if (status == jceLogin::JCE_NOT_CONNECTED)
+ else if (status == jceLogin::JCE_NOT_CONNECTED)
{
- qWarning() << Q_FUNC_INFO << "not connected";
- QApplication::restoreOverrideCursor();
- QMessageBox::critical(this,tr("Error"),tr("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;
+ else
+ qCritical() << Q_FUNC_INFO << "calendar get ended with" << status;
}
}
- QApplication::restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
}
void MainScreen::on_exportToCVSBtn_clicked()
{
- qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
- if (loginHandel->isLoggedInFlag())
+ qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
+ if (loginHandel->isLoggedInFlag())
{
- this->calendar->exportCalendarCSV();
+ this->calendar->exportCalendarCSV();
}
}
//EVENTS ON MENU BAR
void MainScreen::on_actionCredits_triggered()
{
- qDebug() << Q_FUNC_INFO;
- QMessageBox::about(this, "About",
- "Jce Manager v1.0.0
"
- +tr("License:")+
- "
GNU LESSER GENERAL PUBLIC LICENSE V2.1
"
- +"
"+
- "JceManager Repository"+
- "
"
- +tr("Powered By: ")+
- " Jce Connection
"
- +tr("Developed By")+
- ":