kdeui Library API Documentation

KDateTable Class Reference

Date selection table. More...

#include <kdatetbl.h>

Inheritance diagram for KDateTable:

Inheritance graph
[legend]
Collaboration diagram for KDateTable:

Collaboration graph
[legend]
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 (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 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
 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 ### remove in KDE 4.0

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 245 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 81 of file kdatetbl.cpp.

References KGlobalSettings::baseColor(), QDate::currentDate(), QDate::isValid(), KStdAccel::name(), 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 408 of file kdatetbl.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 265 of file kdatetbl.cpp.

References QFontMetrics::boundingRect(), fontsize, QString::fromLatin1(), QRect::height(), KGlobal::locale(), 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 354 of file kdatetbl.cpp.

References date, dateChanged(), QDate::dayOfWeek(), QDate::daysInMonth(), firstday, QDate::isValid(), QDate::month(), numdays, numDaysPrevMonth, QDate::setYMD(), and QDate::year().

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

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

Paint a cell.

Reimplemented from QGridView.

Definition at line 100 of file kdatetbl.cpp.

References KGlobalSettings::activeTextColor(), KGlobalSettings::activeTitleColor(), KGlobalSettings::baseColor(), KGlobalSettings::calculateAlternateBackgroundColor(), QGridView::cellHeight(), QGridView::cellWidth(), QDate::currentDate(), date, QDate::day(), QPainter::drawRect(), QPainter::drawText(), firstday, fontsize, KGlobalSettings::generalFont(), QRect::height(), KGlobalSettings::highlightColor(), KGlobal::locale(), maxCell, QDate::month(), numdays, numDaysPrevMonth, QPainter::pen(), QFont::setBold(), QPainter::setBrush(), QPainter::setFont(), QRect::setHeight(), QString::setNum(), QPainter::setPen(), QFont::setPointSize(), QRect::setWidth(), KGlobalSettings::textColor(), KLocale::weekDayName(), KLocale::weekStartDay(), QRect::width(), and QDate::year().

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

Handle the resize events.

Definition at line 256 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 295 of file kdatetbl.cpp.

References QDate::addDays(), KNotifyClient::beep(), QGridView::columnAt(), date, QDate::day(), firstday, KGlobal::locale(), QDate::month(), numdays, QMouseEvent::pos(), QGridView::rowAt(), setDate(), tableClicked(), QGridView::updateCell(), KLocale::weekStartDay(), 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 294 of file kdatetbl.h.

Referenced by paintCell(), and setFontSize().

QDate KDateTable::date [protected]
 

The currently selected date.

Definition at line 298 of file kdatetbl.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 302 of file kdatetbl.h.

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

int KDateTable::numdays [protected]
 

The number of days in the current month.

Definition at line 306 of file kdatetbl.h.

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

int KDateTable::numDaysPrevMonth [protected]
 

The number of days in the previous month.

Definition at line 310 of file kdatetbl.h.

Referenced by paintCell(), and setDate().

bool KDateTable::unused_hasSelection [protected]
 

unused ### remove in KDE 4.0

Definition at line 315 of file kdatetbl.h.

QRect KDateTable::maxCell [protected]
 

Save the size of the largest used cell content.

Definition at line 319 of file kdatetbl.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 Wed Jan 28 12:59:38 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001