25#include <kspread_insertcalendardialog.h>
27#include <kdatepicker.h>
28#include <kdatewidget.h>
31#include <tqpushbutton.h>
36InsertCalendarDialog::InsertCalendarDialog(TQWidget* parent,
const char* name)
37: InsertCalendarDialogBase(parent,name)
39 this->m_datePicker = NULL;
43 TQDate first_day_in_month = TQDate::currentDate();
44 first_day_in_month.setYMD(first_day_in_month.year(),first_day_in_month.month(),1);
46 TQDate last_day_in_month(first_day_in_month.year(),first_day_in_month.month(),first_day_in_month.daysInMonth());
48 this->m_startDateWidget->setDate(first_day_in_month);
49 this->m_endDateWidget->setDate(last_day_in_month);
51 connect(this->m_selectStartDateButton,TQ_SIGNAL(clicked()),
this,TQ_SLOT(showStartDatePicker()));
52 connect(this->m_selectEndDateButton,TQ_SIGNAL(clicked()),
this,TQ_SLOT(showEndDatePicker()));
54 connect(this->m_insertButton,TQ_SIGNAL(clicked()),
this,TQ_SLOT(accept()));
55 connect(this->m_cancelButton,TQ_SIGNAL(clicked()),
this,TQ_SLOT(reject()));
58InsertCalendarDialog::~InsertCalendarDialog()
62bool InsertCalendarDialog::buildDatePickerFrame()
69 m_datePicker =
new KDatePicker(NULL,
"date picker");
71 Q_ASSERT(m_datePicker);
76 connect(m_datePicker,TQ_SIGNAL(destroyed()),
this,TQ_SLOT(datePickerDeleted()));
78 m_datePicker->setCloseButton(
true);
79 m_datePicker->move(this->x()+this->width(),this->y());
85void InsertCalendarDialog::datePickerDeleted()
87 kdDebug() <<
"date picker deleted" << endl;
91void InsertCalendarDialog::accept()
94 m_datePicker->deleteLater();
95 kdDebug() <<
"insert calendar dialog accepted (insert button clicked)" << endl;
96 done(TQDialog::Accepted);
97 emit insertCalendar(startDate(),endDate());
100void InsertCalendarDialog::reject()
103 m_datePicker->deleteLater();
104 kdDebug() <<
"insert calendar dialog rejected (cancel button clicked)" << endl;
105 done(TQDialog::Rejected);
108void InsertCalendarDialog::showStartDatePicker()
110 if (buildDatePickerFrame())
112 connect(m_datePicker,TQ_SIGNAL(dateSelected(TQDate)),
this,TQ_SLOT(setStartDate(TQDate)));
113 connect(m_datePicker,TQ_SIGNAL(dateEntered(TQDate)),
this,TQ_SLOT(setStartDate(TQDate)));
114 m_datePicker->setDate(startDate());
118void InsertCalendarDialog::showEndDatePicker()
120 if (buildDatePickerFrame())
122 connect(m_datePicker,TQ_SIGNAL(dateSelected(TQDate)),
this,TQ_SLOT(setEndDate(TQDate)));
123 connect(m_datePicker,TQ_SIGNAL(dateEntered(TQDate)),
this,TQ_SLOT(setEndDate(TQDate)));
124 m_datePicker->setDate(endDate());
128void InsertCalendarDialog::setStartDate(TQDate date)
130 this->m_startDateWidget->setDate(date);
133void InsertCalendarDialog::setEndDate(TQDate date)
135 this->m_endDateWidget->setDate(date);
138TQDate InsertCalendarDialog::startDate()
const
140 return this->m_startDateWidget->date();
143TQDate InsertCalendarDialog::endDate()
const
145 return this->m_endDateWidget->date();
150#include "kspread_insertcalendardialog.moc"