diff --git a/main/CalendarTab/CalendarManager.cpp b/main/CalendarTab/CalendarManager.cpp index c19a6fa..aa03224 100644 --- a/main/CalendarTab/CalendarManager.cpp +++ b/main/CalendarTab/CalendarManager.cpp @@ -10,14 +10,14 @@ void CalendarManager::setCalendar(std::string html) { caliSchedPtr->setPage(html); } -void CalendarManager::exportCalendarCSV() //need to add fix to the null pointer bug +bool CalendarManager::exportCalendarCSV() //need to add fix to the null pointer bug { -// if (caliSchedPtr->getCourses()->empty()) -// return; + if (this->caliSchedPtr->getCourses()->empty()) + return false; QMessageBox msgBox; int buttonClicked = caliDialog->exec(); if (buttonClicked == 0) //cancel? - return; + return false; //calDialog.getStartDate(),calDialog.getEndDate() if(caliDialog->ok()) { @@ -26,6 +26,7 @@ void CalendarManager::exportCalendarCSV() //need to add fix to the null pointer msgBox.setIcon(QMessageBox::Information); msgBox.setText(QObject::tr("Exported Successfuly!")); msgBox.exec(); + return true; }else { msgBox.setIcon(QMessageBox::Critical); @@ -39,6 +40,7 @@ void CalendarManager::exportCalendarCSV() //need to add fix to the null pointer msgBox.setText(QObject::tr("Dates not valid")); msgBox.exec(); } + return false; } diff --git a/main/CalendarTab/CalendarManager.h b/main/CalendarTab/CalendarManager.h index 20f4359..f52a4a5 100644 --- a/main/CalendarTab/CalendarManager.h +++ b/main/CalendarTab/CalendarManager.h @@ -17,7 +17,7 @@ public: delete caliSchedPtr; delete caliDialog; } - void exportCalendarCSV(); + bool exportCalendarCSV(); void setCalendar(std::string html); void resetTable() { if (caliSchedPtr != NULL) caliSchedPtr->clearTableItems(); } diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index 4f33871..281869f 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -49,8 +49,6 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr //Local Check and ui setting. checkLocale(); - //calendar bug fix - calendarLoaded = false; } @@ -267,7 +265,6 @@ void MainScreen::on_getCalendarBtn_clicked() //ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect()); calendar->resetTable(); calendar->setCalendar(loginHandel->getCurrentPageContect().toStdString()); - calendarLoaded = true; } else if (status == jceLogin::JCE_NOT_CONNECTED) @@ -280,9 +277,7 @@ void MainScreen::on_exportToCVSBtn_clicked() { if (loginHandel->isLoggedInFlag()) { - if(calendarLoaded) - this->calendar->exportCalendarCSV(); - else + if(!this->calendar->exportCalendarCSV()) { QMessageBox::critical(this,tr("Error"),"No Calendar was loaded."); //Need Translation }