Added CSV on linux, mac, windows

This commit is contained in:
Liran Ben gida 2014-09-08 18:54:52 +03:00
parent 4fa27283d9
commit 235354210b
31 changed files with 2811 additions and 2712 deletions

View file

@ -9,8 +9,22 @@ void CalendarManager::setCalendar(std::string html)
{ {
caliSchedPtr->setPage(html); caliSchedPtr->setPage(html);
} }
void CalendarManager::exportCalendarCSV()
calendarSchedule *CalendarManager::getSch()
{ {
return this->caliSchedPtr; if(CSV_Exporter::exportCalendar(this->caliSchedPtr))
{
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();
}
} }

View file

@ -3,7 +3,9 @@
#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 <iostream> #include <iostream>
#include <QMessageBox>
class CalendarManager class CalendarManager
{ {
@ -13,10 +15,10 @@ public:
{ {
delete caliSchedPtr; delete caliSchedPtr;
} }
void exportCalendarCSV();
void setCalendar(std::string html); void setCalendar(std::string html);
void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); } void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); }
calendarSchedule* getSch();
private: private:
calendarSchedule * caliSchedPtr; calendarSchedule * caliSchedPtr;
}; };

View file

@ -85,7 +85,11 @@ bool loginHandler::makeConnection()
bool loginHandler::isLoggedInFlag() bool loginHandler::isLoggedInFlag()
{ {
if (jceLog->isLoginFlag()) //checking connection and then if logged in
return this->logggedInFlag; return this->logggedInFlag;
else
this->setLoginFlag(false);
return false;
} }
void loginHandler::setLoginFlag(bool flag) void loginHandler::setLoginFlag(bool flag)

View file

@ -13,6 +13,7 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
ui->pswdLineEdit->setEchoMode((QLineEdit::Password)); ui->pswdLineEdit->setEchoMode((QLineEdit::Password));
//Status Bar //Status Bar
ui->actionEnglish->setChecked(true);
ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };"); ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };");
ButtomStatusLabel = new QLabel(this); ButtomStatusLabel = new QLabel(this);
statusLabel = new QLabel(this); statusLabel = new QLabel(this);
@ -65,7 +66,7 @@ void MainScreen::on_loginButton_clicked()
uiSetConnectMode(); uiSetConnectMode();
} }
void MainScreen::on_pushButton_clicked() void MainScreen::on_getCalendarBtn_clicked()
{ {
int status = 0; int status = 0;
if (loginHandel->isLoggedInFlag()) if (loginHandel->isLoggedInFlag())
@ -174,7 +175,9 @@ void MainScreen::uiSetDisconnectMode()
loginHandel->makeDisconnectionRequest(); loginHandel->makeDisconnectionRequest();
ui->loginButton->setText("&Login"); ui->loginButton->setText("&Login");
this->ui->ratesButton->setDisabled(true); ui->getCalendarBtn->setDisabled(true);
ui->exportToCVSBtn->setDisabled(true);
ui->ratesButton->setDisabled(true);
return; return;
} }
@ -203,8 +206,10 @@ void MainScreen::uiSetConnectMode() //fix before distrbute
{ {
setLabelConnectionStatus(jceLogin::jceStatus::JCE_YOU_ARE_IN); setLabelConnectionStatus(jceLogin::jceStatus::JCE_YOU_ARE_IN);
ui->loginButton->setText("&Logout"); ui->loginButton->setText("&Logout");
this->ui->ratesButton->setEnabled(true); ui->ratesButton->setEnabled(true);
ui->CoursesTab->setEnabled(true); ui->CoursesTab->setEnabled(true);
ui->exportToCVSBtn->setEnabled(true);
ui->getCalendarBtn->setEnabled(true);
} }
else else
@ -246,10 +251,6 @@ void MainScreen::on_actionCredits_triggered()
"<ul>" "<ul>"
"<li><a href='mailto:liranbg@gmail.com'>"+tr("Liran")+"</a></li>" "<li><a href='mailto:liranbg@gmail.com'>"+tr("Liran")+"</a></li>"
"<li><a href='mailto:sagidayan@gmail.com'>"+tr("Sagi")+"</a></li>" "<li><a href='mailto:sagidayan@gmail.com'>"+tr("Sagi")+"</a></li>"
"</ul>"
+tr("Tnks")+ "... :"
"<ul>"
"<li><a href='mailto:nadav2051@gmail.com'>"+tr("Nadav")+"</a></li>"
"</ul>"); "</ul>");
} }
@ -292,19 +293,64 @@ void MainScreen::on_actionHow_To_triggered()
} }
void MainScreen::on_pushButton_2_clicked() //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(CSV_Exporter::exportCalendar(this->calendar->getSch())) if (loginHandel->isLoggedInFlag())
this->calendar->exportCalendarCSV();
}
void MainScreen::on_actionHebrew_triggered()
{
if (ui->actionEnglish->isChecked())
{ {
QMessageBox msgBox; ui->actionEnglish->setChecked(false);
msgBox.setText("<center>Exported Successfuly!<br><b>HaazZaA!!"); qDebug() << "Changed Language";
msgBox.exec(); }
}else else
{ {
QMessageBox msgBox; ui->actionHebrew->setChecked(true);
msgBox.setIcon(QMessageBox::Critical); qDebug() << "Set Hebrew Language: ";
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_actionEnglish_triggered()
{
if (ui->actionHebrew->isChecked())
{
ui->actionHebrew->setChecked(false);
qDebug() << "Changed Language";
}
else
{
ui->actionEnglish->setChecked(true);
qDebug() << "Set English Language: ";
} }
} }

View file

@ -13,7 +13,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 "../src/jceData/CSV/csv_exporter.h"
#define StatusIconHeight 35 #define StatusIconHeight 35
namespace Ui { namespace Ui {
@ -56,11 +56,15 @@ private slots:
void on_actionHow_To_triggered(); void on_actionHow_To_triggered();
void on_pushButton_clicked(); void on_getCalendarBtn_clicked();
void on_checkBoxCoursesInfluence_toggled(bool checked); void on_checkBoxCoursesInfluence_toggled(bool checked);
void on_pushButton_2_clicked(); void on_exportToCVSBtn_clicked();
void on_actionHebrew_triggered();
void on_actionEnglish_triggered();
private: private:

View file

@ -582,14 +582,14 @@ font-size: 15px;
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="getCalendarBtn">
<property name="text"> <property name="text">
<string>Get Calendar</string> <string>Get Calendar</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_2"> <widget class="QPushButton" name="exportToCVSBtn">
<property name="text"> <property name="text">
<string>Export to CSV</string> <string>Export to CSV</string>
</property> </property>
@ -626,14 +626,21 @@ font-size: 15px;
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>855</width> <width>855</width>
<height>29</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuA_about"> <widget class="QMenu" name="menuA_about">
<property name="title"> <property name="title">
<string>&amp;About</string> <string>&amp;About</string>
</property> </property>
<addaction name="actionHow_To"/> <widget class="QMenu" name="menuLanguage">
<property name="title">
<string>Language</string>
</property>
<addaction name="actionHebrew"/>
<addaction name="actionEnglish"/>
</widget>
<addaction name="menuLanguage"/>
<addaction name="actionCredits"/> <addaction name="actionCredits"/>
<addaction name="actionExit"/> <addaction name="actionExit"/>
</widget> </widget>
@ -663,9 +670,20 @@ font-size: 15px;
<string>Exit</string> <string>Exit</string>
</property> </property>
</action> </action>
<action name="actionHow_To"> <action name="actionHebrew">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text"> <property name="text">
<string>How-To</string> <string>hebrew</string>
</property>
</action>
<action name="actionEnglish">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>English</string>
</property> </property>
</action> </action>
</widget> </widget>

View file

@ -40,8 +40,16 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched)
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); QString line = makeLine(name, day, startH, startM, endH, endM, lecturer, room, type);
#ifndef _WIN32
if(line != NULL)
out << line << char(0x0D) << " ";
#elif __APPLE__ && __MACH__
if(line != NULL)
out << line << char(0x0D) << " ";
#elif __LINUX__
if(line != NULL) if(line != NULL)
out << line << char(0x0A); out << line << char(0x0A);
#endif
} }

