fixed the null pointer error on csv exportion
This commit is contained in:
parent
13eef8a2ed
commit
c3345399f4
10 changed files with 116 additions and 116 deletions
134
jceGrade.pro
134
jceGrade.pro
|
@ -1,67 +1,67 @@
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
#
|
#
|
||||||
# Project created by QtCreator 2014-05-31T19:49:42
|
# Project created by QtCreator 2014-05-31T19:49:42
|
||||||
#
|
#
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui network widgets
|
QT += core gui network widgets
|
||||||
TARGET = jceGrade
|
TARGET = jceGrade
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
RC_FILE = appConfigure.rc
|
RC_FILE = appConfigure.rc
|
||||||
CONFIG += qt c++11
|
CONFIG += qt c++11
|
||||||
CONFIG += console static
|
CONFIG += console static
|
||||||
|
|
||||||
TRANSLATIONS = jce_en.ts \
|
TRANSLATIONS = jce_en.ts \
|
||||||
jce_he.ts
|
jce_he.ts
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
main/mainscreen.ui \
|
main/mainscreen.ui \
|
||||||
src/jceData/Calendar/calendardialog.ui
|
src/jceData/Calendar/calendarDialog.ui
|
||||||
|
|
||||||
OTHER_FILES +=
|
OTHER_FILES +=
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources/connectionstatus.qrc
|
resources/connectionstatus.qrc
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
main/CalendarTab/CalendarManager.h \
|
main/CalendarTab/CalendarManager.h \
|
||||||
main/CourseTab/coursestablemanager.h \
|
main/CourseTab/coursestablemanager.h \
|
||||||
main/LoginTab/loginhandler.h \
|
main/LoginTab/loginhandler.h \
|
||||||
main/mainscreen.h \
|
main/mainscreen.h \
|
||||||
src/appDatabase/savedata.h \
|
src/appDatabase/savedata.h \
|
||||||
src/jceConnection/jcesslclient.h \
|
src/jceConnection/jcesslclient.h \
|
||||||
src/jceData/Calendar/calendarPage.h \
|
src/jceData/Calendar/calendarPage.h \
|
||||||
src/jceData/Grades/gradeCourse.h \
|
src/jceData/Grades/gradeCourse.h \
|
||||||
src/jceData/Grades/gradePage.h \
|
src/jceData/Grades/gradePage.h \
|
||||||
src/jceData/course.h \
|
src/jceData/course.h \
|
||||||
src/jceData/page.h \
|
src/jceData/page.h \
|
||||||
src/jceSettings/jcelogin.h \
|
src/jceSettings/jcelogin.h \
|
||||||
src/jceSettings/jceLoginHtmlScripts.h \
|
src/jceSettings/jceLoginHtmlScripts.h \
|
||||||
src/jceSettings/user.h \
|
src/jceSettings/user.h \
|
||||||
src/jceData/Calendar/calendarCourse.h \
|
src/jceData/Calendar/calendarCourse.h \
|
||||||
src/jceData/Calendar/calendarSchedule.h \
|
src/jceData/Calendar/calendarSchedule.h \
|
||||||
src/jceData/CSV/csv_exporter.h \
|
src/jceData/CSV/csv_exporter.h \
|
||||||
src/appDatabase/simplecrypt.h \
|
src/appDatabase/simplecrypt.h \
|
||||||
src/jceData/Calendar/calendardialog.h
|
src/jceData/Calendar/calendarDialog.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main/CalendarTab/CalendarManager.cpp \
|
main/CalendarTab/CalendarManager.cpp \
|
||||||
main/CourseTab/coursestablemanager.cpp \
|
main/CourseTab/coursestablemanager.cpp \
|
||||||
main/LoginTab/loginhandler.cpp \
|
main/LoginTab/loginhandler.cpp \
|
||||||
main/main.cpp \
|
main/main.cpp \
|
||||||
main/mainscreen.cpp \
|
main/mainscreen.cpp \
|
||||||
src/appDatabase/savedata.cpp \
|
src/appDatabase/savedata.cpp \
|
||||||
src/jceConnection/jcesslclient.cpp \
|
src/jceConnection/jcesslclient.cpp \
|
||||||
src/jceData/Calendar/calendarPage.cpp \
|
src/jceData/Calendar/calendarPage.cpp \
|
||||||
src/jceData/Grades/gradeCourse.cpp \
|
src/jceData/Grades/gradeCourse.cpp \
|
||||||
src/jceData/Grades/gradePage.cpp \
|
src/jceData/Grades/gradePage.cpp \
|
||||||
src/jceData/page.cpp \
|
src/jceData/page.cpp \
|
||||||
src/jceSettings/jcelogin.cpp \
|
src/jceSettings/jcelogin.cpp \
|
||||||
src/jceSettings/user.cpp \
|
src/jceSettings/user.cpp \
|
||||||
src/jceData/Calendar/calendarCourse.cpp \
|
src/jceData/Calendar/calendarCourse.cpp \
|
||||||
src/jceData/Calendar/calendarSchedule.cpp \
|
src/jceData/Calendar/calendarSchedule.cpp \
|
||||||
src/jceData/CSV/csv_exporter.cpp \
|
src/jceData/CSV/csv_exporter.cpp \
|
||||||
src/appDatabase/simplecrypt.cpp \
|
src/appDatabase/simplecrypt.cpp \
|
||||||
src/jceData/Calendar/calendardialog.cpp
|
src/jceData/Calendar/calendarDialog.cpp
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,37 +10,30 @@ void CalendarManager::setCalendar(QString html)
|
||||||
{
|
{
|
||||||
caliSchedPtr->setPage(html);
|
caliSchedPtr->setPage(html);
|
||||||
}
|
}
|
||||||
bool CalendarManager::exportCalendarCSV() //need to add fix to the null pointer bug
|
void CalendarManager::exportCalendarCSV() //need to add fix to the null pointer bug
|
||||||
{
|
{
|
||||||
if (this->caliSchedPtr->getCourses()->empty())
|
qDebug() << this->caliSchedPtr->getCourses();
|
||||||
return false;
|
if (this->caliSchedPtr->getCourses() == NULL)
|
||||||
|
return;
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
int buttonClicked = caliDialog->exec();
|
int buttonClicked = caliDialog->exec();
|
||||||
if (buttonClicked == 0) //cancel?
|
if (buttonClicked == 0) //cancel?
|
||||||
return false;
|
return;
|
||||||
//calDialog.getStartDate(),calDialog.getEndDate()
|
//calDialog.getStartDate(),calDialog.getEndDate()
|
||||||
if(caliDialog->ok())
|
if (caliDialog->ok())
|
||||||
{
|
{
|
||||||
if(CSV_Exporter::exportCalendar(caliSchedPtr, caliDialog))
|
if (CSV_Exporter::exportCalendar(caliSchedPtr, caliDialog))
|
||||||
{
|
{
|
||||||
msgBox.setIcon(QMessageBox::Information);
|
msgBox.setIcon(QMessageBox::Information);
|
||||||
msgBox.setText(QObject::tr("Exported Successfuly!"));
|
msgBox.setText(QObject::tr("Exported Successfuly!"));
|
||||||
msgBox.exec();
|
|
||||||
return true;
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
|
||||||
msgBox.setText(QObject::tr("Error on exporting."));
|
|
||||||
msgBox.exec();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
msgBox.setText(QObject::tr("Dates not valid"));
|
msgBox.setText(QObject::tr("Dates not valid"));
|
||||||
msgBox.exec();
|
|
||||||
}
|
}
|
||||||
return false;
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
delete caliSchedPtr;
|
delete caliSchedPtr;
|
||||||
delete caliDialog;
|
delete caliDialog;
|
||||||
}
|
}
|
||||||
bool exportCalendarCSV();
|
void exportCalendarCSV();
|
||||||
void setCalendar(QString html);
|
void setCalendar(QString html);
|
||||||
void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); }
|
void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); }
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,6 @@ void MainScreen::uiSetConnectMode()
|
||||||
ui->CoursesTab->setEnabled(true);
|
ui->CoursesTab->setEnabled(true);
|
||||||
ui->exportToCVSBtn->setEnabled(true);
|
ui->exportToCVSBtn->setEnabled(true);
|
||||||
ui->getCalendarBtn->setEnabled(true);
|
ui->getCalendarBtn->setEnabled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -277,10 +276,8 @@ void MainScreen::on_exportToCVSBtn_clicked()
|
||||||
{
|
{
|
||||||
if (loginHandel->isLoggedInFlag())
|
if (loginHandel->isLoggedInFlag())
|
||||||
{
|
{
|
||||||
if(!this->calendar->exportCalendarCSV())
|
this->calendar->exportCalendarCSV();
|
||||||
{
|
|
||||||
QMessageBox::critical(this,tr("Error"),"No Calendar was loaded."); //Need Translation
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ void jceSSLClient::showIfErrorMsg()
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::SocketTimeoutError:
|
case QAbstractSocket::SocketError::SocketTimeoutError:
|
||||||
errorString = QObject::tr("SocketTimeoutError");
|
errorString = QObject::tr("SocketTimeoutError");
|
||||||
if (isConnected())
|
if (!isConnected())
|
||||||
relevantError = true;
|
relevantError = true;
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::DatagramTooLargeError:
|
case QAbstractSocket::SocketError::DatagramTooLargeError:
|
||||||
|
|
|
@ -7,11 +7,15 @@ CSV_Exporter::CSV_Exporter()
|
||||||
|
|
||||||
bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *cal)
|
bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *cal)
|
||||||
{
|
{
|
||||||
if ((cal == NULL) || (calSched == NULL) || (calSched->getCourses() == NULL)) //pointers checking!
|
if ((cal == NULL) || (calSched == NULL)) //pointers checking!
|
||||||
return false;
|
return false;
|
||||||
|
if (calSched->getCourses() == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
qDebug() << "Getting path for csv file from user...";
|
qDebug() << "Getting path for csv file from user...";
|
||||||
QString filePath = getFileFath();
|
QString filePath = getFileFath();
|
||||||
if(filePath == NULL) //User canceled
|
if (filePath == NULL) //User canceled
|
||||||
{
|
{
|
||||||
qDebug() << "User pressed Cancel... returning false";
|
qDebug() << "User pressed Cancel... returning false";
|
||||||
return false;
|
return false;
|
||||||
|
@ -20,7 +24,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
||||||
qDebug() << "Atempting to export the Schedule...";
|
qDebug() << "Atempting to export the Schedule...";
|
||||||
|
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
if(!file.open(QIODevice::ReadWrite | QIODevice::Text |QIODevice::Truncate))
|
if (!file.open(QIODevice::ReadWrite | QIODevice::Text |QIODevice::Truncate))
|
||||||
{
|
{
|
||||||
qDebug() << "unable to open/create the file... maybe permissions error.";
|
qDebug() << "unable to open/create the file... maybe permissions error.";
|
||||||
return false;
|
return false;
|
||||||
|
@ -45,7 +49,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
||||||
|
|
||||||
currentDate = currentDate.addDays(day-1);
|
currentDate = currentDate.addDays(day-1);
|
||||||
|
|
||||||
for(;currentDate <= cal->getEndDate(); currentDate = currentDate.addDays(7))
|
for (;currentDate <= cal->getEndDate(); currentDate = currentDate.addDays(7))
|
||||||
{
|
{
|
||||||
QString line = makeLine(name, ¤tDate, startH, startM, endH, endM, lecturer, room, type);
|
QString line = makeLine(name, ¤tDate, startH, startM, endH, endM, lecturer, room, type);
|
||||||
#ifdef Q_OS_LINUX || Q_OS_UNIX
|
#ifdef Q_OS_LINUX || Q_OS_UNIX
|
||||||
|
@ -74,9 +78,9 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
||||||
QString CSV_Exporter::getFileFath()
|
QString CSV_Exporter::getFileFath()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName();
|
QString fileName = QFileDialog::getSaveFileName();
|
||||||
if(fileName == "")
|
if (fileName == "")
|
||||||
return NULL;
|
return NULL;
|
||||||
if(!fileName.contains(".csv", Qt::CaseInsensitive))
|
if (!fileName.contains(".csv", Qt::CaseInsensitive))
|
||||||
fileName.append(".csv");
|
fileName.append(".csv");
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,30 +8,34 @@ calendarCourse::calendarCourse(int serial, QString name, QString type, QString l
|
||||||
this->semesterHours = semesterHours;
|
this->semesterHours = semesterHours;
|
||||||
this->room = room;
|
this->room = room;
|
||||||
setDayAndHour(dayAndHour);
|
setDayAndHour(dayAndHour);
|
||||||
|
|
||||||
}
|
}
|
||||||
void calendarCourse::setDayAndHour(QString phrase)
|
/**
|
||||||
|
* @brief calendarCourse::setDayAndHour
|
||||||
|
* given a string of time and day - parsing it into day, hour it begins and hour it ends seperated
|
||||||
|
* @param parse -
|
||||||
|
*/
|
||||||
|
void calendarCourse::setDayAndHour(QString parse)
|
||||||
{
|
{
|
||||||
int ctr = 0;
|
int ctr = 0;
|
||||||
QString temp = "";
|
QString temp = "";
|
||||||
QTime timetemp;
|
QTime timetemp;
|
||||||
char *tok;
|
char *tok;
|
||||||
char* textToTok = strdup(phrase.toStdString().c_str());
|
char* textToTok = strdup(parse.toStdString().c_str());
|
||||||
tok = strtok(textToTok, " -");
|
tok = strtok(textToTok, " -");
|
||||||
while(tok != NULL)
|
while(tok != NULL)
|
||||||
{
|
{
|
||||||
temp = tok;
|
temp = tok;
|
||||||
switch (ctr)
|
switch (ctr)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: //day
|
||||||
setDay(temp);
|
setDay(temp);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: //hour it begins
|
||||||
timetemp = QTime::fromString(temp,"hh:mm");
|
timetemp = QTime::fromString(temp,"hh:mm");
|
||||||
setHourBegin(timetemp.hour());
|
setHourBegin(timetemp.hour());
|
||||||
setMinutesBegin(timetemp.minute());
|
setMinutesBegin(timetemp.minute());
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2: //hour it ends
|
||||||
timetemp = QTime::fromString(temp,"hh:mm");
|
timetemp = QTime::fromString(temp,"hh:mm");
|
||||||
setHourEnd(timetemp.hour());
|
setHourEnd(timetemp.hour());
|
||||||
setMinutesEnd(timetemp.minute());
|
setMinutesEnd(timetemp.minute());
|
||||||
|
@ -97,7 +101,10 @@ void calendarCourse::setMinutesEnd(int value)
|
||||||
{
|
{
|
||||||
minutesEnd = value;
|
minutesEnd = value;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief calendarCourse::courseToString
|
||||||
|
* @return prints the course into string pattern
|
||||||
|
*/
|
||||||
QString calendarCourse::courseToString()
|
QString calendarCourse::courseToString()
|
||||||
{
|
{
|
||||||
QString courseText = "";
|
QString courseText = "";
|
||||||
|
@ -118,7 +125,11 @@ int calendarCourse::getDay() const
|
||||||
{
|
{
|
||||||
return day;
|
return day;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief calendarCourse::setDay
|
||||||
|
* translating a day that written with hebrew unicode character to an integer
|
||||||
|
* @param value - contains the day in unicode
|
||||||
|
*/
|
||||||
void calendarCourse::setDay(const QString &value)
|
void calendarCourse::setDay(const QString &value)
|
||||||
{
|
{
|
||||||
std::string dayTemp = value.toStdString().substr(0,2); //recieving two characters respresting days
|
std::string dayTemp = value.toStdString().substr(0,2); //recieving two characters respresting days
|
||||||
|
@ -137,7 +148,6 @@ void calendarCourse::setDay(const QString &value)
|
||||||
else
|
else
|
||||||
day= -1;
|
day= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString calendarCourse::getRoom() const
|
QString calendarCourse::getRoom() const
|
||||||
{
|
{
|
||||||
return room;
|
return room;
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
#define CALENDARCOURSE_H
|
#define CALENDARCOURSE_H
|
||||||
|
|
||||||
#include "../course.h"
|
#include "../course.h"
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
|
||||||
#define CALENDAR_COURSE_FIELDS 8
|
#define CALENDAR_COURSE_FIELDS 8
|
||||||
|
@ -51,7 +47,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void setDayAndHour(QString phrase);
|
void setDayAndHour(QString parse);
|
||||||
|
|
||||||
QString lecturer;
|
QString lecturer;
|
||||||
double semesterHours;
|
double semesterHours;
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setPage(QString html);
|
virtual void setPage(QString html);
|
||||||
CalendarPage() { }
|
CalendarPage() { courses = NULL; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "calendardialog.h"
|
#include "calendarDialog.h"
|
||||||
#include "ui_calendardialog.h"
|
#include "ui_calenDardialog.h"
|
||||||
|
|
||||||
|
|
||||||
CalendarDialog::CalendarDialog(QWidget *parent) :
|
CalendarDialog::CalendarDialog(QWidget *parent) :
|
||||||
|
@ -35,7 +35,7 @@ void CalendarDialog::on_calStart_selectionChanged()
|
||||||
if(ui->calStart->selectedDate() >= ui->calEnd->selectedDate())
|
if(ui->calStart->selectedDate() >= ui->calEnd->selectedDate())
|
||||||
{
|
{
|
||||||
changeLabeStatusIcon(false);
|
changeLabeStatusIcon(false);
|
||||||
ui->lbl_status->setText(tr("The End of the semester can NOT be equal or before semester begins."));
|
ui->lbl_status->setText(tr("The end of the semester can NOT be equal or before the semester begin."));
|
||||||
this->isOK = false;
|
this->isOK = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -49,7 +49,7 @@ void CalendarDialog::on_calStart_selectionChanged()
|
||||||
void CalendarDialog::on_buttonBox_accepted()
|
void CalendarDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
if(ui->calStart->selectedDate() > ui->calEnd->selectedDate())
|
if(ui->calStart->selectedDate() > ui->calEnd->selectedDate())
|
||||||
qDebug() << "start bigger than end!";
|
qDebug() << "start is bigger than end!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarDialog::on_calEnd_selectionChanged()
|
void CalendarDialog::on_calEnd_selectionChanged()
|
||||||
|
@ -57,7 +57,7 @@ void CalendarDialog::on_calEnd_selectionChanged()
|
||||||
if(ui->calStart->selectedDate() >= ui->calEnd->selectedDate())
|
if(ui->calStart->selectedDate() >= ui->calEnd->selectedDate())
|
||||||
{
|
{
|
||||||
changeLabeStatusIcon(false);
|
changeLabeStatusIcon(false);
|
||||||
ui->lbl_status->setText(tr("The End of the semester can NOT be equal or before semester begins."));
|
ui->lbl_status->setText(tr("The end of the semester can NOT be equal or before semester begins."));
|
||||||
this->isOK = false;
|
this->isOK = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue