Merge pull request #9 from sagidayan/master

Export to CSV with Semester begin & end
This commit is contained in:
liranbg 2014-09-11 15:28:28 +03:00
commit 884cc76049
10 changed files with 764 additions and 105 deletions

View file

@ -1,63 +1,67 @@
#------------------------------------------------- #-------------------------------------------------
# #
# Project created by QtCreator 2014-05-31T19:49:42 # Project created by QtCreator 2014-05-31T19:49:42
# #
#------------------------------------------------- #-------------------------------------------------
QT += core gui network widgets QT += core gui network widgets
TARGET = jceGrade TARGET = jceGrade
TEMPLATE = app TEMPLATE = app
RC_FILE = appConfigure.rc RC_FILE = appConfigure.rc
CONFIG += qt c++11 CONFIG += qt c++11
CONFIG += console static CONFIG += console static
TRANSLATIONS = jce_en.ts \ TRANSLATIONS = jce_en.ts \
jce_he.ts jce_he.ts
FORMS += \
main/mainscreen.ui FORMS += \
main/mainscreen.ui \
OTHER_FILES += src/jceData/Calendar/calendardialog.ui
RESOURCES += \ OTHER_FILES +=
resources/connectionstatus.qrc
RESOURCES += \
HEADERS += \ resources/connectionstatus.qrc
main/CalendarTab/CalendarManager.h \
main/CourseTab/coursestablemanager.h \ HEADERS += \
main/LoginTab/loginhandler.h \ main/CalendarTab/CalendarManager.h \
main/mainscreen.h \ main/CourseTab/coursestablemanager.h \
src/appDatabase/savedata.h \ main/LoginTab/loginhandler.h \
src/jceConnection/jcesslclient.h \ main/mainscreen.h \
src/jceData/Calendar/calendarPage.h \ src/appDatabase/savedata.h \
src/jceData/Grades/gradeCourse.h \ src/jceConnection/jcesslclient.h \
src/jceData/Grades/gradePage.h \ src/jceData/Calendar/calendarPage.h \
src/jceData/course.h \ src/jceData/Grades/gradeCourse.h \
src/jceData/page.h \ src/jceData/Grades/gradePage.h \
src/jceSettings/jcelogin.h \ src/jceData/course.h \
src/jceSettings/jceLoginHtmlScripts.h \ src/jceData/page.h \
src/jceSettings/user.h \ src/jceSettings/jcelogin.h \
src/jceData/Calendar/calendarCourse.h \ src/jceSettings/jceLoginHtmlScripts.h \
src/jceData/Calendar/calendarSchedule.h \ src/jceSettings/user.h \
src/jceData/CSV/csv_exporter.h \ src/jceData/Calendar/calendarCourse.h \
src/appDatabase/simplecrypt.h src/jceData/Calendar/calendarSchedule.h \
src/jceData/CSV/csv_exporter.h \
SOURCES += \ src/appDatabase/simplecrypt.h \
main/CalendarTab/CalendarManager.cpp \ src/jceData/Calendar/calendardialog.h
main/CourseTab/coursestablemanager.cpp \
main/LoginTab/loginhandler.cpp \ SOURCES += \
main/main.cpp \ main/CalendarTab/CalendarManager.cpp \
main/mainscreen.cpp \ main/CourseTab/coursestablemanager.cpp \
src/appDatabase/savedata.cpp \ main/LoginTab/loginhandler.cpp \
src/jceConnection/jcesslclient.cpp \ main/main.cpp \
src/jceData/Calendar/calendarPage.cpp \ main/mainscreen.cpp \
src/jceData/Grades/gradeCourse.cpp \ src/appDatabase/savedata.cpp \
src/jceData/Grades/gradePage.cpp \ src/jceConnection/jcesslclient.cpp \
src/jceData/page.cpp \ src/jceData/Calendar/calendarPage.cpp \
src/jceSettings/jcelogin.cpp \ src/jceData/Grades/gradeCourse.cpp \
src/jceSettings/user.cpp \ src/jceData/Grades/gradePage.cpp \
src/jceData/Calendar/calendarCourse.cpp \ src/jceData/page.cpp \
src/jceData/Calendar/calendarSchedule.cpp \ src/jceSettings/jcelogin.cpp \
src/jceData/CSV/csv_exporter.cpp \ src/jceSettings/user.cpp \
src/appDatabase/simplecrypt.cpp src/jceData/Calendar/calendarCourse.cpp \
src/jceData/Calendar/calendarSchedule.cpp \
src/jceData/CSV/csv_exporter.cpp \
src/appDatabase/simplecrypt.cpp \
src/jceData/Calendar/calendardialog.cpp

View file

@ -9,9 +9,9 @@ void CalendarManager::setCalendar(std::string html)
{ {
caliSchedPtr->setPage(html); caliSchedPtr->setPage(html);
} }
void CalendarManager::exportCalendarCSV() void CalendarManager::exportCalendarCSV(CalendarDialog *calDialog)
{ {
if(CSV_Exporter::exportCalendar(this->caliSchedPtr)) if(CSV_Exporter::exportCalendar(this->caliSchedPtr, calDialog))
{ {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(QObject::tr("Exported Successfuly!")); msgBox.setText(QObject::tr("Exported Successfuly!"));

View file

@ -4,6 +4,7 @@
#include "./src/jceData/Calendar/calendarPage.h" #include "./src/jceData/Calendar/calendarPage.h"
#include "./src/jceData/Calendar/calendarSchedule.h" #include "./src/jceData/Calendar/calendarSchedule.h"
#include "./src/jceData/CSV/csv_exporter.h" #include "./src/jceData/CSV/csv_exporter.h"
#include "./src/jceData/Calendar/calendardialog.h"
#include <iostream> #include <iostream>
#include <QMessageBox> #include <QMessageBox>
@ -15,12 +16,13 @@ public:
{ {
delete caliSchedPtr; delete caliSchedPtr;
} }
void exportCalendarCSV(); void exportCalendarCSV(CalendarDialog*);
void setCalendar(std::string html); void setCalendar(std::string html);
void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); } void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); }
private: private:
calendarSchedule * caliSchedPtr; calendarSchedule * caliSchedPtr;
}; };
#endif // CALENDARMANAGER_H #endif // CALENDARMANAGER_H

View file

@ -311,6 +311,23 @@ void MainScreen::on_actionHow_To_triggered()
} }
void MainScreen::on_exportToCVSBtn_clicked()
{
if (loginHandel->isLoggedInFlag())
{
CalendarDialog calDialog;
int buttonClicked = calDialog.exec();
if(buttonClicked == 0)
return;
//calDialog.getStartDate(),calDialog.getEndDate()
if(calDialog.ok())
this->calendar->exportCalendarCSV(&calDialog);
else
showMSG("Somthig was not right with the dates you have chosen... try again");
}
}
void MainScreen::on_actionHebrew_triggered() void MainScreen::on_actionHebrew_triggered()
{ {
if (ui->actionEnglish->isChecked() || ui->actionOS_Default->isChecked()) if (ui->actionEnglish->isChecked() || ui->actionOS_Default->isChecked())

408
main/mainscreen.cpp~ Normal file
View file

@ -0,0 +1,408 @@
#include "mainscreen.h"
#include "ui_mainscreen.h"
MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScreen)
{
ui->setupUi(this);
//this->setFixedSize(this->size()); //main not resizeable
//Login Tab
QPixmap iconPix;
iconPix.load(":/icons/iconX.png");
ui->pswdLineEdit->setEchoMode((QLineEdit::Password));
ui->labelUsrInputStatus->setVisible(false);
ui->labelPswInputStatus->setVisible(false);
ui->labelUsrInputStatus->setPixmap(iconPix);
ui->labelPswInputStatus->setPixmap(iconPix);
//Status Bar
ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };");
ButtomStatusLabel = new QLabel(this);
statusLabel = new QLabel(this);
ui->statusBar->setMaximumSize(this->geometry().width(),StatusIconHeight);
ui->statusBar->addPermanentWidget(ButtomStatusLabel,0);
ui->statusBar->addPermanentWidget(statusLabel,1);
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
//Course, Setting, Calendar Tab
calendarSchedule * calendarSchedulePtr = new calendarSchedule();
ui->calendarGridLayoutMain->addWidget(calendarSchedulePtr);
ui->CoursesTab->setDisabled(true);
ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue));
//Pointer allocating
this->userLoginSetting = new user("","");
this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting);
this->loginHandel = new loginHandler(userLoginSetting);
this->calendar = new CalendarManager(calendarSchedulePtr);
this->data = new SaveData();
//check login File
if (data->isSaved())
{
ui->usrnmLineEdit->setText(data->getUsername());
ui->pswdLineEdit->setText(data->getPassword());
ui->keepLogin->setChecked(true);
}
//Local Check and ui setting.
checkLocale();
}
MainScreen::~MainScreen()
{
delete ButtomStatusLabel;
delete statusLabel;
delete calendar;
delete courseTableMgr;
delete userLoginSetting;
delete loginHandel;
delete ui;
delete data;
}
//EVENTS ON STATUS BAR
void MainScreen::setLabelConnectionStatus(jceLogin::jceStatus statusDescription)
{
QPixmap iconPix;
switch (statusDescription)
{
case jceLogin::jceStatus::JCE_START_VALIDATING_PROGRESS:
iconPix.load(":/icons/blueStatusIcon.png");
statusLabel->setText(tr("Connecting"));
break;
case jceLogin::jceStatus::JCE_YOU_ARE_IN:
iconPix.load(":/icons/greenStatusIcon.png");
statusLabel->setText(tr("Connected"));
break;
default:
iconPix.load(":/icons/redStatusIcon.png");
statusLabel->setText(tr("Disconnected"));
break;
}
ButtomStatusLabel->setPixmap(iconPix);
this->repaint();
}
//EVENTS ON LOGIN TAB
void MainScreen::on_loginButton_clicked()
{
if (loginHandel->isLoggedInFlag())
uiSetDisconnectMode();
else
uiSetConnectMode();
}
void MainScreen::on_keepLogin_clicked()
{
if (ui->keepLogin->isChecked())
{
data->setUsername(ui->usrnmLineEdit->text());
data->setPassword(ui->pswdLineEdit->text());
}
else
data->reset();
}
void MainScreen::on_usrnmLineEdit_editingFinished()
{
ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower());
}
void MainScreen::uiSetDisconnectMode()
{
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
ui->usrnmLineEdit->setText("");
ui->pswdLineEdit->setText("");
ui->usrnmLineEdit->setEnabled(true);
ui->pswdLineEdit->setEnabled(true);
loginHandel->makeDisconnectionRequest();
ui->loginButton->setText(tr("&Login"));
ui->getCalendarBtn->setDisabled(true);
ui->exportToCVSBtn->setDisabled(true);
ui->ratesButton->setDisabled(true);
return;
}
void MainScreen::uiSetConnectMode()
{
string username;
string password;
if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty()))
{
if (ui->usrnmLineEdit->text().isEmpty())
{
ui->labelUsrInputStatus->setVisible(true);
qDebug() << "error, username input is empty";
}
else
ui->labelUsrInputStatus->setVisible(false);
if (ui->pswdLineEdit->text().isEmpty())
{
ui->labelPswInputStatus->setVisible(true);
qDebug() << "error, password input is empty";
}
else
ui->labelPswInputStatus->setVisible(false);
return;
}
else
{
ui->labelUsrInputStatus->setVisible(false);
ui->labelPswInputStatus->setVisible(false);
}
setLabelConnectionStatus(jceLogin::jceStatus::JCE_START_VALIDATING_PROGRESS);
username = ui->usrnmLineEdit->text().toStdString();
password = ui->pswdLineEdit->text().toStdString();
ui->usrnmLineEdit->setDisabled(true);
ui->pswdLineEdit->setDisabled(true);
userLoginSetting->setUsername(username);
userLoginSetting->setPassword(password);
this->loginHandel->setPointers(statusLabel,ui->pswdLineEdit,ui->usrnmLineEdit);
if (loginHandel->makeConnection() == true)
{
setLabelConnectionStatus(jceLogin::jceStatus::JCE_YOU_ARE_IN);
ui->loginButton->setText(tr("&Logout"));
ui->ratesButton->setEnabled(true);
ui->CoursesTab->setEnabled(true);
ui->exportToCVSBtn->setEnabled(true);
ui->getCalendarBtn->setEnabled(true);
}
else
{
uiSetDisconnectMode();
}
}
//EVENTS ON GPA TAB
void MainScreen::on_ratesButton_clicked()
{
std::string pageString;
int status = 0;
if (loginHandel->isLoggedInFlag())
{
if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(),ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_GRADE_PAGE_PASSED)
{
pageString = loginHandel->getCurrentPageContect().toStdString();
courseTableMgr->setCoursesList(pageString);
courseTableMgr->insertJceCoursesIntoTable();
}
else if (status == jceLogin::JCE_NOT_CONNECTED)
{
QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
}
}
}
void MainScreen::on_checkBoxCoursesInfluence_toggled(bool checked)
{
this->userLoginSetting->setInfluenceCourseOnly(checked);
this->courseTableMgr->influnceCourseChanged(checked);
}
void MainScreen::on_spinBoxCoursesFromYear_editingFinished()
{
if (ui->spinBoxCoursesFromYear->value() > ui->spinBoxCoursesToYear->value())
{
ui->spinBoxCoursesFromYear->setValue(ui->spinBoxCoursesToYear->value());
ui->spinBoxCoursesFromYear->setFocus();
}
}
void MainScreen::on_spinBoxCoursesToYear_editingFinished()
{
if (ui->spinBoxCoursesFromYear->value() > ui->spinBoxCoursesToYear->value())
{
ui->spinBoxCoursesToYear->setValue(ui->spinBoxCoursesFromYear->value());
ui->spinBoxCoursesToYear->setFocus();
}
}
void MainScreen::on_spinBoxCoursesFromSemester_editingFinished()
{
if (ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value())
{
if (ui->spinBoxCoursesFromSemester->value() > ui->spinBoxCoursesToSemester->value())
{
ui->spinBoxCoursesFromSemester->setValue(ui->spinBoxCoursesToSemester->value());
ui->spinBoxCoursesFromSemester->setFocus();
}
}
}
void MainScreen::on_spinBoxCoursesToSemester_editingFinished()
{
if (ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value())
{
if (ui->spinBoxCoursesFromSemester->value() > ui->spinBoxCoursesToSemester->value())
{
ui->spinBoxCoursesToSemester->setValue(ui->spinBoxCoursesFromSemester->value());
ui->spinBoxCoursesToSemester->setFocus();
}
}
}
void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item)
{
if (this->courseTableMgr->changes(item->text(),item->row(),item->column()))
ui->avgLCD->display(courseTableMgr->getAvg());
else
QMessageBox::critical(this,tr("Error"),tr("Missmatching data"));
}
void MainScreen::on_clearTableButton_clicked()
{
courseTableMgr->clearTable();
ui->avgLCD->display(courseTableMgr->getAvg());
}
//EVENTS ON CALENDAR TAB
void MainScreen::on_getCalendarBtn_clicked()
{
int status = 0;
if (loginHandel->isLoggedInFlag())
{
if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_GRADE_PAGE_PASSED)
{
//Use it for debug. add plain text and change the object name to 'plainTextEdit' so you will get the html request
//ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect());
calendar->resetTable();
calendar->setCalendar(loginHandel->getCurrentPageContect().toStdString());
}
else if (status == jceLogin::JCE_NOT_CONNECTED)
{
QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
}
}
}
void MainScreen::on_exportToCVSBtn_clicked()
{
if (loginHandel->isLoggedInFlag())
this->calendar->exportCalendarCSV();
}
//EVENTS ON MENU BAR
void MainScreen::on_actionCredits_triggered()
{
QMessageBox::about(this, "About", tr("CREDITS-ROOL-UP1") + " v1.0<br><br>"
+ tr("CREDITS-ROOL-UP2")+"<br>GNU LESSER GENERAL PUBLIC LICENSE V2<br>"
+ tr("CREDITS-ROOL-UP3")+"<br>"
"<a href='https://github.com/liranbg/jceAverageCalculator'>jceAverageCalculator Repository</a>"
"<br><br>"+tr("CREDITS-ROOL-UP4")+"<a href='https://github.com/liranbg/jceConnection'> Jce Connection</a><br><br>"
+tr("DevBy")+":"
"<ul>"
"<li><a href='mailto:liranbg@gmail.com'>"+tr("Liran")+"</a></li>"
"<li><a href='mailto:sagidayan@gmail.com'>"+tr("Sagi")+"</a></li>"
"</ul>");
}
void MainScreen::on_actionExit_triggered()
{
exit(0);
}
void MainScreen::on_actionHow_To_triggered()
{
QMessageBox::information(this,"How To",
"<b>How To..</b>"
"<ul>"
"<br><li>"+tr("HELP1")+"</li>"
"<br><li>"+tr("HELP2")+"</li>"
"<br><li>"+tr("HELP3")+"</li>"
"<br><li>"+tr("HELP4")+"</li>"
"<br><li>"+tr("HELP5")+"</li>"
"<br><br>"+tr("HELP6")+
"</ul>");
}
<<<<<<< HEAD
//void MainScreen::on_pushButton_2_clicked()
//{
// if(CSV_Exporter::exportCalendar(this->calendar->getSch()))
// {
// QMessageBox msgBox;
// msgBox.setText("<center>Exported Successfuly!<br><b>HaazZaA!!");
// msgBox.exec();
// }else
// {
// QMessageBox msgBox;
// msgBox.setIcon(QMessageBox::Critical);
// msgBox.setText("<center>Something went wrong...<br></center>Maybe: <ul><li>You Canceled</li><li>Unable to save the File - try again</li></ul><br><br>"
// "<b><center>In case of a serious problem, please file a bug report.<br>thank you. OpenJCE teem");
// msgBox.exec();
// }
//}
void MainScreen::on_exportToCVSBtn_clicked()
{
if (loginHandel->isLoggedInFlag())
{
CalendarDialog calDialog;
int buttonClicked = calDialog.exec();
if(buttonClicked == 0)
return;
//calDialog.getStartDate(),calDialog.getEndDate()
if(calDialog.ok())
this->calendar->exportCalendarCSV(&calDialog);
else
showMSG("Somthig was not right with the dates you have chosen... try again");
}
}
=======
>>>>>>> 834ee3469ee46960c2484d38ba86a00793de84cc
void MainScreen::on_actionHebrew_triggered()
{
if (ui->actionEnglish->isChecked() || ui->actionOS_Default->isChecked())
{
ui->actionEnglish->setChecked(false);
ui->actionOS_Default->setChecked(false);
qDebug() << "Changed Language to hebrew";
data->setLocal("he");
QMessageBox::information(this,tr("Settings"),tr("Your settings will take effect next time you start the program"),QMessageBox::Ok);
}
else
ui->actionHebrew->setChecked(true);
}
void MainScreen::on_actionEnglish_triggered()
{
if (ui->actionHebrew->isChecked() || ui->actionOS_Default->isChecked())
{
ui->actionHebrew->setChecked(false);
ui->actionOS_Default->setChecked(false);
qDebug() << "Changed Language to English";
data->setLocal("en");
QMessageBox::information(this,"Settings",tr("Your settings will take effect next time you start the program"),QMessageBox::Ok);
}
else
ui->actionEnglish->setChecked(true);
}
void MainScreen::on_actionOS_Default_triggered()
{
if (ui->actionHebrew->isChecked() || ui->actionEnglish->isChecked())
{
ui->actionHebrew->setChecked(false);
ui->actionEnglish->setChecked(false);
qDebug() << "Changed Language to OS Default";
data->setLocal("default");
QMessageBox::information(this,tr("Settings"),tr("Your settings will take effect next time you start the program"),QMessageBox::Ok);
}
else
ui->actionOS_Default->setChecked(true);
}
void MainScreen::checkLocale()
{
if(data->getLocal() == "en")
{
ui->actionHebrew->setChecked(false);
ui->actionOS_Default->setChecked(false);
ui->actionEnglish->setChecked(true);
}else if(data->getLocal() == "he"){
ui->actionHebrew->setChecked(true);
ui->actionOS_Default->setChecked(false);
ui->actionEnglish->setChecked(false);
}else{
ui->actionHebrew->setChecked(false);
ui->actionOS_Default->setChecked(true);
ui->actionEnglish->setChecked(false);
}
}

