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()
|
//calDialog.getStartDate(),calDialog.getEndDate()
|
||||||
if (caliDialog->ok())
|
if (caliDialog->ok())
|
||||||
{
|
{
|
||||||
if (CSV_Exporter::exportCalendar(caliSchedPtr, caliDialog))
|
if (CSV_Exporter::exportCalendar(caliSchedPtr, caliDialog, examSchePtr))
|
||||||
{
|
{
|
||||||
msgBox.setIcon(QMessageBox::Information);
|
msgBox.setIcon(QMessageBox::Information);
|
||||||
msgBox.setText(QObject::tr("Exported Successfuly!"));
|
msgBox.setText(QObject::tr("Exported Successfuly!"));
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "./CourseTab/coursestablemanager.h"
|
#include "./CourseTab/coursestablemanager.h"
|
||||||
#include "./LoginTab/loginhandler.h"
|
#include "./LoginTab/loginhandler.h"
|
||||||
#include "./CalendarTab/CalendarManager.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
|
* Class doc can be found in csv_exporter.h
|
||||||
* TODO: add exam exportation
|
|
||||||
*/
|
*/
|
||||||
CSV_Exporter::CSV_Exporter()
|
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.
|
* @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.
|
* @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!
|
if ((cal == NULL) || (calSched == NULL)) //pointers checking!
|
||||||
return false;
|
return false;
|
||||||
|
@ -97,6 +96,36 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
||||||
out.flush();
|
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();
|
file.close();
|
||||||
qDebug() << Q_FUNC_INFO << "CSV : Exported Successfully";
|
qDebug() << Q_FUNC_INFO << "CSV : Exported Successfully";
|
||||||
|
@ -115,6 +144,10 @@ QString CSV_Exporter::getFileFath()
|
||||||
QObject::tr("CSV Files (*.csv);;All Files (*)"));
|
QObject::tr("CSV Files (*.csv);;All Files (*)"));
|
||||||
if (fileName == "")
|
if (fileName == "")
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
//IMPORTENT! ADD CSV EXTENTION
|
||||||
|
if(!fileName.contains(".csv") && !fileName.contains(".CSV"))
|
||||||
|
fileName.append(".csv");
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,20 +182,32 @@ QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM
|
||||||
|
|
||||||
QString start;
|
QString start;
|
||||||
start.append(QString::number(startH));
|
start.append(QString::number(startH));
|
||||||
|
if(startM != 0)
|
||||||
|
{
|
||||||
|
start.append(":");
|
||||||
|
start.append(QString::number(startM));
|
||||||
|
}
|
||||||
|
else
|
||||||
start.append(":00");
|
start.append(":00");
|
||||||
// start.append(QString::number(startM));
|
|
||||||
start.append(":00");
|
start.append(":00");
|
||||||
|
|
||||||
QString end;
|
QString end;
|
||||||
end.append(QString::number(endH));
|
end.append(QString::number(endH));
|
||||||
|
if(endM != 0)
|
||||||
|
{
|
||||||
end.append(":");
|
end.append(":");
|
||||||
end.append(QString::number(endM));
|
end.append(QString::number(endM));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
end.append(":00");
|
||||||
end.append(":00");
|
end.append(":00");
|
||||||
|
|
||||||
QString description = "\"מרצה ";
|
QString description = "\"מרצה ";
|
||||||
|
|
||||||
if (lecturer == LECTURER_DEFAULT_STRING)
|
if (lecturer == LECTURER_DEFAULT_STRING)
|
||||||
description.append("טרם נקבע מרצה או מתרגל");
|
description.append("טרם נקבע מרצה או מתרגל");
|
||||||
|
else if(lecturer == "")
|
||||||
|
description = "";
|
||||||
else
|
else
|
||||||
description.append(lecturer);
|
description.append(lecturer);
|
||||||
|
|
||||||
|
@ -176,6 +221,9 @@ QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM
|
||||||
description.append(room);
|
description.append(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(room == "")
|
||||||
|
description = "\"\Good Luck!\n";
|
||||||
|
|
||||||
description.append("\n Created with JCE Manager.\"");
|
description.append("\n Created with JCE Manager.\"");
|
||||||
|
|
||||||
//Create the Fucking Line
|
//Create the Fucking Line
|
||||||
|
@ -237,3 +285,4 @@ void CSV_Exporter::changeDayNumberFromQtToNormal(int *QtDay)
|
||||||
}
|
}
|
||||||
return; //Done.
|
return; //Done.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "../Calendar/coursesSchedule/calendarSchedule.h"
|
#include "../Calendar/coursesSchedule/calendarSchedule.h"
|
||||||
#include "../Calendar/coursesSchedule/calendarDialog.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"
|
#define CSV_CALENDAR_HEADER "Subject,Start Date,Start Time,End Date,End Time,Description,Location"
|
||||||
|
@ -26,7 +27,7 @@ class CSV_Exporter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CSV_Exporter();
|
CSV_Exporter();
|
||||||
static bool exportCalendar(calendarSchedule* calSched, CalendarDialog *cal);
|
static bool exportCalendar(calendarSchedule* calSched, CalendarDialog *cal, calendarExam* exams);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -96,3 +96,7 @@ void CalendarDialog::changeLabeStatusIcon(bool goodOrBad)
|
||||||
iconPixStatus.load(":/icons/iconX.png");
|
iconPixStatus.load(":/icons/iconX.png");
|
||||||
this->ui->labelIconStatus->setPixmap(iconPixStatus);
|
this->ui->labelIconStatus->setPixmap(iconPixStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CalendarDialog::isExams(){
|
||||||
|
return ui->isExam->isChecked();
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ public:
|
||||||
QDate getStartDate();
|
QDate getStartDate();
|
||||||
QDate getEndDate();
|
QDate getEndDate();
|
||||||
bool ok();
|
bool ok();
|
||||||
|
bool isExams();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_calStart_selectionChanged();
|
void on_calStart_selectionChanged();
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>609</width>
|
<width>830</width>
|
||||||
<height>310</height>
|
<height>310</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -184,7 +184,7 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="0" column="3">
|
||||||
<widget class="QCheckBox" name="checkBox">
|
<widget class="QCheckBox" name="isExam">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Include Exams</string>
|
<string>Include Exams</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in a new issue