From bc7d61fa388bb6d3da3cdda037385c24874b31d0 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Tue, 9 Sep 2014 14:40:11 +0300 Subject: [PATCH 1/3] Undeg HARD dev - calendar dialog for helping CSV exporter --- jceGrade.pro | 125 ++++++++++++------------ main/CalendarTab/CalendarManager.h | 2 + main/mainscreen.cpp | 7 ++ main/mainscreen.ui | 2 +- src/jceData/Calendar/calendardialog.cpp | 41 ++++++++ src/jceData/Calendar/calendardialog.h | 33 +++++++ src/jceData/Calendar/calendardialog.ui | 118 ++++++++++++++++++++++ 7 files changed, 266 insertions(+), 62 deletions(-) create mode 100644 src/jceData/Calendar/calendardialog.cpp create mode 100644 src/jceData/Calendar/calendardialog.h create mode 100644 src/jceData/Calendar/calendardialog.ui diff --git a/jceGrade.pro b/jceGrade.pro index b047781..60edea4 100644 --- a/jceGrade.pro +++ b/jceGrade.pro @@ -1,61 +1,64 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2014-05-31T19:49:42 -# -#------------------------------------------------- - -QT += core gui network widgets -TARGET = jceGrade -TEMPLATE = app -RC_FILE = appConfigure.rc -CONFIG += qt c++11 -CONFIG += console - - -FORMS += \ - main/mainscreen.ui - -OTHER_FILES += - -RESOURCES += \ - resources/connectionstatus.qrc - -HEADERS += \ - main/CalendarTab/CalendarManager.h \ - main/CourseTab/coursestablemanager.h \ - main/LoginTab/loginhandler.h \ - main/mainscreen.h \ - src/appDatabase/savedata.h \ - src/jceConnection/jcesslclient.h \ - src/jceData/Calendar/calendarPage.h \ - src/jceData/Grades/gradeCourse.h \ - src/jceData/Grades/gradePage.h \ - src/jceData/course.h \ - src/jceData/page.h \ - src/jceSettings/jcelogin.h \ - src/jceSettings/jceLoginHtmlScripts.h \ - src/jceSettings/user.h \ - src/jceData/Calendar/calendarCourse.h \ - src/jceData/Calendar/calendarSchedule.h \ - src/jceData/CSV/csv_exporter.h \ - src/appDatabase/simplecrypt.h - -SOURCES += \ - main/CalendarTab/CalendarManager.cpp \ - main/CourseTab/coursestablemanager.cpp \ - main/LoginTab/loginhandler.cpp \ - main/main.cpp \ - main/mainscreen.cpp \ - src/appDatabase/savedata.cpp \ - src/jceConnection/jcesslclient.cpp \ - src/jceData/Calendar/calendarPage.cpp \ - src/jceData/Grades/gradeCourse.cpp \ - src/jceData/Grades/gradePage.cpp \ - src/jceData/page.cpp \ - src/jceSettings/jcelogin.cpp \ - src/jceSettings/user.cpp \ - src/jceData/Calendar/calendarCourse.cpp \ - src/jceData/Calendar/calendarSchedule.cpp \ - src/jceData/CSV/csv_exporter.cpp \ - src/appDatabase/simplecrypt.cpp - +#------------------------------------------------- +# +# Project created by QtCreator 2014-05-31T19:49:42 +# +#------------------------------------------------- + +QT += core gui network widgets +TARGET = jceGrade +TEMPLATE = app +RC_FILE = appConfigure.rc +CONFIG += qt c++11 +CONFIG += console + + +FORMS += \ + main/mainscreen.ui \ + src/jceData/Calendar/calendardialog.ui + +OTHER_FILES += + +RESOURCES += \ + resources/connectionstatus.qrc + +HEADERS += \ + main/CalendarTab/CalendarManager.h \ + main/CourseTab/coursestablemanager.h \ + main/LoginTab/loginhandler.h \ + main/mainscreen.h \ + src/appDatabase/savedata.h \ + src/jceConnection/jcesslclient.h \ + src/jceData/Calendar/calendarPage.h \ + src/jceData/Grades/gradeCourse.h \ + src/jceData/Grades/gradePage.h \ + src/jceData/course.h \ + src/jceData/page.h \ + src/jceSettings/jcelogin.h \ + src/jceSettings/jceLoginHtmlScripts.h \ + src/jceSettings/user.h \ + src/jceData/Calendar/calendarCourse.h \ + src/jceData/Calendar/calendarSchedule.h \ + src/jceData/CSV/csv_exporter.h \ + src/appDatabase/simplecrypt.h \ + src/jceData/Calendar/calendardialog.h + +SOURCES += \ + main/CalendarTab/CalendarManager.cpp \ + main/CourseTab/coursestablemanager.cpp \ + main/LoginTab/loginhandler.cpp \ + main/main.cpp \ + main/mainscreen.cpp \ + src/appDatabase/savedata.cpp \ + src/jceConnection/jcesslclient.cpp \ + src/jceData/Calendar/calendarPage.cpp \ + src/jceData/Grades/gradeCourse.cpp \ + src/jceData/Grades/gradePage.cpp \ + src/jceData/page.cpp \ + src/jceSettings/jcelogin.cpp \ + src/jceSettings/user.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 + diff --git a/main/CalendarTab/CalendarManager.h b/main/CalendarTab/CalendarManager.h index 43a8f4d..1a92f8c 100644 --- a/main/CalendarTab/CalendarManager.h +++ b/main/CalendarTab/CalendarManager.h @@ -4,6 +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 #include @@ -21,6 +22,7 @@ public: private: calendarSchedule * caliSchedPtr; + }; #endif // CALENDARMANAGER_H diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index a7c0ec7..f6c4b74 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -337,7 +337,14 @@ 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() this->calendar->exportCalendarCSV(); + } } void MainScreen::on_actionHebrew_triggered() diff --git a/main/mainscreen.ui b/main/mainscreen.ui index 837858b..8200986 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -61,7 +61,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r QTabWidget::Rounded - 0 + 2 false diff --git a/src/jceData/Calendar/calendardialog.cpp b/src/jceData/Calendar/calendardialog.cpp new file mode 100644 index 0000000..310ff1d --- /dev/null +++ b/src/jceData/Calendar/calendardialog.cpp @@ -0,0 +1,41 @@ +#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(); +} + +CalendarDialog::~CalendarDialog() +{ + delete ui; +} + +QDate CalendarDialog::getStartDate() +{ + return ui->calStart->selectedDate(); +} + +QDate CalendarDialog::getEndDate() +{ + return ui->calEnd->selectedDate(); +} + + + + + +void CalendarDialog::on_calStart_clicked(const QDate &date) +{ + qDebug() << "FUCK!!!"; +} + +void CalendarDialog::on_calStart_selectionChanged() +{ + qDebug() << "selection **************************************"; +} diff --git a/src/jceData/Calendar/calendardialog.h b/src/jceData/Calendar/calendardialog.h new file mode 100644 index 0000000..36da197 --- /dev/null +++ b/src/jceData/Calendar/calendardialog.h @@ -0,0 +1,33 @@ +#ifndef CALENDARDIALOG_H +#define CALENDARDIALOG_H + +#include +#include +#include + +namespace Ui { +class CalendarDialog; +} + +class CalendarDialog : public QDialog +{ + Q_OBJECT + +public: + explicit CalendarDialog(QWidget *parent = 0); + ~CalendarDialog(); + QDate getStartDate(); + QDate getEndDate(); + +private slots: + void on_calStart_activated(const QDate &date); + + void on_calStart_selectionChanged(); + + void on_calStart_clicked(const QDate &date); + +private: + Ui::CalendarDialog *ui; +}; + +#endif // CALENDARDIALOG_H diff --git a/src/jceData/Calendar/calendardialog.ui b/src/jceData/Calendar/calendardialog.ui new file mode 100644 index 0000000..7dd0a69 --- /dev/null +++ b/src/jceData/Calendar/calendardialog.ui @@ -0,0 +1,118 @@ + + + CalendarDialog + + + + 0 + 0 + 671 + 343 + + + + Dialog + + + + + + + + <h1><b>For The Best CSV Export, Please Enter Correctly + + + + + + + + + + + + + Semester Starts At: + + + + + + + Semester Ends At: + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + [ ! ] Start & End cannot be the same + + + + + + + + + + + + + buttonBox + accepted() + CalendarDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CalendarDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From eb5de02be2e617e73d40f46fae8c52eb60ec547b Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Tue, 9 Sep 2014 21:24:53 +0300 Subject: [PATCH 2/3] Fixes to the Calendar Dialog. QA --- main/CalendarTab/CalendarManager.cpp | 2 +- main/CalendarTab/CalendarManager.h | 2 +- main/mainscreen.cpp | 5 +- main/mainscreen.cpp.autosave | 394 ++++++++++++++++++++++++ src/jceData/Calendar/calendardialog.cpp | 50 ++- src/jceData/Calendar/calendardialog.h | 7 +- 6 files changed, 453 insertions(+), 7 deletions(-) create mode 100644 main/mainscreen.cpp.autosave diff --git a/main/CalendarTab/CalendarManager.cpp b/main/CalendarTab/CalendarManager.cpp index 4f41dbf..cb7c4a2 100644 --- a/main/CalendarTab/CalendarManager.cpp +++ b/main/CalendarTab/CalendarManager.cpp @@ -9,7 +9,7 @@ void CalendarManager::setCalendar(std::string html) { caliSchedPtr->setPage(html); } -void CalendarManager::exportCalendarCSV() +void CalendarManager::exportCalendarCSV(CalendarDialog *calDialog) { if(CSV_Exporter::exportCalendar(this->caliSchedPtr)) { diff --git a/main/CalendarTab/CalendarManager.h b/main/CalendarTab/CalendarManager.h index 1a92f8c..c9d56b8 100644 --- a/main/CalendarTab/CalendarManager.h +++ b/main/CalendarTab/CalendarManager.h @@ -16,7 +16,7 @@ public: { delete caliSchedPtr; } - void exportCalendarCSV(); + void exportCalendarCSV(CalendarDialog*); void setCalendar(std::string html); void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); } diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index f6c4b74..01193ef 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -343,7 +343,10 @@ void MainScreen::on_exportToCVSBtn_clicked() if(buttonClicked == 0) return; //calDialog.getStartDate(),calDialog.getEndDate() - this->calendar->exportCalendarCSV(); + if(calDialog.ok()) + this->calendar->exportCalendarCSV(&calDialog); + else + showMSG("Somthig was not right with the dates you chose... try again"); } } diff --git a/main/mainscreen.cpp.autosave b/main/mainscreen.cpp.autosave new file mode 100644 index 0000000..bf15bf2 --- /dev/null +++ b/main/mainscreen.cpp.autosave @@ -0,0 +1,394 @@ +#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 + 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); + 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 + //SaveData::init(); --> No need. constructor dose everything. + if (data->isSaved()) + { + ui->usrnmLineEdit->setText(data->getUsername()); + ui->pswdLineEdit->setText(data->getPassword()); + ui->keepLogin->setChecked(true); + } + + //Local Check and ui setting. + 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); + } + +} + +MainScreen::~MainScreen() +{ + delete userLoginSetting; + delete loginHandel; + delete ui; + + //Delete save data + delete data; +} +void MainScreen::on_loginButton_clicked() +{ + if (loginHandel->isLoggedInFlag()) + uiSetDisconnectMode(); + + else + uiSetConnectMode(); + +} +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_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,"Error","Missmatching data"); +} + +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("&Login"); + ui->getCalendarBtn->setDisabled(true); + ui->exportToCVSBtn->setDisabled(true); + ui->ratesButton->setDisabled(true); + return; +} + +void MainScreen::uiSetConnectMode() //fix before distrbute +{ + string username; + string password; + if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty())) + { + //add icon near to username and password to mark it + return; + } + 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("&Logout"); + ui->ratesButton->setEnabled(true); + ui->CoursesTab->setEnabled(true); + ui->exportToCVSBtn->setEnabled(true); + ui->getCalendarBtn->setEnabled(true); + + } + else + { + uiSetDisconnectMode(); + } +} +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(); +} + +void MainScreen::showMSG(QString msg) +{ + QMessageBox msgBox; + msgBox.setText(msg); + msgBox.exec(); +} +void MainScreen::on_actionCredits_triggered() +{ + QMessageBox::about(this, "About", tr("CREDITS-ROOL-UP1") + " v1.0

" + + tr("CREDITS-ROOL-UP2")+"
GNU LESSER GENERAL PUBLIC LICENSE V2
" + + tr("CREDITS-ROOL-UP3")+"
" + "jceAverageCalculator Repository" + "

"+tr("CREDITS-ROOL-UP4")+" Jce Connection

" + +tr("DevBy")+":" + ""); +} + +void MainScreen::on_clearTableButton_clicked() +{ + + courseTableMgr->clearTable(); + ui->avgLCD->display(courseTableMgr->getAvg()); +} + +void MainScreen::on_actionExit_triggered() +{ + exit(0); +} + + +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_actionHow_To_triggered() +{ + QMessageBox::information(this,"How To", + "How To.." + "
    " + "
  • "+tr("HELP1")+"
  • " + "
  • "+tr("HELP2")+"
  • " + "
  • "+tr("HELP3")+"
  • " + "
  • "+tr("HELP4")+"
  • " + "
  • "+tr("HELP5")+"
  • " + "

    "+tr("HELP6")+ + "
"); + +} + +//void MainScreen::on_pushButton_2_clicked() +//{ +// if(CSV_Exporter::exportCalendar(this->calendar->getSch())) +// { +// 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 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() +{ + 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"); + showMSG("ההגדרות שלך יכנסו לתוקף בהפעלה הבאה של התוכנית"); + } + 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"); + showMSG("Your settings will take effect next time you start the program"); + } + 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"); + showMSG("Your settings will take effect next time you start the program"); + } + else + ui->actionOS_Default->setChecked(true); +} diff --git a/src/jceData/Calendar/calendardialog.cpp b/src/jceData/Calendar/calendardialog.cpp index 310ff1d..75b6a26 100644 --- a/src/jceData/Calendar/calendardialog.cpp +++ b/src/jceData/Calendar/calendardialog.cpp @@ -9,6 +9,8 @@ CalendarDialog::CalendarDialog(QWidget *parent) : ui->setupUi(this); ui->calEnd->showToday(); ui->calStart->showToday(); + + this->isOK = false; } CalendarDialog::~CalendarDialog() @@ -26,16 +28,60 @@ QDate CalendarDialog::getEndDate() return ui->calEnd->selectedDate(); } +bool CalendarDialog::ok() +{ + return this->isOK; +} + void CalendarDialog::on_calStart_clicked(const QDate &date) { - qDebug() << "FUCK!!!"; + } void CalendarDialog::on_calStart_selectionChanged() { - qDebug() << "selection **************************************"; + 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; + } } diff --git a/src/jceData/Calendar/calendardialog.h b/src/jceData/Calendar/calendardialog.h index 36da197..dc79173 100644 --- a/src/jceData/Calendar/calendardialog.h +++ b/src/jceData/Calendar/calendardialog.h @@ -18,16 +18,19 @@ public: ~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 From 5c92a3f112f5a47af6873b5b65347e9406fb3bd7 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Tue, 9 Sep 2014 23:31:48 +0300 Subject: [PATCH 3/3] Export to CSV with Semester begin & end all bugs that i found fixed. now when user selects "export to csv" he will be prompt to input the begining and the end of the semester. the csv file will populate the whole semester! just one click and you are done. @liranbg (Liran) please check on Windows and OSX. linux is rocking! let me know if you need anything else. sagi --- main/CalendarTab/CalendarManager.cpp | 2 +- main/mainscreen.cpp | 2 +- main/mainscreen.cpp.autosave | 394 --------------------------- main/mainscreen.ui | 2 +- src/jceData/CSV/csv_exporter.cpp | 59 ++-- src/jceData/CSV/csv_exporter.h | 6 +- 6 files changed, 29 insertions(+), 436 deletions(-) delete mode 100644 main/mainscreen.cpp.autosave diff --git a/main/CalendarTab/CalendarManager.cpp b/main/CalendarTab/CalendarManager.cpp index cb7c4a2..2fc9933 100644 --- a/main/CalendarTab/CalendarManager.cpp +++ b/main/CalendarTab/CalendarManager.cpp @@ -11,7 +11,7 @@ void CalendarManager::setCalendar(std::string html) } void CalendarManager::exportCalendarCSV(CalendarDialog *calDialog) { - if(CSV_Exporter::exportCalendar(this->caliSchedPtr)) + if(CSV_Exporter::exportCalendar(this->caliSchedPtr, calDialog)) { QMessageBox msgBox; msgBox.setText("
Exported Successfuly!
HaazZaA!!"); diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index 01193ef..bf15bf2 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -346,7 +346,7 @@ void MainScreen::on_exportToCVSBtn_clicked() if(calDialog.ok()) this->calendar->exportCalendarCSV(&calDialog); else - showMSG("Somthig was not right with the dates you chose... try again"); + showMSG("Somthig was not right with the dates you have chosen... try again"); } } diff --git a/main/mainscreen.cpp.autosave b/main/mainscreen.cpp.autosave deleted file mode 100644 index bf15bf2..0000000 --- a/main/mainscreen.cpp.autosave +++ /dev/null @@ -1,394 +0,0 @@ -#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 - 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); - 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 - //SaveData::init(); --> No need. constructor dose everything. - if (data->isSaved()) - { - ui->usrnmLineEdit->setText(data->getUsername()); - ui->pswdLineEdit->setText(data->getPassword()); - ui->keepLogin->setChecked(true); - } - - //Local Check and ui setting. - 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); - } - -} - -MainScreen::~MainScreen() -{ - delete userLoginSetting; - delete loginHandel; - delete ui; - - //Delete save data - delete data; -} -void MainScreen::on_loginButton_clicked() -{ - if (loginHandel->isLoggedInFlag()) - uiSetDisconnectMode(); - - else - uiSetConnectMode(); - -} -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_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,"Error","Missmatching data"); -} - -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("&Login"); - ui->getCalendarBtn->setDisabled(true); - ui->exportToCVSBtn->setDisabled(true); - ui->ratesButton->setDisabled(true); - return; -} - -void MainScreen::uiSetConnectMode() //fix before distrbute -{ - string username; - string password; - if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty())) - { - //add icon near to username and password to mark it - return; - } - 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("&Logout"); - ui->ratesButton->setEnabled(true); - ui->CoursesTab->setEnabled(true); - ui->exportToCVSBtn->setEnabled(true); - ui->getCalendarBtn->setEnabled(true); - - } - else - { - uiSetDisconnectMode(); - } -} -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(); -} - -void MainScreen::showMSG(QString msg) -{ - QMessageBox msgBox; - msgBox.setText(msg); - msgBox.exec(); -} -void MainScreen::on_actionCredits_triggered() -{ - QMessageBox::about(this, "About", tr("CREDITS-ROOL-UP1") + " v1.0

" - + tr("CREDITS-ROOL-UP2")+"
GNU LESSER GENERAL PUBLIC LICENSE V2
" - + tr("CREDITS-ROOL-UP3")+"
" - "jceAverageCalculator Repository" - "

"+tr("CREDITS-ROOL-UP4")+" Jce Connection

" - +tr("DevBy")+":" - ""); -} - -void MainScreen::on_clearTableButton_clicked() -{ - - courseTableMgr->clearTable(); - ui->avgLCD->display(courseTableMgr->getAvg()); -} - -void MainScreen::on_actionExit_triggered() -{ - exit(0); -} - - -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_actionHow_To_triggered() -{ - QMessageBox::information(this,"How To", - "How To.." - "
    " - "
  • "+tr("HELP1")+"
  • " - "
  • "+tr("HELP2")+"
  • " - "
  • "+tr("HELP3")+"
  • " - "
  • "+tr("HELP4")+"
  • " - "
  • "+tr("HELP5")+"
  • " - "

    "+tr("HELP6")+ - "
"); - -} - -//void MainScreen::on_pushButton_2_clicked() -//{ -// if(CSV_Exporter::exportCalendar(this->calendar->getSch())) -// { -// 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 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() -{ - 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"); - showMSG("ההגדרות שלך יכנסו לתוקף בהפעלה הבאה של התוכנית"); - } - 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"); - showMSG("Your settings will take effect next time you start the program"); - } - 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"); - showMSG("Your settings will take effect next time you start the program"); - } - else - ui->actionOS_Default->setChecked(true); -} diff --git a/main/mainscreen.ui b/main/mainscreen.ui index 8200986..837858b 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -61,7 +61,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r QTabWidget::Rounded - 2 + 0 false diff --git a/src/jceData/CSV/csv_exporter.cpp b/src/jceData/CSV/csv_exporter.cpp index 7b942e6..3844eca 100644 --- a/src/jceData/CSV/csv_exporter.cpp +++ b/src/jceData/CSV/csv_exporter.cpp @@ -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..."; QString filePath = getFileFath(); @@ -39,22 +39,29 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched) QString name = QString(coursePtr->getName().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, ¤tDate, startH, startM, endH, endM, lecturer, room, type); #ifdef Q_OS_LINUX || Q_OS_UNIX - if(line != NULL) - out << line << char(0x0A); + if(line != NULL) + out << line << char(0x0A); #endif #ifdef Q_OS_OSX - if(line != NULL) - out << line << char(0x0A); + if(line != NULL) + out << line << char(0x0A); #endif #ifdef Q_OS_WIN - if(line != NULL) - out << line << char(0x0D) << char(0x0A); + if(line != NULL) + out << line << char(0x0D) << char(0x0A); #endif + } } - +here: out.flush(); @@ -74,10 +81,9 @@ QString CSV_Exporter::getFileFath() 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 - // First day for semester 10/26/2014 QString CSV_line = ""; QString subject = "\""; @@ -86,30 +92,9 @@ QString CSV_Exporter::makeLine(QString name, int day, int startH, int startM, in subject.append(type); subject.append("\""); - QString date; - switch (day) { - 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 dateStr = date->toString("MM/dd/yyyy"); + QString start; 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(","); - CSV_line.append(date); + CSV_line.append(dateStr); CSV_line.append(","); CSV_line.append(start); CSV_line.append(","); - CSV_line.append(date); + CSV_line.append(dateStr); CSV_line.append(","); CSV_line.append(end); diff --git a/src/jceData/CSV/csv_exporter.h b/src/jceData/CSV/csv_exporter.h index 4377921..4cea49b 100644 --- a/src/jceData/CSV/csv_exporter.h +++ b/src/jceData/CSV/csv_exporter.h @@ -8,6 +8,8 @@ #include #include "../Calendar/calendarSchedule.h" +#include "../Calendar/calendardialog.h" + #define CSV_CALENDAR_HEADER "Subject,Start Date,Start Time,End Date,End Time,Description,Location" @@ -15,12 +17,12 @@ class CSV_Exporter { public: CSV_Exporter(); - static bool exportCalendar(calendarSchedule* calSched); + static bool exportCalendar(calendarSchedule* calSched, CalendarDialog *cal); private: 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