View file

@ -5,7 +5,7 @@ CSV_Exporter::CSV_Exporter()
} }
bool CSV_Exporter::exportCalendar(calendarSchedule *calSched) bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *cal)
{ {
qDebug() << "Getting path for csv file from user..."; qDebug() << "Getting path for csv file from user...";
QString filePath = getFileFath(); QString filePath = getFileFath();
@ -39,22 +39,29 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched)
QString name = QString(coursePtr->getName().c_str()); QString name = QString(coursePtr->getName().c_str());
QString room = QString(coursePtr->getRoom().c_str()); QString room = QString(coursePtr->getRoom().c_str());
QString line = makeLine(name, day, startH, startM, endH, endM, lecturer, room, type); QDate currentDate = cal->getStartDate();
currentDate = currentDate.addDays(day-1);
for(;currentDate <= cal->getEndDate(); currentDate = currentDate.addDays(7))
{
QString line = makeLine(name, &currentDate, startH, startM, endH, endM, lecturer, room, type);
#ifdef Q_OS_LINUX || Q_OS_UNIX #ifdef Q_OS_LINUX || Q_OS_UNIX
if(line != NULL) if(line != NULL)
out << line << char(0x0A); out << line << char(0x0A);
#endif #endif
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
if(line != NULL) if(line != NULL)
out << line << char(0x0A); out << line << char(0x0A);
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if(line != NULL) if(line != NULL)
out << line << char(0x0D) << char(0x0A); out << line << char(0x0D) << char(0x0A);
#endif #endif
}
} }
here:
out.flush(); out.flush();
@ -74,10 +81,9 @@ QString CSV_Exporter::getFileFath()
return fileName; return fileName;
} }
QString CSV_Exporter::makeLine(QString name, int day, int startH, int startM, int endH, int endM, QString lecturer, QString room, QString type) 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 //Creating a CSV text line for Google Calendar/iCal/Outlook
// First day for semester 10/26/2014
QString CSV_line = ""; QString CSV_line = "";
QString subject = "\""; QString subject = "\"";
@ -86,30 +92,9 @@ QString CSV_Exporter::makeLine(QString name, int day, int startH, int startM, in
subject.append(type); subject.append(type);
subject.append("\""); subject.append("\"");
QString date;
switch (day) { QString dateStr = date->toString("MM/dd/yyyy");
case 1:
date = "10/26/2014";
break;
case 2:
date = "10/27/2014";
break;
case 3:
date = "10/28/2014";
break;
case 4:
date = "10/29/2014";
break;
case 5:
date = "10/30/2014";
break;
case 6:
date = "10/31/2014";
break;
default:
return NULL;
break;
}
QString start; QString start;
start.append(QString::number(startH)); start.append(QString::number(startH));
@ -135,13 +120,13 @@ QString CSV_Exporter::makeLine(QString name, int day, int startH, int startM, in
CSV_line.append(subject); CSV_line.append(subject);
CSV_line.append(","); CSV_line.append(",");
CSV_line.append(date); CSV_line.append(dateStr);
CSV_line.append(","); CSV_line.append(",");
CSV_line.append(start); CSV_line.append(start);
CSV_line.append(","); CSV_line.append(",");
CSV_line.append(date); CSV_line.append(dateStr);
CSV_line.append(","); CSV_line.append(",");
CSV_line.append(end); CSV_line.append(end);

View file

@ -8,6 +8,8 @@
#include <QDebug> #include <QDebug>
#include "../Calendar/calendarSchedule.h" #include "../Calendar/calendarSchedule.h"
#include "../Calendar/calendardialog.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"
@ -15,12 +17,12 @@ class CSV_Exporter
{ {
public: public:
CSV_Exporter(); CSV_Exporter();
static bool exportCalendar(calendarSchedule* calSched); static bool exportCalendar(calendarSchedule* calSched, CalendarDialog *cal);
private: private:
static QString getFileFath(); static QString getFileFath();
static QString makeLine(QString name,int day,int startH,int startM,int endH,int endM,QString lecturer,QString room,QString type); static QString makeLine(QString name,QDate *date,int startH,int startM,int endH,int endM,QString lecturer,QString room,QString type);
}; };
#endif // CSV_EXPORTER_H #endif // CSV_EXPORTER_H

View file

@ -0,0 +1,87 @@
#include "calendardialog.h"
#include "ui_calendardialog.h"
CalendarDialog::CalendarDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CalendarDialog)
{
ui->setupUi(this);
ui->calEnd->showToday();
ui->calStart->showToday();
this->isOK = false;
}
CalendarDialog::~CalendarDialog()
{
delete ui;
}
QDate CalendarDialog::getStartDate()
{
return ui->calStart->selectedDate();
}
QDate CalendarDialog::getEndDate()
{
return ui->calEnd->selectedDate();
}
bool CalendarDialog::ok()
{
return this->isOK;
}
void CalendarDialog::on_calStart_clicked(const QDate &date)
{
}
void CalendarDialog::on_calStart_selectionChanged()
{
if(ui->calStart->selectedDate() > ui->calEnd->selectedDate()){
ui->lbl_status->setText("[ X ] The End of the semester is before it starts... ");
this->isOK = false;
}else if(ui->calStart->selectedDate() == ui->calEnd->selectedDate()){
ui->lbl_status->setText("[ ! ] Semester Cannot start and end on the same date... Where are you studying?! :)");
this->isOK = false;
}else{
ui->lbl_status->setText("[ V ] Looks ok, Press OK");
this->isOK = true;
}
}
void CalendarDialog::on_buttonBox_accepted()
{
if(ui->calStart->selectedDate() > ui->calEnd->selectedDate())
qDebug() << "start bigger than end!";
}
void CalendarDialog::on_calEnd_clicked(const QDate &date)
{
}
void CalendarDialog::on_calStart_activated(const QDate &date)
{
//null
}
void CalendarDialog::on_calEnd_selectionChanged()
{
if(ui->calStart->selectedDate() > ui->calEnd->selectedDate()){
ui->lbl_status->setText("[ X ] The End of the semester is before it starts... ");
this->isOK = false;
}else if(ui->calStart->selectedDate() == ui->calEnd->selectedDate()){
ui->lbl_status->setText("[ ! ] Semester Cannot start and end on the same date... Where are you studying?! :)");
this->isOK = false;
}else{
ui->lbl_status->setText("[ V ] Looks ok, Press OK");
this->isOK = true;
}
}

View file

@ -0,0 +1,36 @@
#ifndef CALENDARDIALOG_H
#define CALENDARDIALOG_H
#include <QDialog>
#include <QDate>
#include <QDebug>
namespace Ui {
class CalendarDialog;
}
class CalendarDialog : public QDialog
{
Q_OBJECT
public:
explicit CalendarDialog(QWidget *parent = 0);
~CalendarDialog();
QDate getStartDate();
QDate getEndDate();
bool ok();
private slots:
void on_calStart_activated(const QDate &date);
void on_calStart_selectionChanged();
void on_calStart_clicked(const QDate &date);
void on_buttonBox_accepted();
void on_calEnd_clicked(const QDate &date);
void on_calEnd_selectionChanged();
private:
Ui::CalendarDialog *ui;
bool isOK;
};
#endif // CALENDARDIALOG_H

View file

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CalendarDialog</class>
<widget class="QDialog" name="CalendarDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>671</width>
<height>343</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;h1&gt;&lt;b&gt;For The Best CSV Export, Please Enter Correctly</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Semester Starts At:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Semester Ends At:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCalendarWidget" name="calStart"/>
</item>
<item>
<widget class="QCalendarWidget" name="calEnd"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_status">
<property name="text">
<string>[ ! ] Start &amp; End cannot be the same</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CalendarDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CalendarDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>