From cd43b26d504623069338c45bf5708bc0434173d8 Mon Sep 17 00:00:00 2001 From: Liran BN Date: Mon, 8 Sep 2014 17:29:49 +0300 Subject: [PATCH] CVS OPTION ADDED, minor improvments --- jceGrade.pro.user | 251 ++++++++++++++++++++++++ main/CalendarTab/CalendarManager.cpp | 22 ++- main/CalendarTab/CalendarManager.h | 7 +- main/LoginTab/loginhandler.cpp | 6 +- main/mainscreen.cpp | 63 +++--- main/mainscreen.h | 11 +- main/mainscreen.ui | 38 +++- src/jceData/CSV/csv_exporter.cpp | 6 + src/jceData/Calendar/calendarCourse.cpp | 2 +- src/jceSettings/jcelogin.cpp | 6 +- src/jceSettings/jcelogin.h | 2 +- 11 files changed, 369 insertions(+), 45 deletions(-) create mode 100644 jceGrade.pro.user diff --git a/jceGrade.pro.user b/jceGrade.pro.user new file mode 100644 index 0000000..09074ff --- /dev/null +++ b/jceGrade.pro.user @@ -0,0 +1,251 @@ + + + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.3.0 MinGW 32bit + Desktop Qt 5.3.0 MinGW 32bit + qt.53.win32_mingw482_kit + 0 + 0 + 0 + + D:/Dropbox/cpp/jceConQT/build-jceGrade-Desktop_Qt_5_3_0_MinGW_32bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + D:/Dropbox/cpp/jceConQT/build-jceGrade-Desktop_Qt_5_3_0_MinGW_32bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + jceGrade + + Qt4ProjectManager.Qt4RunConfiguration:D:/Dropbox/cpp/jceConQT/jceAverageCalculator/jceGrade.pro + + jceGrade.pro + false + false + + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {f3f3b933-8225-47b3-aa78-fc5de0bd714b} + + + ProjectExplorer.Project.Updater.FileVersion + 15 + + diff --git a/main/CalendarTab/CalendarManager.cpp b/main/CalendarTab/CalendarManager.cpp index addeaac..e157e11 100644 --- a/main/CalendarTab/CalendarManager.cpp +++ b/main/CalendarTab/CalendarManager.cpp @@ -5,12 +5,24 @@ CalendarManager::CalendarManager(calendarSchedule *ptr) this->caliSchedPtr = ptr; } +void CalendarManager::exportCalendarCSV() +{ + if(CSV_Exporter::exportCalendar(this->caliSchedPtr)) + { + QMessageBox msgBox; + msgBox.setText("
Exported Successfuly!
HaazZaA!!"); + msgBox.exec(); + }else + { + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Critical); + msgBox.setText("
Something went wrong...
Maybe:
  • You Canceled
  • Unable to save the File - try again


" + "
In case of a serious problem, please file a bug report.
thank you. OpenJCE teem"); + msgBox.exec(); + } +} + void CalendarManager::setCalendar(std::string html) { caliSchedPtr->setPage(html); } - -calendarSchedule *CalendarManager::getSch() -{ - return this->caliSchedPtr; -} diff --git a/main/CalendarTab/CalendarManager.h b/main/CalendarTab/CalendarManager.h index e7a9737..90083dc 100644 --- a/main/CalendarTab/CalendarManager.h +++ b/main/CalendarTab/CalendarManager.h @@ -3,6 +3,9 @@ #include "./src/jceData/Calendar/calendarPage.h" #include "./src/jceData/Calendar/calendarSchedule.h" +#include "./src/jceData/CSV/csv_exporter.h" + +#include #include class CalendarManager @@ -13,10 +16,10 @@ public: { delete caliSchedPtr; } - + void exportCalendarCSV(); void setCalendar(std::string html); void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); } - calendarSchedule* getSch(); + private: calendarSchedule * caliSchedPtr; }; diff --git a/main/LoginTab/loginhandler.cpp b/main/LoginTab/loginhandler.cpp index 5480bd7..4beb8ae 100644 --- a/main/LoginTab/loginhandler.cpp +++ b/main/LoginTab/loginhandler.cpp @@ -85,7 +85,11 @@ bool loginHandler::makeConnection() bool loginHandler::isLoggedInFlag() { - return this->logggedInFlag; + if (jceLog->isLoginFlag()) //checking connection and then if logged in + return this->logggedInFlag; + else + this->setLoginFlag(false); + return false; } void loginHandler::setLoginFlag(bool flag) diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index b7f4d6b..19ed402 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -13,6 +13,7 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr ui->pswdLineEdit->setEchoMode((QLineEdit::Password)); //Status Bar + ui->actionEnglish->setChecked(true); ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };"); ButtomStatusLabel = new QLabel(this); statusLabel = new QLabel(this); @@ -52,7 +53,6 @@ MainScreen::~MainScreen() delete userLoginSetting; delete loginHandel; delete ui; - //Delete save data delete data; } @@ -60,12 +60,16 @@ void MainScreen::on_loginButton_clicked() { if (loginHandel->isLoggedInFlag()) uiSetDisconnectMode(); - else uiSetConnectMode(); - } -void MainScreen::on_pushButton_clicked() + +void MainScreen::on_exportToCVSBtn_clicked() +{ + if (loginHandel->isLoggedInFlag()) + this->calendar->exportCalendarCSV(); +} +void MainScreen::on_getCalendarBtn_clicked() { int status = 0; if (loginHandel->isLoggedInFlag()) @@ -74,7 +78,7 @@ void MainScreen::on_pushButton_clicked() { //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->resetTable(); calendar->setCalendar(loginHandel->getCurrentPageContect().toStdString()); } @@ -102,9 +106,6 @@ void MainScreen::on_ratesButton_clicked() QMessageBox::critical(this,tr("Error"),tr("Not Connected")); } } - - - } void MainScreen::on_checkBoxCoursesInfluence_toggled(bool checked) { @@ -174,7 +175,9 @@ void MainScreen::uiSetDisconnectMode() loginHandel->makeDisconnectionRequest(); ui->loginButton->setText("&Login"); - this->ui->ratesButton->setDisabled(true); + ui->ratesButton->setDisabled(true); + ui->exportToCVSBtn->setDisabled(true); + ui->getCalendarBtn->setDisabled(true); return; } @@ -203,9 +206,12 @@ void MainScreen::uiSetConnectMode() //fix before distrbute { setLabelConnectionStatus(jceLogin::jceStatus::JCE_YOU_ARE_IN); ui->loginButton->setText("&Logout"); - this->ui->ratesButton->setEnabled(true); + ui->ratesButton->setEnabled(true); ui->CoursesTab->setEnabled(true); + ui->exportToCVSBtn->setEnabled(true); + ui->getCalendarBtn->setEnabled(true); + } else { @@ -246,10 +252,6 @@ void MainScreen::on_actionCredits_triggered() "" - +tr("Tnks")+ "... :" - ""); } @@ -292,19 +294,30 @@ void MainScreen::on_actionHow_To_triggered() } -void MainScreen::on_pushButton_2_clicked() +void MainScreen::on_actionHebrew_triggered() { - if(CSV_Exporter::exportCalendar(this->calendar->getSch())) + if (ui->actionEnglish->isChecked()) { - QMessageBox msgBox; - msgBox.setText("
Exported Successfuly!
HaazZaA!!"); - msgBox.exec(); - }else + ui->actionEnglish->setChecked(false); + qDebug() << "Changed Language"; + } + else { - QMessageBox msgBox; - msgBox.setIcon(QMessageBox::Critical); - msgBox.setText("
Something went wrong...
Maybe:
  • You Canceled
  • Unable to save the File - try again


" - "
In case of a serious problem, please file a bug report.
thank you. OpenJCE teem"); - msgBox.exec(); + ui->actionHebrew->setChecked(true); + qDebug() << "Set Hebrew Language: "; + } +} + +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: "; } } diff --git a/main/mainscreen.h b/main/mainscreen.h index 0c68e4b..5b05ba4 100644 --- a/main/mainscreen.h +++ b/main/mainscreen.h @@ -13,7 +13,6 @@ #include "./CourseTab/coursestablemanager.h" #include "./LoginTab/loginhandler.h" #include "./CalendarTab/CalendarManager.h" -#include "../src/jceData/CSV/csv_exporter.h" #define StatusIconHeight 35 namespace Ui { @@ -56,11 +55,15 @@ private slots: void on_actionHow_To_triggered(); - void on_pushButton_clicked(); - void on_checkBoxCoursesInfluence_toggled(bool checked); - void on_pushButton_2_clicked(); + void on_exportToCVSBtn_clicked(); + + void on_getCalendarBtn_clicked(); + + void on_actionHebrew_triggered(); + + void on_actionEnglish_triggered(); private: diff --git a/main/mainscreen.ui b/main/mainscreen.ui index a9c42a5..0132891 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -582,14 +582,20 @@ font-size: 15px; - + + + false + Get Calendar - + + + false + Export to CSV @@ -626,13 +632,21 @@ font-size: 15px; 0 0 855 - 29 + 21 - &About + &File + + + Language + + + + + @@ -668,6 +682,22 @@ font-size: 15px; How-To + + + true + + + Hebrew + + + + + true + + + English + + diff --git a/src/jceData/CSV/csv_exporter.cpp b/src/jceData/CSV/csv_exporter.cpp index dc2159e..b7f9ab9 100644 --- a/src/jceData/CSV/csv_exporter.cpp +++ b/src/jceData/CSV/csv_exporter.cpp @@ -7,6 +7,8 @@ CSV_Exporter::CSV_Exporter() bool CSV_Exporter::exportCalendar(calendarSchedule *calSched) { + if (calSched == NULL) + return false; qDebug() << "Getting path for csv file from user..."; QString filePath = getFileFath(); if(filePath == NULL) //User canceled @@ -40,6 +42,10 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched) QString room = QString(coursePtr->getRoom().c_str()); QString line = makeLine(name, day, startH, startM, endH, endM, lecturer, room, type); +#ifndef Q_OS_WIN32 + if(line != NULL) + out << line << char(0x0D) << " "; +#endif if(line != NULL) out << line << char(0x0A); } diff --git a/src/jceData/Calendar/calendarCourse.cpp b/src/jceData/Calendar/calendarCourse.cpp index 8e534b5..0296266 100644 --- a/src/jceData/Calendar/calendarCourse.cpp +++ b/src/jceData/Calendar/calendarCourse.cpp @@ -107,7 +107,7 @@ std::string calendarCourse::courseToString() courseText += " " + this->lecturer; courseText += " " + std::to_string(this->getPoints()); 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 += " " + this->room; courseText += "\n"; diff --git a/src/jceSettings/jcelogin.cpp b/src/jceSettings/jcelogin.cpp index 161cdea..b666e76 100644 --- a/src/jceSettings/jcelogin.cpp +++ b/src/jceSettings/jcelogin.cpp @@ -82,7 +82,7 @@ void jceLogin::makeConnection() throw (jceStatus) } -bool jceLogin::checkConnection() +bool jceLogin::checkConnection() const { if (JceConnector->isConnected()) return true; @@ -187,7 +187,9 @@ void jceLogin::setLoginFlag(bool x) } bool jceLogin::isLoginFlag() const { - return this->loginFlag; + if (checkConnection()) + return this->loginFlag; + return false; } std::string jceLogin::getPage() diff --git a/src/jceSettings/jcelogin.h b/src/jceSettings/jcelogin.h index dfcb593..d861d6d 100644 --- a/src/jceSettings/jcelogin.h +++ b/src/jceSettings/jcelogin.h @@ -30,7 +30,7 @@ public: jceLogin(user* username); ~jceLogin(); void makeConnection() throw (jceStatus); - bool checkConnection(); + bool checkConnection() const; void reConnect() throw (jceStatus); void closeAll(); int getCalendar(int year, int semester);