QCalendarPopup Class Reference

#include <qdatetimeedit_p.h>

Inheritance diagram for QCalendarPopup:

Inheritance graph
[legend]
Collaboration diagram for QCalendarPopup:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 48 of file qdatetimeedit_p.h.

Signals

void activated (const QDate &date)
void newDateSelected (const QDate &newDate)
void hidingCalendar (const QDate &oldDate)
void resetButton ()

Public Member Functions

 QCalendarPopup (const QDate &date, QWidget *parent=0)
QDate selectedDate ()
void setDate (const QDate &date)
void setDateRange (const QDate &min, const QDate &max)

Protected Member Functions

void hideEvent (QHideEvent *)
void mousePressEvent (QMouseEvent *e)
void mouseReleaseEvent (QMouseEvent *)
bool event (QEvent *e)

Private Slots

void dateSelected (const QDate &date)
void dateSelectionChanged ()

Private Attributes

QCalendarWidgetcalendar
QDate oldDate
bool dateChanged


Constructor & Destructor Documentation

QCalendarPopup::QCalendarPopup ( const QDate date,
QWidget parent = 0 
)

Definition at line 2076 of file qdatetimeedit.cpp.

References activated(), QBoxLayout::addWidget(), calendar, QObject::connect(), dateChanged, dateSelected(), dateSelectionChanged(), QCalendarWidget::NoVerticalHeader, QWidget::setAttribute(), QWidget::setFocus(), QLayout::setMargin(), QCalendarWidget::setSelectedDate(), QLayout::setSpacing(), QCalendarWidget::setVerticalHeaderFormat(), SIGNAL, SLOT, and Qt::WA_WindowPropagation.

02077     : QWidget(parent, Qt::Popup), oldDate(date)
02078 {
02079     setAttribute(Qt::WA_WindowPropagation);
02080 
02081     dateChanged = false;
02082     calendar = new QCalendarWidget(this);
02083     calendar->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
02084     calendar->setSelectedDate(date);
02085 
02086     QVBoxLayout *widgetLayout = new QVBoxLayout(this);
02087     widgetLayout->setMargin(0);
02088     widgetLayout->setSpacing(0);
02089     widgetLayout->addWidget(calendar);
02090 
02091     connect(calendar, SIGNAL(activated(QDate)), this, SLOT(dateSelected(QDate)));
02092     connect(calendar, SIGNAL(clicked(QDate)), this, SLOT(dateSelected(QDate)));
02093     connect(calendar, SIGNAL(selectionChanged()), this, SLOT(dateSelectionChanged()));
02094 
02095     calendar->setFocus();
02096 }

Here is the call graph for this function:


Member Function Documentation

QDate QCalendarPopup::selectedDate (  )  [inline]

Definition at line 53 of file qdatetimeedit_p.h.

References calendar, and QCalendarWidget::selectedDate().

00053 { return calendar->selectedDate(); }

Here is the call graph for this function:

void QCalendarPopup::setDate ( const QDate date  ) 

Definition at line 2098 of file qdatetimeedit.cpp.

References calendar, oldDate, and QCalendarWidget::setSelectedDate().

02099 {
02100     oldDate = date;
02101     calendar->setSelectedDate(date);
02102 }

void QCalendarPopup::setDateRange ( const QDate min,
const QDate max 
)

Definition at line 2104 of file qdatetimeedit.cpp.

References calendar, QCalendarWidget::setMaximumDate(), and QCalendarWidget::setMinimumDate().

02105 {
02106     calendar->setMinimumDate(min);
02107     calendar->setMaximumDate(max);
02108 }

Here is the call graph for this function:

void QCalendarPopup::activated ( const QDate date  )  [signal]

Referenced by dateSelected(), and QCalendarPopup().

void QCalendarPopup::newDateSelected ( const QDate newDate  )  [signal]

Referenced by dateSelectionChanged().

void QCalendarPopup::hidingCalendar ( const QDate oldDate  )  [signal]

Referenced by hideEvent().

void QCalendarPopup::resetButton (  )  [signal]

Referenced by hideEvent(), and mouseReleaseEvent().

void QCalendarPopup::dateSelected ( const QDate date  )  [private, slot]

Definition at line 2145 of file qdatetimeedit.cpp.

References activated(), QWidget::close(), dateChanged, and emit.

Referenced by QCalendarPopup().

02146 {
02147     dateChanged = true;
02148     emit activated(date);
02149     close();
02150 }

