From 60fa80aa5cd5804a6f9a3367fd75eb17ad681673 Mon Sep 17 00:00:00 2001 From: liranbg Date: Sun, 12 Oct 2014 05:52:07 +0300 Subject: [PATCH] interface, schedule&exam --- main/CalendarTab/CalendarManager.cpp | 4 + main/CalendarTab/CalendarManager.h | 2 +- main/CourseTab/coursestablemanager.cpp | 118 ++-- main/LoginTab/loginhandler.cpp | 2 +- main/mainscreen.cpp | 78 ++- main/mainscreen.h | 40 +- main/mainscreen.ui | 554 ++++++++++-------- src/jceConnection/jcesslclient.cpp | 2 +- src/jceData/Calendar/Exams/examDialog.cpp | 157 ++++- src/jceData/Calendar/Exams/examDialog.h | 13 +- src/jceData/Calendar/Exams/examDialog.ui | 13 +- .../coursesSchedule/calendarDialog.cpp | 1 + .../coursesSchedule/calendarDialog.ui | 344 ++++++----- 13 files changed, 761 insertions(+), 567 deletions(-) diff --git a/main/CalendarTab/CalendarManager.cpp b/main/CalendarTab/CalendarManager.cpp index ec2816d..403143c 100644 --- a/main/CalendarTab/CalendarManager.cpp +++ b/main/CalendarTab/CalendarManager.cpp @@ -19,6 +19,10 @@ void CalendarManager::setExamsSchedule(QString html) { examSchePtr->setPage(html); examDialogPtr->initializingDataIntoTable(); +} + +void CalendarManager::showExamDialog() +{ examDialogPtr->show(); } void CalendarManager::exportCalendarCSV() diff --git a/main/CalendarTab/CalendarManager.h b/main/CalendarTab/CalendarManager.h index 182a527..e45430c 100644 --- a/main/CalendarTab/CalendarManager.h +++ b/main/CalendarTab/CalendarManager.h @@ -28,7 +28,7 @@ public: void exportCalendarCSV(); void setCalendar(QString html); void setExamsSchedule(QString html); - + void showExamDialog(); void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); } private: diff --git a/main/CourseTab/coursestablemanager.cpp b/main/CourseTab/coursestablemanager.cpp index da0d613..c60fa74 100644 --- a/main/CourseTab/coursestablemanager.cpp +++ b/main/CourseTab/coursestablemanager.cpp @@ -157,82 +157,84 @@ void coursesTableManager::addRow(const gradeCourse *courseToAdd) 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()); - 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->item(i, j)->setBackground(Qt::darkRed); - courseTBL->item(i,j)->setTextColor(Qt::white); - } - else if(55 <= c->getGrade() && c->getGrade() < 70 ) - { - 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); + 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->item(i, j)->setBackground(Qt::darkRed); + courseTBL->item(i,j)->setTextColor(Qt::white); + } + else if(55 <= c->getGrade() && c->getGrade() < 70 ) + { + 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); - j++; + j++; - courseTBL->setItem(i,j,addition); + courseTBL->setItem(i,j,addition); } } else { - qCritical() << Q_FUNC_INFO << " no course to load!"; + qCritical() << Q_FUNC_INFO << " no course to load!"; } + courseTBL->resizeColumnsToContents(); + courseTBL->resizeRowsToContents(); } double coursesTableManager::getAvg() @@ -246,8 +248,8 @@ void coursesTableManager::showGraph() { if (gp != NULL) { - qDebug() << Q_FUNC_INFO << " Graph Dialog Opened. gp != NULL"; - this->graph->showGraph(gp); + qDebug() << Q_FUNC_INFO << " Graph Dialog Opened. gp != NULL"; + this->graph->showGraph(gp); } } diff --git a/main/LoginTab/loginhandler.cpp b/main/LoginTab/loginhandler.cpp index c0c70e5..84b22d1 100644 --- a/main/LoginTab/loginhandler.cpp +++ b/main/LoginTab/loginhandler.cpp @@ -129,7 +129,7 @@ QString loginHandler::getCurrentPageContect() if (isLoggedInFlag()) parse.setText(jceLog->getPage()); else - throw jceLogin::ERROR_ON_GETTING_INFO; + return ""; return parse.toPlainText(); } int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester) diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index 96e7988..67ad197 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -175,7 +175,6 @@ void MainScreen::on_ratesButton_clicked() } QApplication::restoreOverrideCursor(); } - bool MainScreen::checkIfValidDates() { bool flag = false; @@ -199,28 +198,23 @@ void MainScreen::on_checkBoxCoursesInfluence_toggled(bool checked) this->userLoginSetting->setInfluenceCourseOnly(checked); this->courseTableMgr->influnceCourseChanged(checked); } - void MainScreen::on_spinBoxCoursesFromYear_valueChanged(int arg1) { ui->spinBoxCoursesFromYear->setValue(arg1); } - void MainScreen::on_spinBoxCoursesToYear_valueChanged(int arg1) { ui->spinBoxCoursesToYear->setValue(arg1); } - void MainScreen::on_spinBoxCoursesFromSemester_valueChanged(int arg1) { ui->spinBoxCoursesFromSemester->setValue(arg1%4); } - void MainScreen::on_spinBoxCoursesToSemester_valueChanged(int arg1) { ui->spinBoxCoursesToSemester->setValue(arg1%4); } - void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item) { if (this->courseTableMgr->changes(item->text(),item->row(),item->column())) @@ -231,7 +225,6 @@ void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item) QMessageBox::critical(this,tr("Error"),tr("Missmatching data")); } } - void MainScreen::on_clearTableButton_clicked() { qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); @@ -248,6 +241,11 @@ void MainScreen::on_graphButton_clicked() //EVENTS ON CALENDAR TAB void MainScreen::on_examsBtn_clicked() +{ + calendar->showExamDialog(); + +} +void MainScreen::on_getCalendarBtn_clicked() { ui->progressBar->setValue(0); qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); @@ -256,45 +254,38 @@ void MainScreen::on_examsBtn_clicked() QApplication::setOverrideCursor(Qt::WaitCursor); 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 schedule...")); + if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED) { - ui->statusBar->showMessage(tr("Done."),1000); + calendar->resetTable(); + ui->statusBar->showMessage(tr("Done. Inserting schdule into table..."),1000); page = loginHandel->getCurrentPageContect(); - calendar->setExamsSchedule(page); - ui->progressBar->setValue(100); - qDebug() << Q_FUNC_INFO << "exams schedule 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 << "exams request get ended with" << status; - } - QApplication::restoreOverrideCursor(); -} -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->setCalendar(page); + + qDebug() << Q_FUNC_INFO << "calendar is loaded"; + + //auto getting exam + if (loginHandel->isLoggedInFlag()) { - calendar->resetTable(); - ui->statusBar->showMessage(tr("Done. Inserting schdule into table..."),1000); - page = loginHandel->getCurrentPageContect(); - calendar->setCalendar(page); + 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"; + } + 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 << "exams request get ended with" << status; + + ui->progressBar->setValue(100); - qDebug() << Q_FUNC_INFO << "calendar is loaded"; ui->statusBar->showMessage(tr("Done")); } else if (status == jceLogin::JCE_NOT_CONNECTED) @@ -306,7 +297,8 @@ void MainScreen::on_getCalendarBtn_clicked() else qCritical() << Q_FUNC_INFO << "calendar get ended with" << status; } - QApplication::restoreOverrideCursor(); + } + QApplication::restoreOverrideCursor(); } void MainScreen::on_exportToCVSBtn_clicked() { diff --git a/main/mainscreen.h b/main/mainscreen.h index 3f9a7f9..116c957 100644 --- a/main/mainscreen.h +++ b/main/mainscreen.h @@ -27,56 +27,42 @@ public: private slots: - void on_ratesButton_clicked(); - + //Login Tab slots void on_loginButton_clicked(); - + void on_keepLogin_clicked(); void on_usrnmLineEdit_editingFinished(); - void on_actionCredits_triggered(); - + //GPA Tab slots + void on_ratesButton_clicked(); + void on_graphButton_clicked(); void on_clearTableButton_clicked(); - - void on_actionExit_triggered(); - void on_coursesTable_itemChanged(QTableWidgetItem *item); - - void on_keepLogin_clicked(); - - void on_actionHow_To_triggered(); - - void on_getCalendarBtn_clicked(); - void on_checkBoxCoursesInfluence_toggled(bool checked); + //Schedule Tab slots + void on_getCalendarBtn_clicked(); + void on_examsBtn_clicked(); void on_exportToCVSBtn_clicked(); + //Menubar slots + void on_actionCredits_triggered(); + void on_actionExit_triggered(); + void on_actionHow_To_triggered(); void on_actionHebrew_triggered(); - void on_actionEnglish_triggered(); - void on_actionOS_Default_triggered(); + //Main screen general slots void on_spinBoxCoursesFromSemester_valueChanged(int arg1); - void on_spinBoxCoursesFromYear_valueChanged(int arg1); - void on_spinBoxCoursesToYear_valueChanged(int arg1); - void on_spinBoxCoursesToSemester_valueChanged(int arg1); - void on_labelMadeBy_linkActivated(const QString &link); - - void on_graphButton_clicked(); - void on_progressBar_valueChanged(int value); - void on_examsBtn_clicked(); - private: void checkLocale(); - bool checkIfValidDates(); Ui::MainScreen *ui; diff --git a/main/mainscreen.ui b/main/mainscreen.ui index 4e24066..997f0a2 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -48,7 +48,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r - + @@ -64,7 +64,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r QTabWidget::Rounded - 1 + 0 false @@ -119,7 +119,6 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r #LoginFrame { border: 3px solid rgb(160, 165, 170); border-radius: 40px; - } #loginButton { color: white; @@ -327,21 +326,290 @@ font-size: 15px; 0 - - - - Qt::Horizontal + + + + + 0 + 0 + - - QSizePolicy::Expanding + + #frameTo { + border: 1px solids; + border-style: inset; + border-color: black; + border-radius: 10px; +} - - - 40 - 20 - + + QFrame::StyledPanel - + + QFrame::Raised + + + + 1 + + + 0 + + + 0 + + + 0 + + + 0 + + + 1 + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + + + Semester: + + + + + + + 1 + + + 999 + + + 3 + + + + + + + + 0 + 0 + + + + + + + Year: + + + + + + + 2008 + + + 2016 + + + 2015 + + + + + + + + + + 0 + 0 + + + + + + + <html><head/><body><p align="center">To</p></body></html> + + + + + + + + + + + 0 + 0 + + + + #frameBtns { + border: 0px solids; +} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 5 + + + 0 + + + 0 + + + 0 + + + 9 + + + 0 + + + + + 0 + + + 0 + + + + + 0 + + + -1 + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600;">Clear table</span></p></body></html> + + + Clear Table + + + + + + + true + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600;">Get your grades</span></p></body></html> + + + Get GPA + + + false + + + false + + + false + + + + + + + + + #frameMainCourses { + border: 0px solids; +} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Only Main Courses + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -353,9 +621,10 @@ font-size: 15px; #frameFrom { - border-width: 1px; + border: 1px solids; border-style: inset; border-color: black; + border-radius: 10px; } @@ -461,223 +730,8 @@ font-size: 15px; - - - - - 0 - 0 - - - - #frameTo { - border-width: 1px; - border-style: inset; - border-color: black; -} - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 1 - - - 0 - - - 0 - - - 0 - - - 0 - - - 1 - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - - - Year: - - - - - - - 2008 - - - 2016 - - - 2015 - - - - - - - - 0 - 0 - - - - - - - Semester: - - - - - - - 1 - - - 999 - - - 3 - - - - - - - - - - 0 - 0 - - - - - - - <html><head/><body><p align="center">To</p></body></html> - - - - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 5 - - - 0 - - - 0 - - - 0 - - - 9 - - - 0 - - - - - true - - - <html><head/><body><p><span style=" font-weight:600;">Get your grades</span></p></body></html> - - - Get GPA - - - - - - - <html><head/><body><p><span style=" font-weight:600;">Clear table</span></p></body></html> - - - Clear Table - - - - - - - - - - - 0 - 0 - - - - Only Main Courses - - - - - - - - 0 - 0 - - - - Qt::RightToLeft - - - QAbstractItemView::SingleSelection - - - true - - - @@ -738,6 +792,25 @@ font-size: 15px; + + + + + 0 + 0 + + + + Qt::RightToLeft + + + QAbstractItemView::SingleSelection + + + true + + + @@ -782,7 +855,7 @@ font-size: 15px; - Get Schedule + Get Schedule && Exam @@ -823,13 +896,6 @@ font-size: 15px; - - - - <p align="center">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> - - - @@ -869,6 +935,13 @@ background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop: + + + + <p align="center">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> + + + @@ -877,7 +950,7 @@ background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop: 0 0 1133 - 21 + 22 @@ -968,7 +1041,6 @@ background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop: spinBoxYear spinBoxSemester getCalendarBtn - exportToCVSBtn diff --git a/src/jceConnection/jcesslclient.cpp b/src/jceConnection/jcesslclient.cpp index 2eec393..deb03cd 100644 --- a/src/jceConnection/jcesslclient.cpp +++ b/src/jceConnection/jcesslclient.cpp @@ -170,7 +170,7 @@ bool jceSSLClient::recieveData(QString *str) disconnect(this, SIGNAL(readyRead()), this, SLOT(readIt())); str->append(packet); - //qDebug() << *str; //if you want to see the whole packet, unmark me +// qDebug() << *str; //if you want to see the whole packet, unmark me qDebug() << Q_FUNC_INFO << "packet size: " << packetSizeRecieved << "received data lenght: " << str->length(); qDebug() << Q_FUNC_INFO << "return with flag: " << recieveLastPacket; diff --git a/src/jceData/Calendar/Exams/examDialog.cpp b/src/jceData/Calendar/Exams/examDialog.cpp index 4c0ae8d..1a1b84f 100644 --- a/src/jceData/Calendar/Exams/examDialog.cpp +++ b/src/jceData/Calendar/Exams/examDialog.cpp @@ -13,15 +13,21 @@ examDialog::examDialog(QWidget *parent, calendarExam *calSchedPtr) : QDialog(par QStringList headLine; //SERIAL, NAME, LECTURER, FIELD, TYPE, FIRST_DATE, FIRST_HOUR_BEGIN, SECOND_DATE, SECOND_HOUR_BEGIN - headLine << tr("Serial") << tr("Course") << tr("Lecturer") << tr("Field") << tr("Type") << tr("First") << tr("Begin") << tr("Second") << tr("Begin"); + headLine << tr("Serial") << tr("Course") << tr("Lecturer") << tr("Field") << tr("Type") << tr("Exam 1 Date") << tr("Starting Hour") << tr("Exam 2 Date") << tr("Starting Hour"); ui->tableWidget->verticalHeader()->setVisible(false); - ui->tableWidget->horizontalHeader()->setVisible(false); + ui->tableWidget->horizontalHeader()->setVisible(true); ui->tableWidget->setColumnCount(EXAM_SCHEDULE_FIELDS); ui->tableWidget->setHorizontalHeaderLabels(headLine); ui->tableWidget->setLayoutDirection(Qt::LayoutDirection::RightToLeft); + ui->tableWidget->setSortingEnabled(false); - this->setModal(true); + this->setModal(true); //always on top + + ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); + ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Interactive); + + connect(ui->tableWidget,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(upgradeExamsTime(QTableWidgetItem*))); } /** @@ -31,58 +37,151 @@ examDialog::examDialog(QWidget *parent, calendarExam *calSchedPtr) : QDialog(par */ void examDialog::initializingDataIntoTable() { + disconnect(ui->tableWidget,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(upgradeExamsTime(QTableWidgetItem*))); ui->tableWidget->setRowCount(exams->getExamsCounter()); int i=0,j=0; + int year,month,day; //for constructin qdate by setdate QTableWidgetItem *lecturer,*name,*type; QTableWidgetItem *serial; QTableWidgetItem *field; - QDateEdit *firstDate; - QTimeEdit *firstHourbegin; - QDateEdit *secondDate; - QTimeEdit *secondHourbegin; + QTableWidgetItem *firstDate; + QTableWidgetItem *firstHourbegin; + QTableWidgetItem *secondDate; + QTableWidgetItem *secondHourbegin; for (calendarExamCourse * tempExam: exams->getExams()) { j=0; + lecturer = new QTableWidgetItem(); lecturer->setData(Qt::EditRole, tempExam->getLecturer()); + lecturer->setFlags(lecturer->flags() & ~Qt::ItemIsEditable); + name = new QTableWidgetItem(); name->setData(Qt::EditRole, tempExam->getName()); + name->setFlags(name->flags() & ~Qt::ItemIsEditable); + type = new QTableWidgetItem(); type->setData(Qt::EditRole, tempExam->getType()); + type->setFlags(type->flags() & ~Qt::ItemIsEditable); + serial = new QTableWidgetItem(); serial->setData(Qt::EditRole, tempExam->getSerialNum()); + serial->setFlags(serial->flags() & ~Qt::ItemIsEditable); + field = new QTableWidgetItem(); field->setData(Qt::EditRole, tempExam->getField()); - firstDate = new QDateEdit(); - firstDate->setDisplayFormat("d/M/yy"); - firstDate->setDate(tempExam->getFirstDate()); - secondDate = new QDateEdit(); - secondDate->setDisplayFormat("d/M/yy"); - secondDate->setDate(tempExam->getSecondDate()); - firstHourbegin = new QTimeEdit(); - firstHourbegin->setTime(tempExam->getFirstHourbegin()); - secondHourbegin = new QTimeEdit(); - secondHourbegin->setTime(tempExam->getSecondHourbegin()); + field->setFlags(field->flags() & ~Qt::ItemIsEditable); + + firstDate = new QTableWidgetItem(); + tempExam->getFirstDate().getDate(&year,&month,&day); + firstDate->setData(Qt::EditRole, QDate(year,month,day).toString("d/M/yy")); + firstDate->setFlags(firstDate->flags() & ~Qt::ItemIsEditable); + + secondDate = new QTableWidgetItem(); + tempExam->getSecondDate().getDate(&year,&month,&day); + secondDate->setData(Qt::EditRole, QDate(year,month,day).toString("d/M/yy")); + secondDate->setFlags(secondDate->flags() & ~Qt::ItemIsEditable); + + firstHourbegin = new QTableWidgetItem(); + firstHourbegin->setData(Qt::EditRole, QTime(tempExam->getFirstHourbegin().hour(),tempExam->getFirstHourbegin().minute()).toString("hh:mm")); + + secondHourbegin = new QTableWidgetItem(); + secondHourbegin->setData(Qt::EditRole, QTime(tempExam->getSecondHourbegin().hour(),tempExam->getSecondHourbegin().minute()).toString("hh:mm")); + - ui->tableWidget->setItem(i,j++,lecturer); - ui->tableWidget->setItem(i,j++,name); - ui->tableWidget->setItem(i,j++,type); ui->tableWidget->setItem(i,j++,serial); + ui->tableWidget->setItem(i,j++,name); + ui->tableWidget->setItem(i,j++,lecturer); ui->tableWidget->setItem(i,j++,field); - ui->tableWidget->setCellWidget(i,j++,firstDate); - ui->tableWidget->setCellWidget(i,j++,firstHourbegin); - ui->tableWidget->setCellWidget(i,j++,secondDate); - ui->tableWidget->setCellWidget(i,j++,secondHourbegin); + ui->tableWidget->setItem(i,j++,type); + ui->tableWidget->setItem(i,j++,firstDate); + ui->tableWidget->setItem(i,j++,firstHourbegin); + ui->tableWidget->setItem(i,j++,secondDate); + ui->tableWidget->setItem(i,j++,secondHourbegin); i++; } - ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); - ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); - - this->setMinimumHeight(ui->tableWidget->height()); - this->setMinimumWidth(ui->tableWidget->width()); + resetGeo(); + connect(ui->tableWidget,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(upgradeExamsTime(QTableWidgetItem*))); } examDialog::~examDialog() { delete ui; } + +/** + * @brief examDialog::upgradeExamsTime + * gets an item and check if its value is valid by time. + * currently we allow only modification of time + * + * @param item - tablewidet from ui->tablewidet. + * @return true if has been changed. false otherwise + */ +bool examDialog::upgradeExamsTime(QTableWidgetItem *item) +{ + QString text; + int row,col; + text = item->text(); + row = item->row(); + col = item->column(); + if (ui->tableWidget->item(row,calendarExamCourse::CourseScheme::SERIAL) == NULL) + return true; + + int serialCourse = ui->tableWidget->item(row,calendarExamCourse::CourseScheme::SERIAL)->text().toInt(); + for (calendarExamCourse * tempExam: exams->getExams()) + { + if (tempExam->getSerialNum() == serialCourse) + { + if (QTime::fromString(text).isValid()) + { + if (col == calendarExamCourse::CourseScheme::FIRST_HOUR_BEGIN) + tempExam->setFirstHourbegin(QTime::fromString(text)); + else if (col == calendarExamCourse::CourseScheme::SECOND_HOUR_BEGIN) + tempExam->setSecondHourbegin(QTime::fromString(text)); + else + qCritical() << Q_FUNC_INFO; //is doesnt need to get here. we allow modifications only at hours + return true; + } + else + { + if (col == calendarExamCourse::CourseScheme::FIRST_HOUR_BEGIN) + ui->tableWidget->item(row,col)->setData(Qt::EditRole, QTime(tempExam->getFirstHourbegin().hour(),tempExam->getFirstHourbegin().minute()).toString("hh:mm")); + else if (col == calendarExamCourse::CourseScheme::SECOND_HOUR_BEGIN) + ui->tableWidget->item(row,col)->setData(Qt::EditRole, QTime(tempExam->getSecondHourbegin().hour(),tempExam->getSecondHourbegin().minute()).toString("hh:mm")); + else + qCritical() << Q_FUNC_INFO; //is doesnt need to get here. we allow modifications only at hours + qWarning() << Q_FUNC_INFO << "missmatch data"; + QMessageBox::critical(this,tr("Error"),tr("Missmatching data.\nFormat: hh:mm\nIn Example: 08:25 or 12:05")); + return false; + } + } + } + return false; +} + +/** + * @brief examDialog::resetGeo + * Resizes Dialog according to widgets and table content + */ +void examDialog::resetGeo() +{ + + ui->tableWidget->resizeColumnsToContents(); + ui->tableWidget->resizeRowsToContents(); + + int mWidth=0,mHeight=0; + mHeight += ui->tableWidget->horizontalHeader()->height() + 4; + for (int i=0,j=0; i < ui->tableWidget->rowCount() && j < ui->tableWidget->columnCount();++i,++j) + { + mWidth += ui->tableWidget->columnWidth(j); + mHeight += ui->tableWidget->rowHeight(i) + 4; + + } + mHeight += ui->buttonBox->height() + 4; + mHeight += ui->labelHeader->height() + 4; + + + this->setMinimumHeight(mHeight); +// this->setMaximumHeight(mHeight); + +} diff --git a/src/jceData/Calendar/Exams/examDialog.h b/src/jceData/Calendar/Exams/examDialog.h index 24aef6b..04bc9d3 100644 --- a/src/jceData/Calendar/Exams/examDialog.h +++ b/src/jceData/Calendar/Exams/examDialog.h @@ -2,8 +2,10 @@ #define EXAMDIALOG_H #include -#include - +#include +#include +#include +#include #include "calendarExam.h" namespace Ui { @@ -29,7 +31,14 @@ public: void initializingDataIntoTable(); ~examDialog(); +private slots: + + bool upgradeExamsTime(QTableWidgetItem* item); + private: + + void resetGeo(); + Ui::examDialog *ui; calendarExam * exams; }; diff --git a/src/jceData/Calendar/Exams/examDialog.ui b/src/jceData/Calendar/Exams/examDialog.ui index c43802d..53829eb 100644 --- a/src/jceData/Calendar/Exams/examDialog.ui +++ b/src/jceData/Calendar/Exams/examDialog.ui @@ -7,7 +7,7 @@ 0 0 810 - 257 + 273 @@ -21,7 +21,7 @@ - + 0 @@ -34,7 +34,14 @@ - + + + + 0 + 0 + + + diff --git a/src/jceData/Calendar/coursesSchedule/calendarDialog.cpp b/src/jceData/Calendar/coursesSchedule/calendarDialog.cpp index 7a29c13..bf36e36 100644 --- a/src/jceData/Calendar/coursesSchedule/calendarDialog.cpp +++ b/src/jceData/Calendar/coursesSchedule/calendarDialog.cpp @@ -70,6 +70,7 @@ void CalendarDialog::on_calEnd_selectionChanged() { changeLabeStatusIcon(false); ui->lbl_status->setText(tr("The end of the semester can NOT be equal or before the semester begin.")); + this->isOK = false; } else diff --git a/src/jceData/Calendar/coursesSchedule/calendarDialog.ui b/src/jceData/Calendar/coursesSchedule/calendarDialog.ui index f78317d..863d278 100644 --- a/src/jceData/Calendar/coursesSchedule/calendarDialog.ui +++ b/src/jceData/Calendar/coursesSchedule/calendarDialog.ui @@ -6,177 +6,199 @@ 0 0 - 631 - 281 + 610 + 310 - + 0 0 + + + 0 + 0 + + Dates Dialog - - - - 10 - 10 - 613 - 263 - - - - - - - <body><p><span style=" font-size:9pt; font-weight:600;">The dates were chosen according to JCE General Academic Calendar for the first semester</span></p> - - - - - - - - - - - - - Semester Starts At: - - - - - - - Semester Ends At: - - - - - - - - - - - - - - Qt::ImhNone - - - - 2014 - 10 - 26 - - - - - 2000 - 9 - 14 - - - - - 2080 - 12 - 31 - - - - true - - - QCalendarWidget::NoVerticalHeader - - - - - - - - 2015 - 2 - 1 - - - - - 2000 - 9 - 14 - - - - - 2080 - 12 - 31 - - - - true - - - QCalendarWidget::NoVerticalHeader - - - - - - - - - - - - - - - - - - - - <b>Please chose your dates correctly</b> - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - + + + + + + + <html><head/><body><p align="center"><span style=" font-size:14pt; font-weight:600;">Schedule Exportation</span></p></body></html> + + + + + + + + + + + <html><head/><body><p align="center">Semester Starts At:</p></body></html> + + + + + + + + 0 + 0 + + + + Qt::ImhNone + + + + 2014 + 10 + 26 + + + + + 2000 + 9 + 14 + + + + + 2080 + 12 + 31 + + + + true + + + QCalendarWidget::NoVerticalHeader + + + + + + + + + + + <html><head/><body><p align="center">Semester Ends At:</p></body></html> + + + + + + + + 0 + 0 + + + + + 2015 + 2 + 1 + + + + + 2000 + 9 + 14 + + + + + 2080 + 12 + 31 + + + + true + + + QCalendarWidget::NoVerticalHeader + + + + + + + + + + + <html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">The dates were chosen according to JCE General Academic Calendar for the first semester</span></p></body></html> + + + + + + + + + + + + + + + + <b>Please chose your dates correctly</b> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Include Exams + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + +