Added a new algorithm to fix #15
Added a few if statmenst to fix that issue. in addition , added a privat function to convert the returnd dayOfWeek (QDate returns sunday=7 monday=2...) to JCE Manager format (AKA: sunday=1, monday=2 ....). checked on linux. working great! Issue #15.
This commit is contained in:
parent
2c4ae54ffc
commit
623baafce3
2 changed files with 43 additions and 1 deletions
|
@ -69,8 +69,20 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
|||
QString room = coursePtr->getRoom();
|
||||
|
||||
QDate currentDate = cal->getStartDate(); // currentDate will iterate throuh the semester
|
||||
int firstDayOfSemester = currentDate.dayOfWeek(); //Returns the weekday (1 = Monday to 7 = Sunday) for this date.
|
||||
|
||||
currentDate = currentDate.addDays(day-1); //selecting the REAL starting day of that course
|
||||
changeDayNumberFromQtToNormal(&firstDayOfSemester); //Get sync with our day numbers.
|
||||
|
||||
/*
|
||||
* these 6 lines will get the right day for the starting poin in a
|
||||
* semester for eatch course.
|
||||
*/
|
||||
if(day > firstDayOfSemester)
|
||||
currentDate = currentDate.addDays(day-firstDayOfSemester); //add the gap
|
||||
else if(day < firstDayOfSemester)
|
||||
currentDate = currentDate.addDays(6); //move a week nius one day
|
||||
else// ==
|
||||
currentDate = currentDate; //just for clearaty
|
||||
|
||||
/*
|
||||
* secondary loop - We have course info and starting day.
|
||||
|
@ -180,3 +192,31 @@ QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM
|
|||
|
||||
return CSV_line;
|
||||
}
|
||||
|
||||
void CSV_Exporter::changeDayNumberFromQtToNormal(int *QtDay)
|
||||
{
|
||||
switch(*QtDay){
|
||||
case 7:
|
||||
*QtDay = SUNDAY;
|
||||
break;
|
||||
case 1:
|
||||
*QtDay = MONDAY;
|
||||
break;
|
||||
case 2:
|
||||
*QtDay = TUESDAY;
|
||||
break;
|
||||
case 3:
|
||||
*QtDay = WENDSDAY;
|
||||
break;
|
||||
case 4:
|
||||
*QtDay = THURSDAY;
|
||||
break;
|
||||
case 5:
|
||||
*QtDay = FRIDAY;
|
||||
break;
|
||||
default:
|
||||
*QtDay = 7;
|
||||
break;
|
||||
}
|
||||
return; //Done.
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ public:
|
|||
private:
|
||||
static QString getFileFath();
|
||||
static QString makeLine(QString name,QDate *date,int startH,int startM,int endH,int endM,QString lecturer,QString room,QString type);
|
||||
static void changeDayNumberFromQtToNormal(int *);
|
||||
enum DAYS{SUNDAY=1, MONDAY=2, TUESDAY=3, WENDSDAY=4, THURSDAY=5, FRIDAY=6};
|
||||
};
|
||||
|
||||
#endif // CSV_EXPORTER_H
|
||||
|
|
Loading…
Reference in a new issue