void QCalendarPopup::dateSelectionChanged (  )  [private, slot]

Definition at line 2140 of file qdatetimeedit.cpp.

References calendar, dateChanged, emit, newDateSelected(), and QCalendarWidget::selectedDate().

Referenced by QCalendarPopup().

02141 {
02142     dateChanged = true;
02143     emit newDateSelected(calendar->selectedDate());
02144 }

void QCalendarPopup::hideEvent ( QHideEvent  )  [protected, virtual]

This event handler can be reimplemented in a subclass to receive widget hide events. The event is passed in the event parameter.

Hide events are sent to widgets immediately after they have been hidden.

Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible().

See also:
visible, event(), QHideEvent

Reimplemented from QWidget.

Definition at line 2152 of file qdatetimeedit.cpp.

References dateChanged, emit, hidingCalendar(), oldDate, and resetButton().

02153 {
02154     emit resetButton();
02155     if (!dateChanged)
02156         emit hidingCalendar(oldDate);
02157 }

void QCalendarPopup::mousePressEvent ( QMouseEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive mouse press events for the widget.

If you create new widgets in the mousePressEvent() the mouseReleaseEvent() may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.

The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.

See also:
mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}

Reimplemented from QWidget.

Definition at line 2110 of file qdatetimeedit.cpp.

References QStyle::CC_ComboBox, QRect::contains(), event(), QStyleOption::init(), QWidget::mapToGlobal(), QWidget::mousePressEvent(), QRect::moveTo(), QWidget::parentWidget(), QWidget::rect(), QStyle::SC_ComboBoxArrow, QWidget::setAttribute(), QWidget::style(), QStyle::subControlRect(), QRect::topLeft(), and Qt::WA_NoMouseReplay.

02111 {
02112     QDateTimeEdit *dateTime = qobject_cast<QDateTimeEdit *>(parentWidget());
02113     if (dateTime) {
02114         QStyleOptionComboBox opt;
02115         opt.init(dateTime);
02116         QRect arrowRect = dateTime->style()->subControlRect(QStyle::CC_ComboBox, &opt,
02117                                                             QStyle::SC_ComboBoxArrow, dateTime);
02118         arrowRect.moveTo(dateTime->mapToGlobal(arrowRect .topLeft()));
02119         if (arrowRect.contains(event->globalPos()) || rect().contains(event->pos()))
02120             setAttribute(Qt::WA_NoMouseReplay);
02121     }
02122     QWidget::mousePressEvent(event);
02123 }

Here is the call graph for this function:

void QCalendarPopup::mouseReleaseEvent ( QMouseEvent  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive mouse release events for the widget.

See also:
mousePressEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}

Reimplemented from QWidget.

Definition at line 2125 of file qdatetimeedit.cpp.

References emit, and resetButton().

02126 {
02127     emit resetButton();
02128 }

bool QCalendarPopup::event ( QEvent e  )  [protected, virtual]

This is the main event handler; it handles event event. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event() checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event() calls keyPressEvent().

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event() will call the specialized handlers such as mousePressEvent(); otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

See also:
closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), keyPressEvent(), keyReleaseEvent(), leaveEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), QObject::event(), QObject::timerEvent()

Reimplemented from QWidget.

Definition at line 2130 of file qdatetimeedit.cpp.

References dateChanged, QWidget::event(), Qt::Key_Escape, QTest::keyEvent(), and QEvent::KeyPress.

Referenced by mousePressEvent().

02131 {
02132      if (event->type() == QEvent::KeyPress) {
02133         QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
02134         if (keyEvent->key()== Qt::Key_Escape)
02135             dateChanged = false;
02136     }
02137      return QWidget::event(event);
02138 }

Here is the call graph for this function:


Member Data Documentation

QCalendarWidget* QCalendarPopup::calendar [private]

Definition at line 74 of file qdatetimeedit_p.h.

Referenced by dateSelectionChanged(), QCalendarPopup(), selectedDate(), setDate(), and setDateRange().

QDate QCalendarPopup::oldDate [private]

Definition at line 75 of file qdatetimeedit_p.h.

Referenced by hideEvent(), and setDate().

bool QCalendarPopup::dateChanged [private]

Definition at line 76 of file qdatetimeedit_p.h.

Referenced by dateSelected(), dateSelectionChanged(), event(), hideEvent(), and QCalendarPopup().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 16:56:42 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1