calendarsystem Library API Documentation

KDateTable Class Reference

Date selection table. More...

#include <mkdatetbl.h>

Inheritance diagram for KDateTable:

QGridView List of all members.

Signals

void dateChanged (QDate)
 The selected date changed.

void tableClicked ()
 A date has been selected by clicking on the table.


Public Member Functions

 KDateTable (const QString &calType="gregorian", QWidget *parent=0, QDate date=QDate::currentDate(), const char *name=0, WFlags f=0)
 The constructor.

virtual QSize sizeHint () const
 Returns a recommended size for the widget.

void setFontSize (int size)
 Set the font size of the date table.

bool setDate (const QDate &)
 Select and display this date.

const QDategetDate () const

Protected Member Functions

virtual void paintCell (QPainter *, int, int)
 Paint a cell.

virtual void viewportResizeEvent (QResizeEvent *)
 Handle the resize events.

virtual void contentsMousePressEvent (QMouseEvent *)
 React on mouse clicks that select a date.

virtual void keyPressEvent (QKeyEvent *e)
virtual void focusInEvent (QFocusEvent *e)
virtual void focusOutEvent (QFocusEvent *e)
virtual void virtual_hook (int id, void *data)

Protected Attributes

int fontsize
 The font size of the displayed text.

QDate date
 The currently selected date.

int firstday
 The day of the first day in the month [1..7].

int numdays
 The number of days in the current month.

int numDaysPrevMonth
 The number of days in the previous month.

bool unused_hasSelection
 unused

QRect maxCell
 Save the size of the largest used cell content.


Detailed Description

Date selection table.

This is a support class for the KDatePicker class. It just draws the calender table without titles, but could theoretically be used as a standalone.

When a date is selected by the user, it emits a signal: dateSelected(QDate)

Definition at line 233 of file mkdatetbl.h.


Constructor & Destructor Documentation

KDateTable::KDateTable const QString calType = "gregorian",
QWidget parent = 0,
QDate  date = QDate::currentDate(),
const char *  name = 0,
WFlags  f = 0
 

The constructor.

Definition at line 90 of file mkdatetbl.cpp.

References QDate::currentDate(), QDate::isValid(), setDate(), setFontSize(), QGridView::setNumCols(), and QGridView::setNumRows().


Member Function Documentation

QSize KDateTable::sizeHint  )  const [virtual]
 

Returns a recommended size for the widget.

To save some time, the size of the largest used cell content is calculated in each paintCell() call, since all calculations have to be done there anyway. The size is stored in maxCell. The sizeHint() simply returns a multiple of maxCell.

Definition at line 449 of file mkdatetbl.cpp.

References QRect::height(), maxCell, QGridView::numCols(), QGridView::numRows(), and QRect::width().

Referenced by KDatePicker::sizeHint().

void KDateTable::setFontSize int  size  ) 
 

Set the font size of the date table.

Definition at line 309 of file mkdatetbl.cpp.

References QFontMetrics::boundingRect(), fontsize, QRect::height(), maxCell, QRect::setHeight(), QRect::setWidth(), KCalendarSystem::weekDayName(), and QRect::width().

Referenced by KDateTable(), and KDatePicker::setFontSize().

bool KDateTable::setDate const QDate  ) 
 

Select and display this date.

Definition at line 388 of file mkdatetbl.cpp.

References date, dateChanged(), KCalendarSystem::dayOfTheWeek(), firstday, QDate::isValid(), KCalendarSystem::numberOfDaysInMonth(), KCalendarSystem::numberOfDaysPrevMonth(), numdays, and numDaysPrevMonth.

Referenced by contentsMousePressEvent(), KDateTable(), and KDatePicker::setDate().

void KDateTable::paintCell QPainter ,
int  ,
int 
[protected, virtual]
 

Paint a cell.

Reimplemented from QGridView.

Definition at line 115 of file mkdatetbl.cpp.

References QGridView::cellHeight(), QGridView::cellWidth(), date, KCalendarSystem::day(), QPainter::drawRect(), QPainter::drawText(), firstday, fontsize, QRect::height(), maxCell, numdays, numDaysPrevMonth, QPainter::pen(), QFont::setBold(), QPainter::setBrush(), QPainter::setFont(), QRect::setHeight(), QString::setNum(), QPainter::setPen(), QFont::setPointSize(), QRect::setWidth(), KCalendarSystem::weekDayName(), and QRect::width().

void KDateTable::viewportResizeEvent QResizeEvent  )  [protected, virtual]
 

Handle the resize events.

Definition at line 300 of file mkdatetbl.cpp.

References QGridView::setCellHeight(), and QGridView::setCellWidth().

void KDateTable::contentsMousePressEvent QMouseEvent  )  [protected, virtual]
 

React on mouse clicks that select a date.

Definition at line 333 of file mkdatetbl.cpp.

References QDate::addDays(), QGridView::columnAt(), date, QDate::day(), KCalendarSystem::day(), firstday, QDate::month(), numdays, QMouseEvent::pos(), QGridView::rowAt(), setDate(), tableClicked(), QGridView::updateCell(), QPoint::x(), QPoint::y(), and QDate::year().

void KDateTable::dateChanged QDate   )  [signal]
 

The selected date changed.

Referenced by setDate().

void KDateTable::tableClicked  )  [signal]
 

A date has been selected by clicking on the table.

Referenced by contentsMousePressEvent().


Member Data Documentation

int KDateTable::fontsize [protected]
 

The font size of the displayed text.

Definition at line 283 of file mkdatetbl.h.

Referenced by paintCell(), and setFontSize().

QDate KDateTable::date [protected]
 

The currently selected date.

Definition at line 287 of file mkdatetbl.h.

Referenced by contentsMousePressEvent(), paintCell(), and setDate().

int KDateTable::firstday [protected]
 

The day of the first day in the month [1..7].

Definition at line 291 of file mkdatetbl.h.

Referenced by contentsMousePressEvent(), paintCell(), and setDate().

int KDateTable::numdays [protected]
 

The number of days in the current month.

Definition at line 295 of file mkdatetbl.h.

Referenced by contentsMousePressEvent(), paintCell(), and setDate().

int KDateTable::numDaysPrevMonth [protected]
 

The number of days in the previous month.

Definition at line 299 of file mkdatetbl.h.

Referenced by paintCell(), and setDate().

bool KDateTable::unused_hasSelection [protected]
 

unused

Definition at line 303 of file mkdatetbl.h.

QRect KDateTable::maxCell [protected]
 

Save the size of the largest used cell content.

Definition at line 307 of file mkdatetbl.h.

Referenced by paintCell(), setFontSize(), and sizeHint().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:09 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001