Added exams to the export - if user chooses to
Tested on linux - works well! 😉
This commit is contained in:
parent
2209923153
commit
d6c1e7e5d6
7 changed files with 66 additions and 11 deletions
|
@ -36,7 +36,7 @@ void CalendarManager::exportCalendarCSV()
|
|||
//calDialog.getStartDate(),calDialog.getEndDate()
|
||||
if (caliDialog->ok())
|
||||
{
|
||||
if (CSV_Exporter::exportCalendar(caliSchedPtr, caliDialog))
|
||||
if (CSV_Exporter::exportCalendar(caliSchedPtr, caliDialog, examSchePtr))
|
||||
{
|
||||
msgBox.setIcon(QMessageBox::Information);
|
||||
msgBox.setText(QObject::tr("Exported Successfuly!"));
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "./CourseTab/coursestablemanager.h"
|
||||
#include "./LoginTab/loginhandler.h"
|
||||
#include "./CalendarTab/CalendarManager.h"
|
||||
#include "./jceWidgets/jceStatusBar.h"
|
||||
#include "./jceWidgets/jcestatusbar.h"
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
/*
|
||||
*
|
||||
* Class doc can be found in csv_exporter.h
|
||||
* TODO: add exam exportation
|
||||
*/
|
||||
CSV_Exporter::CSV_Exporter()
|
||||
{
|
||||
|
@ -18,7 +17,7 @@ CSV_Exporter::CSV_Exporter()
|
|||
* @param cal - The Calendar dialog witch holdes the starting date and the eand date.
|
||||
* @return - True if *all* went well, false if something on the way went wrong.
|
||||
*/
|
||||
bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *cal)
|
||||
bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *cal, calendarExam *exams)
|
||||
{
|
||||
if ((cal == NULL) || (calSched == NULL)) //pointers checking!
|
||||
return false;
|
||||
|
@ -97,6 +96,36 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
|||
out.flush();
|
||||
}
|
||||
|
||||
if(cal->isExams()) //Export Exams as well
|
||||
{
|
||||
qDebug() << "Exporting Exams!";
|
||||
for(calendarExamCourse* exam:exams->getExams())
|
||||
{
|
||||
QTime startH = exam->getFirstHourbegin();
|
||||
QTime endH = startH.addSecs(60*60*3);//add 3 hours
|
||||
QString type = "מבחן א";
|
||||
QString name = exam->getName();
|
||||
QDate date = exam->getFirstDate();
|
||||
QString line = makeLine(name, &date, startH.hour(), startH.minute(), endH.hour(), endH.minute(), "", "", type);
|
||||
if(line != NULL)
|
||||
out << line << char(0x0A);
|
||||
else
|
||||
qWarning() << Q_FUNC_INFO << "CSV : Got A NULL in Line! in function: " << Q_FUNC_INFO;
|
||||
//===============
|
||||
// Second Date
|
||||
//===============
|
||||
startH = exam->getSecondHourbegin();
|
||||
endH = startH.addSecs(60*60*3);//add 3 hours
|
||||
date = exam->getSecondDate();
|
||||
type = "מבחן ב";
|
||||
line = makeLine(name, &date, startH.hour(), startH.minute(), endH.hour(), endH.minute(), "", "", type);
|
||||
if(line != NULL)
|
||||
out << line << char(0x0A);
|
||||
else
|
||||
qWarning() << Q_FUNC_INFO << "CSV : Got A NULL in Line! in function: " << Q_FUNC_INFO;
|
||||
}
|
||||
out.flush();
|
||||
}
|
||||
|
||||
file.close();
|
||||
qDebug() << Q_FUNC_INFO << "CSV : Exported Successfully";
|
||||
|
@ -115,6 +144,10 @@ QString CSV_Exporter::getFileFath()
|
|||
QObject::tr("CSV Files (*.csv);;All Files (*)"));
|
||||
if (fileName == "")
|
||||
return NULL;
|
||||
|
||||
//IMPORTENT! ADD CSV EXTENTION
|
||||
if(!fileName.contains(".csv") && !fileName.contains(".CSV"))
|
||||
fileName.append(".csv");
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
@ -149,20 +182,32 @@ 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));
|
||||
if(startM != 0)
|
||||
{
|
||||
start.append(":");
|
||||
start.append(QString::number(startM));
|
||||
}
|
||||
else
|
||||
start.append(":00");
|
||||
start.append(":00");
|
||||
|
||||
QString end;
|
||||
end.append(QString::number(endH));
|
||||
end.append(":");
|
||||
end.append(QString::number(endM));
|
||||
if(endM != 0)
|
||||
{
|
||||
end.append(":");
|
||||
end.append(QString::number(endM));
|
||||
}
|
||||
else
|
||||
end.append(":00");
|
||||
end.append(":00");
|
||||
|
||||
QString description = "\"מרצה ";
|
||||
|
||||
if (lecturer == LECTURER_DEFAULT_STRING)
|
||||
description.append("טרם נקבע מרצה או מתרגל");
|
||||
else if(lecturer == "")
|
||||
description = "";
|
||||
else
|
||||
description.append(lecturer);
|
||||
|
||||
|
@ -176,6 +221,9 @@ QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM
|
|||
description.append(room);
|
||||
}
|
||||
|
||||
if(room == "")
|
||||
description = "\"\Good Luck!\n";
|
||||
|
||||
description.append("\n Created with JCE Manager.\"");
|
||||
|
||||
//Create the Fucking Line
|
||||
|
@ -237,3 +285,4 @@ void CSV_Exporter::changeDayNumberFromQtToNormal(int *QtDay)
|
|||
}
|
||||
return; //Done.
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "../Calendar/coursesSchedule/calendarSchedule.h"
|
||||
#include "../Calendar/coursesSchedule/calendarDialog.h"
|
||||
#include "../Calendar/Exams/calendarExam.h"
|
||||
|
||||
|
||||
#define CSV_CALENDAR_HEADER "Subject,Start Date,Start Time,End Date,End Time,Description,Location"
|
||||
|
@ -26,7 +27,7 @@ class CSV_Exporter
|
|||
{
|
||||
public:
|
||||
CSV_Exporter();
|
||||
static bool exportCalendar(calendarSchedule* calSched, CalendarDialog *cal);
|
||||
static bool exportCalendar(calendarSchedule* calSched, CalendarDialog *cal, calendarExam* exams);
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -96,3 +96,7 @@ void CalendarDialog::changeLabeStatusIcon(bool goodOrBad)
|
|||
iconPixStatus.load(":/icons/iconX.png");
|
||||
this->ui->labelIconStatus->setPixmap(iconPixStatus);
|
||||
}
|
||||
|
||||
bool CalendarDialog::isExams(){
|
||||
return ui->isExam->isChecked();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
QDate getStartDate();
|
||||
QDate getEndDate();
|
||||
bool ok();
|
||||
bool isExams();
|
||||
|
||||
private slots:
|
||||
void on_calStart_selectionChanged();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>609</width>
|
||||
<width>830</width>
|
||||
<height>310</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -184,7 +184,7 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<widget class="QCheckBox" name="isExam">
|
||||
<property name="text">
|
||||
<string>Include Exams</string>
|
||||
</property>
|
||||
|
|
Loading…
Reference in a new issue