From 13eef8a2ed790454eef77af50808dd3ed8903b93 Mon Sep 17 00:00:00 2001 From: liranbg Date: Wed, 17 Sep 2014 04:57:44 +0300 Subject: [PATCH] fix dates validation. remove debugging in page --- main/mainscreen.cpp | 89 ++++++++++++++++++++++---------------------- main/mainscreen.h | 18 +++++---- main/mainscreen.ui | 10 ++--- src/jceData/page.cpp | 1 - 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index fa8b669..25e005b 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -28,7 +28,6 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr //Course, Setting, Calendar Tab calendarSchedule * calendarSchedulePtr = new calendarSchedule(); ui->calendarGridLayoutMain->addWidget(calendarSchedulePtr); - ui->CoursesTab->setDisabled(true); ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue)); //Pointer allocating @@ -181,6 +180,12 @@ void MainScreen::uiSetConnectMode() //EVENTS ON GPA TAB void MainScreen::on_ratesButton_clicked() { + if (!checkIfValidDates()) + { + qWarning() << "MainScreen::on_ratesButton_clicked; Invalid dates! "; + QMessageBox::critical(this,tr("Error"),tr("Invalid Dates.\nMake Sure everything is correct and try again")); + return; + } QString pageString; int status = 0; if (loginHandel->isLoggedInFlag()) @@ -197,50 +202,44 @@ void MainScreen::on_ratesButton_clicked() } } } +bool MainScreen::checkIfValidDates() +{ + bool flag = false; + if (ui->spinBoxCoursesFromYear->value() < ui->spinBoxCoursesToYear->value()) + { + //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; + } + return flag; +} void MainScreen::on_checkBoxCoursesInfluence_toggled(bool checked) { this->userLoginSetting->setInfluenceCourseOnly(checked); this->courseTableMgr->influnceCourseChanged(checked); } -void MainScreen::on_spinBoxCoursesFromYear_editingFinished() +void MainScreen::on_spinBoxCoursesFromYear_valueChanged(int arg1) { - if (ui->spinBoxCoursesFromYear->value() > ui->spinBoxCoursesToYear->value()) - { - ui->spinBoxCoursesFromYear->setValue(ui->spinBoxCoursesToYear->value()); - ui->spinBoxCoursesFromYear->setFocus(); - } + ui->spinBoxCoursesFromYear->setValue(arg1); +} + +void MainScreen::on_spinBoxCoursesToYear_valueChanged(int arg1) +{ + ui->spinBoxCoursesToYear->setValue(arg1); } -void MainScreen::on_spinBoxCoursesToYear_editingFinished() +void MainScreen::on_spinBoxCoursesFromSemester_valueChanged(int arg1) { - if (ui->spinBoxCoursesFromYear->value() > ui->spinBoxCoursesToYear->value()) - { - ui->spinBoxCoursesToYear->setValue(ui->spinBoxCoursesFromYear->value()); - ui->spinBoxCoursesToYear->setFocus(); - - } + ui->spinBoxCoursesFromSemester->setValue(arg1%4); } -void MainScreen::on_spinBoxCoursesFromSemester_editingFinished() +void MainScreen::on_spinBoxCoursesToSemester_valueChanged(int arg1) { - if (ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value()) - { - if (ui->spinBoxCoursesFromSemester->value() > ui->spinBoxCoursesToSemester->value()) - { - ui->spinBoxCoursesFromSemester->setValue(ui->spinBoxCoursesToSemester->value()); - ui->spinBoxCoursesFromSemester->setFocus(); - } - } -} -void MainScreen::on_spinBoxCoursesToSemester_editingFinished() -{ - if (ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value()) - { - if (ui->spinBoxCoursesFromSemester->value() > ui->spinBoxCoursesToSemester->value()) - { - ui->spinBoxCoursesToSemester->setValue(ui->spinBoxCoursesFromSemester->value()); - ui->spinBoxCoursesToSemester->setFocus(); - } - } + ui->spinBoxCoursesToSemester->setValue(arg1%4); } void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item) { @@ -291,13 +290,13 @@ void MainScreen::on_actionCredits_triggered() QMessageBox::about(this, "About", tr("CREDITS-ROOL-UP1") + " v1.0

" + tr("CREDITS-ROOL-UP2")+"
GNU LESSER GENERAL PUBLIC LICENSE V2
" + tr("CREDITS-ROOL-UP3")+"
" - "jceAverageCalculator Repository" - "

"+tr("CREDITS-ROOL-UP4")+" Jce Connection

" + "jceAverageCalculator Repository" + "

"+tr("CREDITS-ROOL-UP4")+" Jce Connection

" +tr("DevBy")+":" - ""); + ""); } void MainScreen::on_actionExit_triggered() { @@ -309,11 +308,11 @@ void MainScreen::on_actionHow_To_triggered() "How To.." ""); } diff --git a/main/mainscreen.h b/main/mainscreen.h index c130dbe..7f15462 100644 --- a/main/mainscreen.h +++ b/main/mainscreen.h @@ -32,14 +32,6 @@ private slots: void on_ratesButton_clicked(); - void on_spinBoxCoursesFromYear_editingFinished(); - - void on_spinBoxCoursesFromSemester_editingFinished(); - - void on_spinBoxCoursesToYear_editingFinished(); - - void on_spinBoxCoursesToSemester_editingFinished(); - void on_loginButton_clicked(); void on_usrnmLineEdit_editingFinished(); @@ -68,6 +60,14 @@ private slots: void on_actionOS_Default_triggered(); + void on_spinBoxCoursesFromSemester_valueChanged(int arg1); + + void on_spinBoxCoursesFromYear_valueChanged(int arg1); + + void on_spinBoxCoursesToYear_valueChanged(int arg1); + + void on_spinBoxCoursesToSemester_valueChanged(int arg1); + private: void uiSetDisconnectMode(); @@ -75,6 +75,8 @@ private: void setLabelConnectionStatus(jceLogin::jceStatus statusDescription); void checkLocale(); + bool checkIfValidDates(); + Ui::MainScreen *ui; QLabel *ButtomStatusLabel; diff --git a/main/mainscreen.ui b/main/mainscreen.ui index 201f57c..0f0a0de 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -61,7 +61,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r QTabWidget::Rounded - 2 + 1 false @@ -305,7 +305,7 @@ font-size: 15px; - false + true @@ -473,7 +473,7 @@ font-size: 15px; 1 - 3 + 999 @@ -539,7 +539,7 @@ font-size: 15px; 1 - 3 + 999 3 @@ -634,7 +634,7 @@ font-size: 15px; 0 0 855 - 21 + 22 diff --git a/src/jceData/page.cpp b/src/jceData/page.cpp index 7999e7d..3c7e44a 100644 --- a/src/jceData/page.cpp +++ b/src/jceData/page.cpp @@ -16,7 +16,6 @@ void Page::makeText(QString &html) int index = 0; index = html.indexOf("",0); //set index into the place where the data is manageTableContent(html, index); - qDebug() << "page after parsing " << text; } /** * @brief Page::manageTableContent strip html, make it string