2014-09-17 02:47:12 +00:00
|
|
|
#include "calendarDialog.h"
|
2014-09-22 15:39:16 +00:00
|
|
|
#include "ui_calendardialog.h"
|
2014-09-12 08:43:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
CalendarDialog::CalendarDialog(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::CalendarDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
changeLabeStatusIcon(true);//be default the dates are ok, i Updated it according to jce official dates
|
|
|
|
this->isOK = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CalendarDialog::~CalendarDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDate CalendarDialog::getStartDate()
|
|
|
|
{
|
|
|
|
return ui->calStart->selectedDate();
|
|
|
|
}
|
|
|
|
|
|
|
|
QDate CalendarDialog::getEndDate()
|
|
|
|
{
|
|
|
|
return ui->calEnd->selectedDate();
|
|
|
|
}
|
|
|
|
|
2014-09-26 20:00:40 +00:00
|
|
|
/**
|
|
|
|
* @breif This method will return the state of the dates aka User input.
|
|
|
|
* @return true - if dates are valid, invalid false.
|
|
|
|
*/
|
2014-09-12 08:43:55 +00:00
|
|
|
bool CalendarDialog::ok()
|
|
|
|
{
|
|
|
|
return this->isOK;
|
|
|
|
}
|
2014-09-26 20:00:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @breif A Slot - triggers when the start calendar widget is selected (Date changed by user)
|
|
|
|
* it will change the status label (ui->lbl_status) according to the users input.
|
|
|
|
*/
|
2014-09-12 08:43:55 +00:00
|
|
|
void CalendarDialog::on_calStart_selectionChanged()
|
|
|
|
{
|
2014-09-26 20:00:40 +00:00
|
|
|
if(ui->calStart->selectedDate() >= ui->calEnd->selectedDate()) //User input is invalid
|
2014-09-12 08:43:55 +00:00
|
|
|
{
|
|
|
|
changeLabeStatusIcon(false);
|
2014-09-17 02:47:12 +00:00
|
|
|
ui->lbl_status->setText(tr("The end of the semester can NOT be equal or before the semester begin."));
|
2014-09-12 08:43:55 +00:00
|
|
|
this->isOK = false;
|
|
|
|
}
|
2014-09-26 20:00:40 +00:00
|
|
|
else // input is valid
|
2014-09-12 08:43:55 +00:00
|
|
|
{
|
|
|
|
changeLabeStatusIcon(true);
|
2014-09-26 20:00:40 +00:00
|
|
|
ui->lbl_status->setText(tr("Looks fine, Click \"OK\""));
|
2014-09-12 08:43:55 +00:00
|
|
|
this->isOK = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-26 20:00:40 +00:00
|
|
|
/**
|
|
|
|
* @breif A Slot triggerd when OK clicked
|
|
|
|
*/
|
2014-09-12 08:43:55 +00:00
|
|
|
void CalendarDialog::on_buttonBox_accepted()
|
|
|
|
{
|
2014-09-26 20:00:40 +00:00
|
|
|
if(this->isOK)
|
|
|
|
qDebug() << "CalendarDialog: Valid input";
|
2014-09-12 08:43:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CalendarDialog::on_calEnd_selectionChanged()
|
|
|
|
{
|
|
|
|
if(ui->calStart->selectedDate() >= ui->calEnd->selectedDate())
|
|
|
|
{
|
|
|
|
changeLabeStatusIcon(false);
|
2014-09-23 02:57:35 +00:00
|
|
|
ui->lbl_status->setText(tr("The end of the semester can NOT be equal or before the semester begin."));
|
2014-09-12 08:43:55 +00:00
|
|
|
this->isOK = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
changeLabeStatusIcon(true);
|
|
|
|
ui->lbl_status->setText(tr("Looks ok, Press OK"));
|
|
|
|
this->isOK = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-09-26 20:00:40 +00:00
|
|
|
/**
|
|
|
|
* @breif changes the status icon according to the... status... smart huh?
|
|
|
|
* @param goodOrBad - self explained
|
|
|
|
*/
|
2014-09-12 08:43:55 +00:00
|
|
|
void CalendarDialog::changeLabeStatusIcon(bool goodOrBad)
|
|
|
|
{
|
|
|
|
if (goodOrBad == true) //good date!
|
|
|
|
iconPixStatus.load(":/icons/iconV.png");
|
|
|
|
else
|
|
|
|
iconPixStatus.load(":/icons/iconX.png");
|
|
|
|
this->ui->labelIconStatus->setPixmap(iconPixStatus);
|
|
|
|
}
|