Merge pull request #18 from liranbg/sagi_dev

Sagi dev -> Master
This commit is contained in:
Liran BG 2014-09-22 22:07:42 +03:00
commit fc39787eb4
7 changed files with 58 additions and 18 deletions

View file

@ -4,7 +4,7 @@
#include "./src/jceData/Calendar/calendarPage.h"
#include "./src/jceData/Calendar/calendarSchedule.h"
#include "./src/jceData/CSV/csv_exporter.h"
#include "./src/jceData/Calendar/calendardialog.h"
#include "./src/jceData/Calendar/calendarDialog.h"
#include <iostream>
#include <QMessageBox>

View file

@ -5,22 +5,20 @@
* SaveData Class
* --------------------------------------
*
* all functions in this class are static!
* no need to create an object!
*
* provides all the needed functions
* for saving user data for JCE login.
* Uses QMap
*
* the class will enteract with a file formated by tags for storing the valus.
* the file format is as sutch:
*
* [status]Status Value[/]
* [username]usernaem vale[/]
* [password]hashed(not really) password vale[/]
* key : vale
*
* the class will create a file if not exists by calling Save Data::init() function.
* Keys:
* "username"
* "password"
* "local"
* "calendar"
*
* Note that the password will be encrypted using the SimpleCrypt class!
*
* SimpleCrypt class was found at the qt projects forms - and been fixed by Sagi Dayan.
*
* for more info about functions - see implantation
*/
/* QT libs */
@ -31,7 +29,7 @@
#include <QMap>
#include "simplecrypt.h"
#define FILE_NAME "JAC_DB.dat"
#define FILE_NAME "JM.dat"
class SaveData
{

View file

@ -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.
}

View file

@ -9,7 +9,7 @@
#include <QMessageBox>
#include "../Calendar/calendarSchedule.h"
#include "../Calendar/calendardialog.h"
#include "../Calendar/calendarDialog.h"
#define CSV_CALENDAR_HEADER "Subject,Start Date,Start Time,End Date,End Time,Description,Location"
@ -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

View file

@ -1,5 +1,5 @@
#include "calendarDialog.h"
#include "ui_calenDardialog.h"
#include "ui_calendardialog.h"
CalendarDialog::CalendarDialog(QWidget *parent) :