Go to the documentation of this file.
22#include <QtCore/QDate>
23#include <QtGui/QLayout>
24#include <QtGui/QLineEdit>
25#include <QtGui/QDoubleSpinBox>
35class KDateWidgetSpinBox :
public QSpinBox
38 KDateWidgetSpinBox(
int min,
int max, QWidget *parent ) : QSpinBox( parent )
40 setRange( qMin( min, max ), qMax( min, max ) );
42 lineEdit()->setAlignment( Qt::AlignRight );
46class KDateWidget::KDateWidgetPrivate
49 KDateWidgetSpinBox *m_day;
51 KDateWidgetSpinBox *m_year;
52 KLocalizedDate m_date;
61 init( QDate::currentDate() );
65 :
QWidget( parent ), d( new KDateWidgetPrivate )
72 QHBoxLayout *layout =
new QHBoxLayout(
this );
73 layout->setMargin( 0 );
76 d->m_day =
new KDateWidgetSpinBox( 1, 31,
this );
78 d->m_year =
new KDateWidgetSpinBox(
calendar()->year(
calendar()->earliestValidDate() ),
81 layout->addWidget( d->m_day );
82 layout->addWidget( d->m_month );
83 layout->addWidget( d->m_year );
85 connect( d->m_day, SIGNAL(valueChanged(
int)),
this, SLOT(
slotDateChanged()) );
86 connect( d->m_month, SIGNAL(activated(
int)),
this, SLOT(
slotDateChanged()) );
87 connect( d->m_year, SIGNAL(valueChanged(
int)),
this, SLOT(
slotDateChanged()) );
89 setFocusProxy(d->m_day);
90 setFocusPolicy(Qt::StrongFocus);
95 setDate( QDate::currentDate() );
107 bool dayBlocked = d->m_day->blockSignals(
true );
108 bool monthBlocked = d->m_month->blockSignals(
true );
109 bool yearBlocked = d->m_year->blockSignals(
true );
111 d->m_date.setDate(
date );
114 d->m_day->setMaximum( d->m_date.daysInMonth() );
115 d->m_day->setValue( d->m_date.day() );
118 d->m_month->setMaxVisibleItems( d->m_date.monthsInYear() );
119 for (
int m = 1; m <= d->m_date.monthsInYear(); ++m ) {
120 d->m_month->addItem(
calendar()->monthName( m, d->m_date.year() ) );
122 d->m_month->setCurrentIndex( d->m_date.month() - 1 );
124 d->m_year->setValue( d->m_date.year() );
126 d->m_day->blockSignals( dayBlocked );
127 d->m_month->blockSignals( monthBlocked );
128 d->m_year->blockSignals( yearBlocked );
146 y = d->m_year->value();
150 date.setDate( y, 1, 1 );
151 m = d->m_month->currentIndex() + 1;
152 m = qMin( qMax( m, 1 ),
date.monthsInYear() );
154 date.setDate( y, m, 1 );
155 day = d->m_day->value();
156 day = qMin( qMax( day, 1 ),
date.daysInMonth() );
158 date.setDate( y, m, day );
164 return d->m_date.calendar();
169 QDate oldDate =
date();
181 d->m_date.setCalendarSystem( newCalendarSystem );
185#include "kdatewidget.moc"
KLocale::CalendarSystem calendarSystem() const
static int spacingHint()
Returns the number of pixels that should be used between widgets inside a dialog according to the KDE...
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Tue Mar 25 2025 00:00:00 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.