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
This commit is contained in:
parent
845bfbdafb
commit
e6e7557a31
8 changed files with 77 additions and 39 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -658,9 +658,9 @@ font-size: 15px;
|
|||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>200</horstretch>
|
||||
<verstretch>200</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
#include "../page.h"
|
||||
#include "calendarCourse.h"
|
||||
#include <list>
|
||||
//#include <string.h> //strlen and strtok to phrase the html file
|
||||
//#include <ctype.h> //checks if character is numeric
|
||||
|
||||
#define ROOM_DEFAULT_STRING "nullRoom"
|
||||
#define LECTURER_DEFAULT_STRING "nullLecturer"
|
||||
|
||||
class CalendarPage : public Page
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
#define CALENDARSCHEDULE_H
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <QHeaderView>
|
||||
#include <QTextStream>
|
||||
#include <iostream>
|
||||
|
||||
#include "calendarPage.h"
|
||||
#include <iostream>
|
||||
#include <QHeaderView>
|
||||
|
||||
|
||||
#define HOURS_BEGIN 8
|
||||
#define HOURS_END 20
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue