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
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui network widgets
|
||||
TARGET = jceGrade
|
||||
TEMPLATE = app
|
||||
RC_FILE = appConfigure.rc
|
||||
CONFIG += qt c++11
|
||||
CONFIG += console static
|
||||
|
||||
TRANSLATIONS = jce_en.ts \
|
||||
jce_he.ts
|
||||
|
||||
FORMS += \
|
||||
main/mainscreen.ui \
|
||||
src/jceData/Calendar/calendardialog.ui
|
||||
|
||||
OTHER_FILES +=
|
||||
|
||||
RESOURCES += \
|
||||
resources/connectionstatus.qrc
|
||||
|
||||
HEADERS += \
|
||||
main/CalendarTab/CalendarManager.h \
|
||||
main/CourseTab/coursestablemanager.h \
|
||||
main/LoginTab/loginhandler.h \
|
||||
main/mainscreen.h \
|
||||
src/appDatabase/savedata.h \
|
||||
src/jceConnection/jcesslclient.h \
|
||||
src/jceData/Calendar/calendarPage.h \
|
||||
src/jceData/Grades/gradeCourse.h \
|
||||
src/jceData/Grades/gradePage.h \
|
||||
src/jceData/course.h \
|
||||
src/jceData/page.h \
|
||||
src/jceSettings/jcelogin.h \
|
||||
src/jceSettings/jceLoginHtmlScripts.h \
|
||||
src/jceSettings/user.h \
|
||||
src/jceData/Calendar/calendarCourse.h \
|
||||
src/jceData/Calendar/calendarSchedule.h \
|
||||
src/jceData/CSV/csv_exporter.h \
|
||||
src/appDatabase/simplecrypt.h \
|
||||
src/jceData/Calendar/calendardialog.h
|
||||
|
||||
SOURCES += \
|
||||
main/CalendarTab/CalendarManager.cpp \
|
||||
main/CourseTab/coursestablemanager.cpp \
|
||||
main/LoginTab/loginhandler.cpp \
|
||||
main/main.cpp \
|
||||
main/mainscreen.cpp \
|
||||
src/appDatabase/savedata.cpp \
|
||||
src/jceConnection/jcesslclient.cpp \
|
||||
src/jceData/Calendar/calendarPage.cpp \
|
||||
src/jceData/Grades/gradeCourse.cpp \
|
||||
src/jceData/Grades/gradePage.cpp \
|
||||
src/jceData/page.cpp \
|
||||
src/jceSettings/jcelogin.cpp \
|
||||
src/jceSettings/user.cpp \
|
||||
src/jceData/Calendar/calendarCourse.cpp \
|
||||
src/jceData/Calendar/calendarSchedule.cpp \
|
||||
src/jceData/CSV/csv_exporter.cpp \
|
||||
src/appDatabase/simplecrypt.cpp \
|
||||
src/jceData/Calendar/calendardialog.cpp
|
||||
|
||||
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2014-05-31T19:49:42
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui network widgets
|
||||
TARGET = jceGrade
|
||||
TEMPLATE = app
|
||||
RC_FILE = appConfigure.rc
|
||||
CONFIG += qt c++11
|
||||
CONFIG += console static
|
||||
|
||||
TRANSLATIONS = jce_en.ts \
|
||||
jce_he.ts
|
||||
|
||||
FORMS += \
|
||||
main/mainscreen.ui \
|
||||
src/jceData/Calendar/calendarDialog.ui
|
||||
|
||||
OTHER_FILES +=
|
||||
|
||||
RESOURCES += \
|
||||
resources/connectionstatus.qrc
|
||||
|
||||
HEADERS += \
|
||||
main/CalendarTab/CalendarManager.h \
|
||||
main/CourseTab/coursestablemanager.h \
|
||||
main/LoginTab/loginhandler.h \
|
||||
main/mainscreen.h \
|
||||
src/appDatabase/savedata.h \
|
||||
src/jceConnection/jcesslclient.h \
|
||||
src/jceData/Calendar/calendarPage.h \
|
||||
src/jceData/Grades/gradeCourse.h \
|
||||
src/jceData/Grades/gradePage.h \
|
||||
src/jceData/course.h \
|
||||
src/jceData/page.h \
|
||||
src/jceSettings/jcelogin.h \
|
||||
src/jceSettings/jceLoginHtmlScripts.h \
|
||||
src/jceSettings/user.h \
|
||||
src/jceData/Calendar/calendarCourse.h \
|
||||
src/jceData/Calendar/calendarSchedule.h \
|
||||
src/jceData/CSV/csv_exporter.h \
|
||||
src/appDatabase/simplecrypt.h \
|
||||
src/jceData/Calendar/calendarDialog.h
|
||||
|
||||
SOURCES += \
|
||||
main/CalendarTab/CalendarManager.cpp \
|
||||
main/CourseTab/coursestablemanager.cpp \
|
||||
main/LoginTab/loginhandler.cpp \
|
||||
main/main.cpp \
|
||||
main/mainscreen.cpp \
|
||||
src/appDatabase/savedata.cpp \
|
||||
src/jceConnection/jcesslclient.cpp \
|
||||
src/jceData/Calendar/calendarPage.cpp \
|
||||
src/jceData/Grades/gradeCourse.cpp \
|
||||
src/jceData/Grades/gradePage.cpp \
|
||||
src/jceData/page.cpp \
|
||||
src/jceSettings/jcelogin.cpp \
|
||||
src/jceSettings/user.cpp \
|
||||
src/jceData/Calendar/calendarCourse.cpp \
|
||||
src/jceData/Calendar/calendarSchedule.cpp \
|
||||
src/jceData/CSV/csv_exporter.cpp \
|
||||
src/appDatabase/simplecrypt.cpp \
|
||||
src/jceData/Calendar/calendarDialog.cpp
|
||||
|
||||
|
||||
|
|
|
@ -10,37 +10,30 @@ void CalendarManager::setCalendar(QString 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())
|
||||
return false;
|
||||
qDebug() << this->caliSchedPtr->getCourses();
|
||||
if (this->caliSchedPtr->getCourses() == NULL)
|
||||
return;
|
||||
QMessageBox msgBox;
|
||||
int buttonClicked = caliDialog->exec();
|
||||
if (buttonClicked == 0) //cancel?
|
||||
return false;
|
||||
return;
|
||||
//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.setText(QObject::tr("Exported Successfuly!"));
|
||||
msgBox.exec();
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setText(QObject::tr("Error on exporting."));
|
||||
msgBox.exec();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setText(QObject::tr("Dates not valid"));
|
||||
msgBox.exec();
|
||||
msgBox.setText(QObject::tr("Dates not valid"));
|
||||
}
|
||||
return false;
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
delete caliSchedPtr;
|
||||
delete caliDialog;
|
||||
}
|
||||
bool exportCalendarCSV();
|
||||
void exportCalendarCSV();
|
||||
void setCalendar(QString html);
|
||||
void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); }
|
||||
|
||||
|
|
|
@ -170,7 +170,6 @@ void MainScreen::uiSetConnectMode()
|
|||
ui->CoursesTab->setEnabled(true);
|
||||
ui->exportToCVSBtn->setEnabled(true);
|
||||
ui->getCalendarBtn->setEnabled(true);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -277,10 +276,8 @@ void MainScreen::on_exportToCVSBtn_clicked()
|
|||
{
|
||||
if (loginHandel->isLoggedInFlag())
|
||||
{
|
||||
if(!this->calendar->exportCalendarCSV())
|
||||
{
|
||||
QMessageBox::critical(this,tr("Error"),"No Calendar was loaded."); //Need Translation
|
||||
}
|
||||
this->calendar->exportCalendarCSV();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -240,7 +240,7 @@ void jceSSLClient::showIfErrorMsg()
|
|||
break;
|
||||
case QAbstractSocket::SocketError::SocketTimeoutError:
|
||||
errorString = QObject::tr("SocketTimeoutError");
|
||||
if (isConnected())
|
||||
if (!isConnected())
|
||||
relevantError = true;
|
||||
break;
|
||||
case QAbstractSocket::SocketError::DatagramTooLargeError:
|
||||
|
|
|
@ -7,11 +7,15 @@ CSV_Exporter::CSV_Exporter()
|
|||
|
||||
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;
|
||||
if (calSched->getCourses() == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
qDebug() << "Getting path for csv file from user...";
|
||||
QString filePath = getFileFath();
|
||||
if(filePath == NULL) //User canceled
|
||||
if (filePath == NULL) //User canceled
|
||||
{
|
||||
qDebug() << "User pressed Cancel... returning false";
|
||||
return false;
|
||||
|
@ -20,7 +24,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
|||
qDebug() << "Atempting to export the Schedule...";
|
||||
|
||||
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.";
|
||||
return false;
|
||||
|
@ -45,7 +49,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
|||
|
||||
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);
|
||||
#ifdef Q_OS_LINUX || Q_OS_UNIX
|
||||
|
@ -74,9 +78,9 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
|||
QString CSV_Exporter::getFileFath()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName();
|
||||
if(fileName == "")
|
||||
if (fileName == "")
|
||||
return NULL;
|
||||
if(!fileName.contains(".csv", Qt::CaseInsensitive))
|
||||
if (!fileName.contains(".csv", Qt::CaseInsensitive))
|
||||
fileName.append(".csv");
|
||||
return fileName;
|
||||
}
|
||||
|
|
|
@ -8,30 +8,34 @@ calendarCourse::calendarCourse(int serial, QString name, QString type, QString l
|
|||
this->semesterHours = semesterHours;
|
||||
this->room = room;
|
||||
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;
|
||||
QString temp = "";
|
||||
QTime timetemp;
|
||||
char *tok;
|
||||
char* textToTok = strdup(phrase.toStdString().c_str());
|
||||
char* textToTok = strdup(parse.toStdString().c_str());
|
||||
tok = strtok(textToTok, " -");
|
||||
while(tok != NULL)
|
||||
{
|
||||
temp = tok;
|
||||
switch (ctr)
|
||||
{
|
||||
case 0:
|
||||
case 0: //day
|
||||
setDay(temp);
|
||||
break;
|
||||
case 1:
|
||||
case 1: //hour it begins
|
||||
timetemp = QTime::fromString(temp,"hh:mm");
|
||||
setHourBegin(timetemp.hour());
|
||||
setMinutesBegin(timetemp.minute());
|
||||
break;
|
||||
case 2:
|
||||
case 2: //hour it ends
|
||||
timetemp = QTime::fromString(temp,"hh:mm");
|
||||
setHourEnd(timetemp.hour());
|
||||
setMinutesEnd(timetemp.minute());
|
||||
|
@ -97,7 +101,10 @@ void calendarCourse::setMinutesEnd(int value)
|
|||
{
|
||||
minutesEnd = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief calendarCourse::courseToString
|
||||
* @return prints the course into string pattern
|
||||
*/
|
||||
QString calendarCourse::courseToString()
|
||||
{
|
||||
QString courseText = "";
|
||||
|
@ -118,7 +125,11 @@ int calendarCourse::getDay() const
|
|||
{
|
||||
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)
|
||||
{
|
||||
std::string dayTemp = value.toStdString().substr(0,2); //recieving two characters respresting days
|
||||
|
@ -137,7 +148,6 @@ void calendarCourse::setDay(const QString &value)
|
|||
else
|
||||
day= -1;
|
||||
}
|
||||
|
||||
QString calendarCourse::getRoom() const
|
||||
{
|
||||
return room;
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
#define CALENDARCOURSE_H
|
||||
|
||||
#include "../course.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
#include <QTime>
|
||||
|
||||
#define CALENDAR_COURSE_FIELDS 8
|
||||
|
@ -51,7 +47,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
void setDayAndHour(QString phrase);
|
||||
void setDayAndHour(QString parse);
|
||||
|
||||
QString lecturer;
|
||||
double semesterHours;
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void setPage(QString html);
|
||||
CalendarPage() { }
|
||||
CalendarPage() { courses = NULL; }
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "calendardialog.h"
|
||||
#include "ui_calendardialog.h"
|
||||
#include "calendarDialog.h"
|
||||
#include "ui_calenDardialog.h"
|
||||
|
||||
|
||||
CalendarDialog::CalendarDialog(QWidget *parent) :
|
||||
|
@ -35,7 +35,7 @@ void CalendarDialog::on_calStart_selectionChanged()
|
|||
if(ui->calStart->selectedDate() >= ui->calEnd->selectedDate())
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
@ -49,7 +49,7 @@ void CalendarDialog::on_calStart_selectionChanged()
|
|||
void CalendarDialog::on_buttonBox_accepted()
|
||||
{
|
||||
if(ui->calStart->selectedDate() > ui->calEnd->selectedDate())
|
||||
qDebug() << "start bigger than end!";
|
||||
qDebug() << "start is bigger than end!";
|
||||
}
|
||||
|
||||
void CalendarDialog::on_calEnd_selectionChanged()
|
||||
|
@ -57,7 +57,7 @@ void CalendarDialog::on_calEnd_selectionChanged()
|
|||
if(ui->calStart->selectedDate() >= ui->calEnd->selectedDate())
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue