Merge conflict - fixed
This commit is contained in:
commit
6979de6576
|
@ -8,13 +8,21 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
qInstallMessageHandler(jce_logger::customMessageHandler);
|
||||
qDebug() << "Start : JCE Manager Launched" << Q_FUNC_INFO;
|
||||
#ifdef QT_DEBUG // Incase QtCreator is in Debug mode all qDebug messages will go to terminal
|
||||
qDebug() << "Running a debug build";
|
||||
#else // If QtCreator is on Release mode , qDebug messages will be logged in a log file.
|
||||
qDebug() << "Running a release build";
|
||||
qInstallMessageHandler(jce_logger::customMessageHandler);
|
||||
#endif
|
||||
|
||||
qDebug() << "Start : JCE Manager Launched";
|
||||
|
||||
QApplication a(argc, argv);
|
||||
QTranslator translator;
|
||||
QString loco;
|
||||
SaveData data;
|
||||
loco = data.getLocal();
|
||||
//Loading Local (From Settings file (SaveData.cpp)
|
||||
if(loco == "default")
|
||||
{
|
||||
QString locale = QLocale::system().name();
|
||||
|
@ -27,10 +35,11 @@ int main(int argc, char *argv[])
|
|||
translator.load("jce_en" , a.applicationDirPath());
|
||||
qDebug() << "Local : English Local Loaded";
|
||||
}
|
||||
a.installTranslator(&translator);
|
||||
a.installTranslator(&translator); //Setting local
|
||||
MainScreen w;
|
||||
w.show();
|
||||
|
||||
//Getting the exit code from QApplication. for debug reasons
|
||||
int returnCode = a.exec();
|
||||
if(returnCode == 0)
|
||||
qDebug() << "End : JCE Manager Ended Successfully With A Return Code: " << returnCode;
|
||||
|
|
|
@ -1,10 +1,25 @@
|
|||
#include "csv_exporter.h"
|
||||
|
||||
/*
|
||||
*
|
||||
* Class doc can be bound in csv_exporter.h
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
CSV_Exporter::CSV_Exporter()
|
||||
{
|
||||
|
||||
/* EMPTY - NO NEED */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This method will generate the CSV file (Targeting google calendar import)
|
||||
* it will create a full Semester calendar based on the users input (@param cal)
|
||||
* and the @calSched wich holdes all the courses in "this" semester.
|
||||
* @param calSched - Holdes all the Courses and there info
|
||||
* @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)
|
||||
{
|
||||
if ((cal == NULL) || (calSched == NULL)) //pointers checking!
|
||||
|
@ -16,7 +31,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
|||
qDebug() << "Getting path for csv file from user...";
|
||||
|
||||
QString filePath = getFileFath();
|
||||
if (filePath == NULL) //User canceled
|
||||
if(filePath == NULL) //User canceled from the file explorer popup
|
||||
{
|
||||
qDebug() << "CSV : User pressed Cancel... returning false";
|
||||
return false;
|
||||
|
@ -25,7 +40,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
|||
qDebug() << "CSV : Atempting to export the Schedule...";
|
||||
|
||||
QFile file(filePath);
|
||||
if(!file.open(QIODevice::ReadWrite | QIODevice::Truncate))
|
||||
if(!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) //Incase unable to open the file (binary mode - \n will not be converted on "Windows")
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
|
@ -33,28 +48,33 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
|||
msgBox.exec();
|
||||
qCritical() << "unable to open/create the file... maybe permissions error.";
|
||||
return false;
|
||||
}//else
|
||||
//Delete the file
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out << CSV_CALENDAR_HEADER << "\n";
|
||||
for (calendarCourse *coursePtr: *(calSched->getCourses()))
|
||||
out << CSV_CALENDAR_HEADER << "\n"; // macro in header file
|
||||
|
||||
for (calendarCourse *coursePtr: *(calSched->getCourses())) //main loop - running though all courses
|
||||
{
|
||||
// Subject,Start Date,Start Time,End Date,End Time,Description,Location
|
||||
// Getting course info - store in vars for easy access
|
||||
int day = coursePtr->getDay();
|
||||
int startH = coursePtr->getHourBegin();
|
||||
int startM = coursePtr->getMinutesBegin();
|
||||
int endH = coursePtr->getHourEnd();
|
||||
int endM = coursePtr->getMinutesEnd();
|
||||
QString lecturer = coursePtr->getLecturer();
|
||||
QString type = coursePtr->getType();
|
||||
QString name = coursePtr->getName();
|
||||
QString room = coursePtr->getRoom();
|
||||
QString lecturer = QString(coursePtr->getLecturer().c_str()); //NOTE: STD String
|
||||
QString type = QString(coursePtr->getType().c_str());
|
||||
QString name = QString(coursePtr->getName().c_str());
|
||||
QString room = QString(coursePtr->getRoom().c_str());
|
||||
|
||||
QDate currentDate = cal->getStartDate();
|
||||
QDate currentDate = cal->getStartDate(); // currentDate will iterate thou the semester
|
||||
|
||||
currentDate = currentDate.addDays(day-1);
|
||||
currentDate = currentDate.addDays(day-1); //selecting the REAL starting day of that course
|
||||
|
||||
for (;currentDate <= cal->getEndDate(); currentDate = currentDate.addDays(7))
|
||||
/*
|
||||
* secondary loop - We have course info and starting day.
|
||||
* evrey loop enterence we add the course and moving one week forward.
|
||||
*/
|
||||
for(;currentDate <= cal->getEndDate(); currentDate = currentDate.addDays(7))
|
||||
{
|
||||
QString line = makeLine(name, ¤tDate, startH, startM, endH, endM, lecturer, room, type);
|
||||
if(line != NULL)
|
||||
|
@ -72,6 +92,10 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the file path according to user via a file explorer dialog
|
||||
* @return - QString: the file path.
|
||||
*/
|
||||
QString CSV_Exporter::getFileFath()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName();
|
||||
|
@ -82,6 +106,20 @@ QString CSV_Exporter::getFileFath()
|
|||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returning a CSV formated ling in QString.
|
||||
* @param name
|
||||
* @param date
|
||||
* @param startH
|
||||
* @param startM
|
||||
* @param endH
|
||||
* @param endM
|
||||
* @param lecturer
|
||||
* @param room
|
||||
* @param type
|
||||
* @return a CSV formated ling in QString.
|
||||
*/
|
||||
QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM, int endH, int endM, QString lecturer, QString room, QString type)
|
||||
{
|
||||
//Creating a CSV text line for Google Calendar/iCal/Outlook
|
||||
|
@ -114,7 +152,7 @@ QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM
|
|||
description.append("\n");
|
||||
description.append(" ב");
|
||||
description.append(room);
|
||||
description.append("\"");
|
||||
description.append("\n Created with JCE Manager. \" ");
|
||||
|
||||
//Create the Fucking Line
|
||||
//Header: Subject,Start Date,Start Time,End Date,End Time,Description,Location
|
||||
|
|
|
@ -4,6 +4,15 @@
|
|||
* This Static method will help parsing our debug messages to a readable Log file
|
||||
*
|
||||
* timestamp - Message type - message
|
||||
*
|
||||
* Message types cam be:
|
||||
*
|
||||
* - DEBUG
|
||||
* - WARNING
|
||||
* - CRITICAL
|
||||
* - FATAL
|
||||
*
|
||||
* Logs stored in a log file. File name is Stored in the Macro in Header file
|
||||
*/
|
||||
void jce_logger::customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
|
@ -29,7 +38,7 @@ void jce_logger::customMessageHandler(QtMsgType type, const QMessageLogContext &
|
|||
break;
|
||||
}
|
||||
|
||||
QFile outFile("J_M_Log.log");
|
||||
QFile outFile(LOG_FILE_NAME);
|
||||
outFile.open(QIODevice::WriteOnly | QIODevice::Append);
|
||||
|
||||
QTextStream textStream(&outFile);
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#define LOG_FILE_NAME "J_M_Log.log"
|
||||
|
||||
class jce_logger
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue