From e6e7557a31dbbea38203f96a37a2d5b0f4b2695e Mon Sep 17 00:00:00 2001 From: liranbg Date: Tue, 23 Sep 2014 04:15:38 +0300 Subject: [PATCH] fix #17 default room\lecturer strings also fixed an huge bug i found! (couldnt export calendar if there were courses over 17 pm!) i also used trimming function to avoid empty spaces in data --- main/mainscreen.cpp | 2 +- main/mainscreen.ui | 6 ++-- src/jceData/CSV/csv_exporter.cpp | 36 +++++++++++++++-------- src/jceData/Calendar/calendarPage.cpp | 29 +++++++++++++----- src/jceData/Calendar/calendarPage.h | 5 ++-- src/jceData/Calendar/calendarSchedule.cpp | 29 +++++++++++++----- src/jceData/Calendar/calendarSchedule.h | 5 ++-- src/jceData/Grades/gradePage.cpp | 4 +-- 8 files changed, 77 insertions(+), 39 deletions(-) diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index f249830..6962b0a 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -98,7 +98,7 @@ void MainScreen::on_loginButton_clicked() } else { - qDebug() << Q_FUNC_INFO << "login session end with end"; + qDebug() << Q_FUNC_INFO << "login session end with false"; ui->pswdLineEdit->setDisabled(false); ui->usrnmLineEdit->setDisabled(false); diff --git a/main/mainscreen.ui b/main/mainscreen.ui index 60f58d6..26b8404 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -658,9 +658,9 @@ font-size: 15px; - - 0 - 0 + + 200 + 200 diff --git a/src/jceData/CSV/csv_exporter.cpp b/src/jceData/CSV/csv_exporter.cpp index 375321d..a5fb2ef 100644 --- a/src/jceData/CSV/csv_exporter.cpp +++ b/src/jceData/CSV/csv_exporter.cpp @@ -5,8 +5,6 @@ * Class doc can be bound in csv_exporter.h * */ - - CSV_Exporter::CSV_Exporter() { /* EMPTY - NO NEED */ @@ -28,16 +26,16 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca if (calSched->getCourses() == NULL) return false; - qDebug() << "Getting path for csv file from user..."; + qDebug() << Q_FUNC_INFO << "Getting path for csv file from user..."; QString filePath = getFileFath(); if(filePath == NULL) //User canceled from the file explorer popup { - qDebug() << "CSV : User pressed Cancel... returning false"; + qDebug() << Q_FUNC_INFO << "CSV : User pressed Cancel... returning false"; return false; } - qDebug() << "CSV : User Chose: " << filePath; - qDebug() << "CSV : Atempting to export the Schedule..."; + qDebug() << Q_FUNC_INFO << "CSV : User Chose: " << filePath; + qDebug() << Q_FUNC_INFO << "CSV : Atempting to export the Schedule..."; QFile file(filePath); if(!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) //Incase unable to open the file (binary mode - \n will not be converted on "Windows") @@ -46,7 +44,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca msgBox.setIcon(QMessageBox::Critical); msgBox.setText(QObject::tr("Unable to open or create the file.\nExporting Failed")); msgBox.exec(); - qCritical() << "unable to open/create the file... maybe permissions error."; + qCritical() << Q_FUNC_INFO << "unable to open/create the file... maybe permissions error."; return false; } @@ -94,14 +92,14 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca if(line != NULL) out << line << char(0x0A); else - qWarning() << "CSV : Got A NULL in Line! in function: " << Q_FUNC_INFO; + qWarning() << Q_FUNC_INFO << "CSV : Got A NULL in Line! in function: " << Q_FUNC_INFO; } out.flush(); } file.close(); - qDebug() << "CSV : Exported Successfully"; + qDebug() << Q_FUNC_INFO << "CSV : Exported Successfully"; return true; } @@ -152,7 +150,7 @@ QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM QString start; start.append(QString::number(startH)); start.append(":00"); - //start.append(QString::number(startM)); +// start.append(QString::number(startM)); start.append(":00"); QString end; @@ -162,10 +160,22 @@ QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM end.append(":00"); QString description = "\"מרצה "; - description.append(lecturer); + + if (lecturer == LECTURER_DEFAULT_STRING) + description.append("טרם נקבע מרצה או מתרגל"); + else + description.append(lecturer); + description.append("\n"); - description.append(" ב"); - description.append(room); + + if (room == ROOM_DEFAULT_STRING) + description.append("טרם נקבע מיקום"); + else + { + description.append(" ב"); + description.append(room); + } + description.append("\n Created with JCE Manager.\""); //Create the Fucking Line diff --git a/src/jceData/Calendar/calendarPage.cpp b/src/jceData/Calendar/calendarPage.cpp index b4b65c9..4084545 100644 --- a/src/jceData/Calendar/calendarPage.cpp +++ b/src/jceData/Calendar/calendarPage.cpp @@ -73,10 +73,13 @@ calendarCourse *CalendarPage::lineToCourse(QString line) tok = strtok(cLine, "\t"); while(tok != NULL) { - tempS = QString(tok); - if (i>=1) - templinearray[i-1] = tempS; + + if (i >= 1) + { + templinearray[i-1] = tempS.trimmed(); + } + i++; if (i > 8) break; @@ -84,22 +87,32 @@ calendarCourse *CalendarPage::lineToCourse(QString line) } if (templinearray[0] == "") //empty parsing return NULL; + serial = templinearray[calendarCourse::CourseScheme::SERIAL].toInt(); name = templinearray[calendarCourse::CourseScheme::NAME]; type = templinearray[calendarCourse::CourseScheme::TYPE]; - lecturer = templinearray[calendarCourse::CourseScheme::LECTURER]; - if (templinearray[calendarCourse::CourseScheme::POINTS].compare(" ") == 0) + + if (!templinearray[calendarCourse::CourseScheme::LECTURER].isEmpty()) + lecturer = templinearray[calendarCourse::CourseScheme::LECTURER]; + else + lecturer = LECTURER_DEFAULT_STRING; + + if (!templinearray[calendarCourse::CourseScheme::POINTS].isEmpty()) points = templinearray[calendarCourse::CourseScheme::POINTS].toDouble(); else points = 0; - if (templinearray[calendarCourse::CourseScheme::SEM_HOURS].compare(" ") == 0) + if (!templinearray[calendarCourse::CourseScheme::SEM_HOURS].isEmpty()) semesterHours = templinearray[calendarCourse::CourseScheme::SEM_HOURS].toDouble(); else semesterHours = 0; - dayAndHour = templinearray[calendarCourse::CourseScheme::DAY_AND_HOURS]; - room = templinearray[calendarCourse::CourseScheme::ROOM]; + dayAndHour = templinearray[calendarCourse::CourseScheme::DAY_AND_HOURS]; + + if (!templinearray[calendarCourse::CourseScheme::ROOM].isEmpty()) + room = templinearray[calendarCourse::CourseScheme::ROOM]; + else + room = ROOM_DEFAULT_STRING; tempC = new calendarCourse(serial,name,type,lecturer,points,semesterHours,dayAndHour,room); diff --git a/src/jceData/Calendar/calendarPage.h b/src/jceData/Calendar/calendarPage.h index 5ee4721..c68fcba 100644 --- a/src/jceData/Calendar/calendarPage.h +++ b/src/jceData/Calendar/calendarPage.h @@ -4,8 +4,9 @@ #include "../page.h" #include "calendarCourse.h" #include -//#include //strlen and strtok to phrase the html file -//#include //checks if character is numeric + +#define ROOM_DEFAULT_STRING "nullRoom" +#define LECTURER_DEFAULT_STRING "nullLecturer" class CalendarPage : public Page { diff --git a/src/jceData/Calendar/calendarSchedule.cpp b/src/jceData/Calendar/calendarSchedule.cpp index 7810201..98f8421 100644 --- a/src/jceData/Calendar/calendarSchedule.cpp +++ b/src/jceData/Calendar/calendarSchedule.cpp @@ -48,8 +48,8 @@ void calendarSchedule::clearTableItems() for (j = 0; j < columnCount(); j++) if (this->takeItem(i,j) != NULL) delete this->takeItem(i,j); - horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); + horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); } void calendarSchedule::insertCourseIntoTable() @@ -64,12 +64,24 @@ void calendarSchedule::insertCourseIntoTable() courseString = ""; currentHour = coursePtr->getHourBegin(); currentDay = coursePtr->getDay(); - blocksNumer = coursePtr->getHourEnd() - coursePtr->getHourBegin(); + blocksNumer = coursePtr->getHourEnd() - coursePtr->getHourBegin(); //every hour is a block to fill! while (blocksNumer >= 0) { - row = currentHour % HOURS_BEGIN; + row = currentHour - HOURS_BEGIN; col = currentDay-1; - courseString = (QString(coursePtr->getName() + " \n" + coursePtr->getLecturer() + " \n" + coursePtr->getRoom())); + courseString = QString(coursePtr->getName() + "\n"); + + if (coursePtr->getLecturer() != LECTURER_DEFAULT_STRING) + courseString += coursePtr->getLecturer() + "\n"; + else + courseString += QString("טרם נקבע מרצה או מתרגל\n"); + + if (coursePtr->getRoom() != ROOM_DEFAULT_STRING) + courseString += coursePtr->getRoom(); + else + courseString += QString("טרם נקבעה כיתה"); + + item = new QTableWidgetItem(courseString); if (this->takeItem(row,col) != NULL) delete this->takeItem(row,col); @@ -78,9 +90,12 @@ void calendarSchedule::insertCourseIntoTable() currentHour++; --blocksNumer; } + horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); } - horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); - verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + + horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); + verticalHeader()->setSectionResizeMode(QHeaderView::Interactive); } diff --git a/src/jceData/Calendar/calendarSchedule.h b/src/jceData/Calendar/calendarSchedule.h index d759753..14749cd 100644 --- a/src/jceData/Calendar/calendarSchedule.h +++ b/src/jceData/Calendar/calendarSchedule.h @@ -2,12 +2,11 @@ #define CALENDARSCHEDULE_H #include +#include #include -#include #include "calendarPage.h" -#include -#include + #define HOURS_BEGIN 8 #define HOURS_END 20 diff --git a/src/jceData/Grades/gradePage.cpp b/src/jceData/Grades/gradePage.cpp index 979c7d2..1dffbf6 100644 --- a/src/jceData/Grades/gradePage.cpp +++ b/src/jceData/Grades/gradePage.cpp @@ -100,8 +100,8 @@ gradeCourse* GradePage::lineToCourse(QString line) tempS += QString(*tokTemp); tokTemp++; } - templinearray[i-1] = tempS; - templinearray[i] = QString(tokTemp); + templinearray[i-1] = tempS.trimmed(); + templinearray[i] = QString(tokTemp).trimmed(); } else if (i > 1)