# kdeui Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# KDateTable Class Reference

Date selection table. More...

`#include <kdatetbl.h>`

Inheritance diagram for KDateTable:

[legend]
Collaboration diagram for KDateTable:

[legend]
List of all members.

## Public Types

enum | BackgroundMode { NoBgMode = 0, RectangleMode, CircleMode }

## Signals

void | dateChanged (QDate)
void | dateChanged (const QDate &cur, const QDate &old)
void | tableClicked ()
void | aboutToShowContextMenu (KPopupMenu *menu, const QDate &date)

## Public Member Functions

| KDateTable (QWidget *parent=0, QDate date=QDate::currentDate(), const char *name=0, WFlags f=0)
| KDateTable (QWidget *parent, const char *name, WFlags f=0)
| ~KDateTable ()
virtual QSize | sizeHint () const
void | setFontSize (int size)
bool | setDate (const QDate &)
const QDate & | getDate () const
void | setPopupMenuEnabled (bool enable)
bool | popupMenuEnabled () const
void | setCustomDatePainting (const QDate &date, const QColor &fgColor, BackgroundMode bgMode=NoBgMode, const QColor &bgColor=QColor())
void | unsetCustomDatePainting (const QDate &date)

## Protected Member Functions

int | posFromDate (const QDate &date)
QDate | dateFromPos (int pos)
virtual void | paintCell (QPainter *, int, int)
virtual void | viewportResizeEvent (QResizeEvent *)
virtual void | contentsMousePressEvent (QMouseEvent *)
virtual void | wheelEvent (QWheelEvent *e)
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
int | firstday
int | numdays
int | numDaysPrevMonth
bool | unused_hasSelection
QRect | maxCell

## Properties

QDate | date
bool | popupMenu

## 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 254 of file kdatetbl.h.

## Constructor & Destructor Documentation

KDateTable::KDateTable | ( | QWidget * | parent = `0`,
|  | QDate | date = `QDate::currentDate()`,
|  | const char * | name = `0`,
|  | WFlags | f = `0`
| ) |

| The constructor. Definition at line 116 of file kdatetbl.cpp. References QDate::currentDate(), endl(), QDate::isValid(), kdDebug(), setDate(), setFontSize(), QGridView::setNumCols(), and QGridView::setNumRows().

KDateTable::KDateTable | ( | QWidget * | parent,
|  | const char * | name,
|  | WFlags | f = `0`
| ) |

The constructor.

Since:
  3.4

Definition at line 136 of file kdatetbl.cpp.

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

KDateTable::~KDateTable | ( |  | ) |

| The destructor. Definition at line 151 of file kdatetbl.cpp.

## 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 548 of file kdatetbl.cpp.

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

void KDateTable::setFontSize | ( | int | size | ) |

| Set the font size of the date table. Definition at line 408 of file kdatetbl.cpp. References QFontMetrics::boundingRect(), fontsize, QRect::height(), maxCell, QRect::setHeight(), QRect::setWidth(), and QRect::width(). Referenced by KDateTable(), and KDatePicker::setFontSize().

bool KDateTable::setDate | ( | const QDate & |  | ) |

Select and display this date.

Definition at line 494 of file kdatetbl.cpp.

References KCalendarSystem::addMonths(), KLocale::calendar(), date, dateChanged(), QDate::dayOfWeek(), KCalendarSystem::daysInMonth(), endl(), firstday, kdDebug(), KGlobal::locale(), KCalendarSystem::month(), numdays, numDaysPrevMonth, KCalendarSystem::setYMD(), and KCalendarSystem::year().

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

void KDateTable::setPopupMenuEnabled | ( | bool | enable | ) |

Enables a popup menu when right clicking on a date.

When it's enabled, this object emits a aboutToShowContextMenu signal where you can fill in the menu items.

Since:
  3.2

Definition at line 560 of file kdatetbl.cpp.

bool KDateTable::popupMenuEnabled | ( |  | ) | const

| Returns if the popup menu is enabled or not. Definition at line 565 of file kdatetbl.cpp.

void KDateTable::setCustomDatePainting | ( | const QDate & | date,
|  | const QColor & | fgColor,
|  | BackgroundMode | bgMode = `NoBgMode`,
|  | const QColor & | bgColor = `QColor()`
| ) |

Makes a given date be painted with a given foregroundColor, and background (a rectangle, or a circle/ellipse) in a given color.

Since:
  3.2

Definition at line 570 of file kdatetbl.cpp.

References date, QDate::toString(), and unsetCustomDatePainting().

void KDateTable::unsetCustomDatePainting | ( | const QDate & | date | ) |

Unsets the custom painting of a date so that the date is painted as usual.

Since:
  3.2

Definition at line 588 of file kdatetbl.cpp.

References date, and QDate::toString().

Referenced by setCustomDatePainting().

int KDateTable::posFromDate | ( | const QDate & | date | ) | `[protected]`

