csv exporting messages fix.

This commit is contained in:
liranbg 2014-09-17 05:55:28 +03:00
parent c3345399f4
commit f7a468fb31
3 changed files with 12 additions and 6 deletions

View file

@ -12,7 +12,6 @@ void CalendarManager::setCalendar(QString html)
}
void CalendarManager::exportCalendarCSV() //need to add fix to the null pointer bug
{
qDebug() << this->caliSchedPtr->getCourses();
if (this->caliSchedPtr->getCourses() == NULL)
return;
QMessageBox msgBox;
@ -26,14 +25,17 @@ void CalendarManager::exportCalendarCSV() //need to add fix to the null pointer
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(QObject::tr("Exported Successfuly!"));
msgBox.exec();
}
}
else
{
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(QObject::tr("Dates not valid"));
msgBox.exec();
}
msgBox.exec();
}

View file

@ -10,9 +10,8 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
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
@ -24,9 +23,13 @@ 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.";
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(QObject::tr("Unable to open or create the file.\nExporting Failed"));
msgBox.exec();
qWarning() << "unable to open/create the file... maybe permissions error.";
return false;
}//else
//Delete the file

View file

@ -6,6 +6,7 @@
#include <QTextStream>
#include <QString>
#include <QDebug>
#include <QMessageBox>
#include "../Calendar/calendarSchedule.h"
#include "../Calendar/calendardialog.h"