View file

@ -107,7 +107,7 @@ std::string calendarCourse::courseToString()
courseText += " " + this->lecturer; courseText += " " + this->lecturer;
courseText += " " + std::to_string(this->getPoints()); courseText += " " + std::to_string(this->getPoints());
courseText += " " + std::to_string(this->semesterHours); courseText += " " + std::to_string(this->semesterHours);
courseText += " " + this->day; courseText += " " + std::to_string(this->day);
courseText += " " + std::to_string(this->hourBegin) + ":" + std::to_string(this->minutesBegin) + "-" + std::to_string(this->hourEnd) + ":" + std::to_string(this->minutesEnd); courseText += " " + std::to_string(this->hourBegin) + ":" + std::to_string(this->minutesBegin) + "-" + std::to_string(this->hourEnd) + ":" + std::to_string(this->minutesEnd);
courseText += " " + this->room; courseText += " " + this->room;
courseText += "\n"; courseText += "\n";

View file

@ -82,7 +82,7 @@ void jceLogin::makeConnection() throw (jceStatus)
} }
bool jceLogin::checkConnection() bool jceLogin::checkConnection() const
{ {
if (JceConnector->isConnected()) if (JceConnector->isConnected())
return true; return true;
@ -187,7 +187,10 @@ void jceLogin::setLoginFlag(bool x)
} }
bool jceLogin::isLoginFlag() const bool jceLogin::isLoginFlag() const
{ {
if (checkConnection())
return this->loginFlag; return this->loginFlag;
return false;
} }
std::string jceLogin::getPage() std::string jceLogin::getPage()

View file

@ -30,7 +30,7 @@ public:
jceLogin(user* username); jceLogin(user* username);
~jceLogin(); ~jceLogin();
void makeConnection() throw (jceStatus); void makeConnection() throw (jceStatus);
bool checkConnection(); bool checkConnection() const;
void reConnect() throw (jceStatus); void reConnect() throw (jceStatus);
void closeAll(); void closeAll();
int getCalendar(int year, int semester); int getCalendar(int year, int semester);