| calculate the position of the cell in the matrix for the given date. The result is the 0-based index. Definition at line 168 of file kdatetbl.cpp. References KLocale::calendar(), KCalendarSystem::day(), firstday, KGlobal::locale(), and KLocale::weekStartDay(). Referenced by contentsMousePressEvent().

QDate KDateTable::dateFromPos | ( | int | pos | ) | `[protected]`

calculate the date that is displayed at a given cell in the matrix.

pos is the 0-based index in the matrix. Inverse function to posForDate().

Definition at line 180 of file kdatetbl.cpp.

References KCalendarSystem::addDays(), KLocale::calendar(), date, firstday, KGlobal::locale(), KCalendarSystem::month(), KCalendarSystem::setYMD(), KLocale::weekStartDay(), and KCalendarSystem::year().

Referenced by contentsMousePressEvent(), and paintCell().

void KDateTable::paintCell | ( | QPainter * | ,
|  | int | ,
|  | int |
| ) | `[protected, virtual]`

Paint a cell.

Reimplemented from QGridView.

Definition at line 196 of file kdatetbl.cpp.

References KLocale::calendar(), KCalendarSystem::calendarName(), QGridView::cellHeight(), QGridView::cellWidth(), date, dateFromPos(), KCalendarSystem::day(), KCalendarSystem::dayString(), firstday, KGlobalSettings::generalFont(), QRect::height(), KGlobal::locale(), maxCell, KCalendarSystem::month(), QFont::setBold(), QRect::setHeight(), QRect::setWidth(), QDate::toString(), KCalendarSystem::weekDayName(), KCalendarSystem::weekDayOfPray(), KLocale::weekStartDay(), and QRect::width().

void KDateTable::viewportResizeEvent | ( | QResizeEvent * |  | ) | `[protected, virtual]`

| Handle the resize events. Definition at line 399 of file kdatetbl.cpp. References QGridView::setCellHeight(), and QGridView::setCellWidth().

void KDateTable::contentsMousePressEvent | ( | QMouseEvent * |  | ) | `[protected, virtual]`

| React on mouse clicks that select a date. Definition at line 439 of file kdatetbl.cpp. References aboutToShowContextMenu(), KNotifyClient::beep(), QGridView::columnAt(), date, dateFromPos(), KPopupMenu::insertTitle(), QPopupMenu::popup(), posFromDate(), QGridView::rowAt(), setDate(), tableClicked(), QGridView::updateCell(), QPoint::x(), and QPoint::y().

void KDateTable::dateChanged | ( | QDate |  | ) | `[signal]`

| The selected date changed. Referenced by setDate().

void KDateTable::dateChanged | ( | const QDate & | cur,
|  | const QDate & | old
| ) | `[signal]`

This function behaves essentially like the one above.

The selected date changed.

Parameters:

  | cur | The current date
  | old | The date before the date was changed

void KDateTable::tableClicked | ( |  | ) | `[signal]`

| A date has been selected by clicking on the table. Referenced by contentsMousePressEvent().

void KDateTable::aboutToShowContextMenu | ( | KPopupMenu * | menu,
|  | const QDate & | date
| ) | `[signal]`

A popup menu for a given date is about to be shown (as when the user right clicks on that date and the popup menu is enabled).

Connect the slot where you fill the menu to this signal.

Since:
  3.2

Referenced by contentsMousePressEvent().

## Member Data Documentation

int KDateTable::fontsize`[protected]`

| The font size of the displayed text. Definition at line 362 of file kdatetbl.h. Referenced by setFontSize().

int KDateTable::firstday`[protected]`

| The day of the first day in the month [1..7]. Definition at line 370 of file kdatetbl.h. Referenced by dateFromPos(), paintCell(), posFromDate(), and setDate().

int KDateTable::numdays`[protected]`

| The number of days in the current month. Definition at line 374 of file kdatetbl.h. Referenced by setDate().

int KDateTable::numDaysPrevMonth`[protected]`

| The number of days in the previous month. Definition at line 378 of file kdatetbl.h. Referenced by setDate().

bool KDateTable::unused_hasSelection`[protected]`

| unused ### remove in KDE 4.0 Definition at line 383 of file kdatetbl.h.

QRect KDateTable::maxCell`[protected]`

| Save the size of the largest used cell content. Definition at line 387 of file kdatetbl.h. Referenced by paintCell(), setFontSize(), and sizeHint().

## Property Documentation

QDate KDateTable::date`[read, write]`

| The currently selected date. Definition at line 257 of file kdatetbl.h. Referenced by contentsMousePressEvent(), dateFromPos(), paintCell(), setCustomDatePainting(), setDate(), and unsetCustomDatePainting().

The documentation for this class was generated from the following files:

- kdatetbl.h
- kdatetbl.cpp

This file is part of the documentation for kdeui Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:20:53 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003