• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • widgets
kdatepicker.cpp
Go to the documentation of this file.
1/* -*- C++ -*-
2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 (C) 2007 John Layt <john@layt.net>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#include "kdatepicker.h"
23#include "kdatepicker_p.h"
24#include "kdatetable.h"
25
26#include <QtGui/QApplication>
27#include <QtGui/QFont>
28#include <QtGui/QLayout>
29#include <QKeyEvent>
30#include <QtGui/QMenu>
31#include <QtGui/QPainter>
32#include <QtGui/QStyle>
33#include <QtGui/QToolButton>
34#include <QtGui/QDoubleValidator>
35
36#include <kcalendarsystem.h>
37#include <klocalizeddate.h>
38#include <kcombobox.h>
39#include <kdebug.h>
40#include <kdialog.h>
41#include <kglobal.h>
42#include <kicon.h>
43#include <kiconloader.h>
44#include <klineedit.h>
45#include <knotification.h>
46
47#include "kdatepicker.moc"
48#include "kdatepicker_p.moc"
49
50// Week numbers are defined by ISO 8601
51// See http://www.merlyn.demon.co.uk/weekinfo.htm for details
52
53KDatePickerPrivateYearSelector::KDatePickerPrivateYearSelector(
54 const KCalendarSystem *cal, const QDate &currentDate, QWidget* parent )
55 : QLineEdit( parent ), val( new QIntValidator( this ) ), result( 0 )
56{
57 calendar = cal;
58 oldDate = currentDate;
59
60 QFont font;
61 font = KGlobalSettings::generalFont();
62 setFont( font );
63
64 setFrame( false );
65
66 val->setRange( calendar->year( calendar->earliestValidDate() ),
67 calendar->year( calendar->latestValidDate() ) );
68 setValidator( val );
69
70 connect( this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot()) );
71}
72
73void KDatePickerPrivateYearSelector::yearEnteredSlot()
74{
75 bool ok;
76 int newYear;
77 QDate newDate;
78
79 // check if entered value is a number
80 newYear = text().toInt( &ok );
81 if( !ok ) {
82 KNotification::beep();
83 return;
84 }
85
86 // check if new year will lead to a valid date
87 if ( calendar->setDate( newDate, newYear, calendar->month( oldDate ), calendar->day( oldDate ) ) ) {
88 result = newYear;
89 emit( closeMe( 1 ) );
90 } else {
91 KNotification::beep();
92 }
93
94}
95
96int KDatePickerPrivateYearSelector::year()
97{
98 return result;
99}
100
101void KDatePickerPrivateYearSelector::setYear( int year )
102{
103 setText( QString::number( year ) );
104}
105
106class KDatePicker::KDatePickerPrivate
107{
108public:
109 KDatePickerPrivate( KDatePicker *q ) :
110 q( q ), closeButton( 0L ), selectWeek( 0L ), todayButton( 0 ), navigationLayout( 0 )
111 {
112 }
113
114 void fillWeeksCombo();
115 QDate validDateInYearMonth( int year, int month );
116
118 KDatePicker *q;
119
120 QToolButton *closeButton;
121 KComboBox *selectWeek;
122 QToolButton *todayButton;
123 QBoxLayout *navigationLayout;
124
126 QToolButton *yearForward;
128 QToolButton *yearBackward;
130 QToolButton *monthForward;
132 QToolButton *monthBackward;
134 QToolButton *selectMonth;
136 QToolButton *selectYear;
138 QLineEdit *line;
140 KDateValidator *val;
142 KDateTable *table;
144 QSize maxMonthRect;
145
147 int fontsize;
148};
149
150void KDatePicker::KDatePickerPrivate::fillWeeksCombo()
151{
152 // every year can have a different number of weeks
153 // it could be that we had 53,1..52 and now 1..53 which is the same number but different
154 // so always fill with new values
155 // We show all week numbers for all weeks between first day of year to last day of year
156 // This of course can be a list like 53,1,2..52
157
158 KLocalizedDate thisDate( q->date(), q->calendar() );
159 int thisYear = thisDate.year();
160 KLocalizedDate day = thisDate.firstDayOfYear();
161 KLocalizedDate lastDayOfYear = thisDate.lastDayOfYear();
162
163 selectWeek->clear();
164
165 // Starting from the first day in the year, loop through the year a week at a time
166 // adding an entry to the week combo for each week in the year
167
168 for ( ; day.isValid() && day <= lastDayOfYear; day.addDaysTo( day.daysInWeek() ) ) {
169
170 // Get the ISO week number for the current day and what year that week is in
171 // e.g. 1st day of this year may fall in week 53 of previous year
172 int weekYear = thisYear;
173 day.week( &weekYear );
174 QString weekString = i18n( "Week %1", day.formatDate( KLocale::Week, KLocale::ShortNumber ) );
175
176 // show that this is a week from a different year
177 if ( weekYear != thisYear ) {
178 weekString += '*';
179 }
180
181 // when the week is selected, go to the same weekday as the one
182 // that is currently selected in the date table
183 QDate targetDate = day.addDays( thisDate.dayOfWeek() - day.dayOfWeek() ).date();
184 selectWeek->addItem( weekString, targetDate );
185
186 // make sure that the week of the lastDayOfYear is always inserted: in Chinese calendar
187 // system, this is not always the case
188 if ( day < lastDayOfYear &&
189 day.daysDifference( lastDayOfYear ) < day.daysInWeek() &&
190 lastDayOfYear.week() != day.week() ) {
191 day = lastDayOfYear.addDays( - thisDate.daysInWeek() );
192 }
193 }
194}
195
196QDate KDatePicker::KDatePickerPrivate::validDateInYearMonth( int year, int month )
197{
198 QDate newDate;
199
200 // Try to create a valid date in this year and month
201 // First try the first of the month, then try last of month
202 if ( q->calendar()->isValid( year, month, 1 ) ) {
203 q->calendar()->setDate( newDate, year, month, 1 );
204 } else if ( q->calendar()->isValid( year, month + 1, 1 ) ) {
205 q->calendar()->setDate( newDate, year, month, 1 );
206 q->calendar()->addDays( newDate, -1 );
207 } else {
208 newDate = QDate::fromJulianDay( 0 );
209 }
210
211 return newDate;
212}
213
214KDatePicker::KDatePicker( QWidget* parent ) : QFrame( parent ), d( new KDatePickerPrivate( this ) )
215{
216 init( QDate::currentDate() );
217}
218
219KDatePicker::KDatePicker( const QDate& date_, QWidget* parent )
220 : QFrame( parent ), d( new KDatePickerPrivate( this ) )
221{
222 init( date_ );
223}
224
225void KDatePicker::init( const QDate &date_ )
226{
227 QBoxLayout * topLayout = new QVBoxLayout( this );
228 topLayout->setSpacing( 0 );
229 topLayout->setMargin( 0 );
230
231 d->navigationLayout = new QHBoxLayout();
232 d->navigationLayout->setSpacing( 0 );
233 d->navigationLayout->setMargin( 0 );
234 topLayout->addLayout( d->navigationLayout );
235 d->navigationLayout->addStretch();
236 d->yearBackward = new QToolButton( this );
237 d->yearBackward->setAutoRaise( true );
238 d->navigationLayout->addWidget( d->yearBackward );
239 d->monthBackward = new QToolButton( this );
240 d->monthBackward ->setAutoRaise( true );
241 d->navigationLayout->addWidget( d->monthBackward );
242 d->navigationLayout->addSpacing( KDialog::spacingHint() );
243
244 d->selectMonth = new QToolButton( this );
245 d->selectMonth ->setAutoRaise( true );
246 d->navigationLayout->addWidget( d->selectMonth );
247 d->selectYear = new QToolButton( this );
248 d->selectYear->setCheckable( true );
249 d->selectYear->setAutoRaise( true );
250 d->navigationLayout->addWidget( d->selectYear );
251 d->navigationLayout->addSpacing( KDialog::spacingHint() );
252
253 d->monthForward = new QToolButton( this );
254 d->monthForward ->setAutoRaise( true );
255 d->navigationLayout->addWidget( d->monthForward );
256 d->yearForward = new QToolButton( this );
257 d->yearForward ->setAutoRaise( true );
258 d->navigationLayout->addWidget( d->yearForward );
259 d->navigationLayout->addStretch();
260
261 d->line = new KLineEdit( this );
262 d->val = new KDateValidator( this );
263 d->table = new KDateTable( this );
264 setFocusProxy( d->table );
265
266 d->fontsize = KGlobalSettings::generalFont().pointSize();
267 if ( d->fontsize == -1 ) {
268 d->fontsize = QFontInfo( KGlobalSettings::generalFont() ).pointSize();
269 }
270
271 d->fontsize++; // Make a little bigger
272
273 d->selectWeek = new KComboBox( this ); // read only week selection
274 d->selectWeek->setFocusPolicy( Qt::NoFocus );
275 d->todayButton = new QToolButton( this );
276 d->todayButton->setIcon( KIcon( "go-jump-today" ) );
277
278 d->yearForward->setToolTip( i18n( "Next year" ) );
279 d->yearBackward->setToolTip( i18n( "Previous year" ) );
280 d->monthForward->setToolTip( i18n( "Next month" ) );
281 d->monthBackward->setToolTip( i18n( "Previous month" ) );
282 d->selectWeek->setToolTip( i18n( "Select a week" ) );
283 d->selectMonth->setToolTip( i18n( "Select a month" ) );
284 d->selectYear->setToolTip( i18n( "Select a year" ) );
285 d->todayButton->setToolTip( i18n( "Select the current day" ) );
286
287 // -----
288 setFontSize( d->fontsize );
289 d->line->setValidator( d->val );
290 d->line->installEventFilter( this );
291 if ( QApplication::isRightToLeft() ) {
292 d->yearForward->setIcon( KIcon( QLatin1String( "arrow-left-double" ) ) );
293 d->yearBackward->setIcon( KIcon( QLatin1String( "arrow-right-double" ) ) );
294 d->monthForward->setIcon( KIcon( QLatin1String( "arrow-left" ) ) );
295 d->monthBackward->setIcon( KIcon( QLatin1String( "arrow-right" ) ) );
296 } else {
297 d->yearForward->setIcon( KIcon( QLatin1String( "arrow-right-double" ) ) );
298 d->yearBackward->setIcon( KIcon( QLatin1String( "arrow-left-double" ) ) );
299 d->monthForward->setIcon( KIcon( QLatin1String( "arrow-right" ) ) );
300 d->monthBackward->setIcon( KIcon( QLatin1String( "arrow-left" ) ) );
301 }
302
303 connect( d->table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate)) );
304 connect( d->table, SIGNAL(tableClicked()), SLOT(tableClickedSlot()) );
305 connect( d->monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked()) );
306 connect( d->monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked()) );
307 connect( d->yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked()) );
308 connect( d->yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked()) );
309 connect( d->selectWeek, SIGNAL(activated(int)), SLOT(weekSelected(int)) );
310 connect( d->todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked()) );
311 connect( d->selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked()) );
312 connect( d->selectYear, SIGNAL(toggled(bool)), SLOT(selectYearClicked()) );
313 connect( d->line, SIGNAL(returnPressed()), SLOT(lineEnterPressed()) );
314
315
316 topLayout->addWidget( d->table );
317
318 QBoxLayout * bottomLayout = new QHBoxLayout();
319 bottomLayout->setMargin( 0 );
320 bottomLayout->setSpacing( 0 );
321 topLayout->addLayout( bottomLayout );
322
323 bottomLayout->addWidget( d->todayButton );
324 bottomLayout->addWidget( d->line );
325 bottomLayout->addWidget( d->selectWeek );
326
327 d->table->setDate( date_ );
328 dateChangedSlot( date_ ); // needed because table emits changed only when newDate != oldDate
329}
330
331KDatePicker::~KDatePicker()
332{
333 delete d;
334}
335
336bool KDatePicker::eventFilter( QObject *o, QEvent *e )
337{
338 if ( e->type() == QEvent::KeyPress ) {
339 QKeyEvent * k = ( QKeyEvent * )e;
340
341 if ( ( k->key() == Qt::Key_PageUp ) ||
342 ( k->key() == Qt::Key_PageDown ) ||
343 ( k->key() == Qt::Key_Up ) ||
344 ( k->key() == Qt::Key_Down ) ) {
345 QApplication::sendEvent( d->table, e );
346 d->table->setFocus();
347 return true; // eat event
348 }
349 }
350 return QFrame::eventFilter( o, e );
351}
352
353void KDatePicker::resizeEvent( QResizeEvent* e )
354{
355 QWidget::resizeEvent( e );
356}
357
358void KDatePicker::dateChangedSlot( const QDate &date_ )
359{
360 KLocalizedDate thisDate( date_, calendar() );
361 d->line->setText( thisDate.formatDate( KLocale::ShortDate ) );
362 d->selectMonth->setText( thisDate.formatDate( KLocale::Month, KLocale::LongName ) );
363 d->fillWeeksCombo();
364
365 // calculate the item num in the week combo box; normalize selected day so as if 1.1. is the first day of the week
366 KLocalizedDate firstDay = thisDate.firstDayOfYear();
367 // If we cannot successfully create the 1st of the year, this can only mean that
368 // the 1st is before the earliest valid date in the current calendar system, so use
369 // the earliestValidDate as the first day.
370 // In particular covers the case of Gregorian where 1/1/-4713 is not a valid QDate
371 d->selectWeek->setCurrentIndex( ( thisDate.dayOfYear() + firstDay.dayOfWeek() - 2 ) /
372 thisDate.daysInWeek() );
373 d->selectYear->setText( thisDate.formatDate( KLocale::Year, KLocale::LongNumber ) );
374
375 emit( dateChanged( date_ ) );
376}
377
378void KDatePicker::tableClickedSlot()
379{
380 emit( dateSelected( date() ) );
381 emit( tableClicked() );
382}
383
384const QDate & KDatePicker::date() const
385{
386 return d->table->date();
387}
388
389bool KDatePicker::setDate( const QDate &date_ )
390{
391 // the table setDate does validity checking for us
392 // this also emits dateChanged() which then calls our dateChangedSlot()
393 return d->table->setDate( date_ );
394}
395
396const KCalendarSystem *KDatePicker::calendar() const
397{
398 return d->table->calendar();
399}
400
401bool KDatePicker::setCalendar( KCalendarSystem *calendar )
402{
403 return d->table->setCalendar( calendar );
404}
405
406bool KDatePicker::setCalendar( const QString &calendarType )
407{
408 return d->table->setCalendar( calendarType );
409}
410
411bool KDatePicker::setCalendarSystem( KLocale::CalendarSystem calendarSystem )
412{
413 return d->table->setCalendarSystem( calendarSystem );
414}
415
416void KDatePicker::monthForwardClicked()
417{
418 if ( ! setDate( calendar()->addMonths( date(), 1 ) ) ) {
419 KNotification::beep();
420 }
421 d->table->setFocus();
422}
423
424void KDatePicker::monthBackwardClicked()
425{
426 if ( ! setDate( calendar()->addMonths( date(), -1 ) ) ) {
427 KNotification::beep();
428 }
429 d->table->setFocus();
430}
431
432void KDatePicker::yearForwardClicked()
433{
434 if ( ! setDate( calendar()->addYears( d->table->date(), 1 ) ) ) {
435 KNotification::beep();
436 }
437 d->table->setFocus();
438}
439
440void KDatePicker::yearBackwardClicked()
441{
442 if ( ! setDate( calendar()->addYears( d->table->date(), -1 ) ) ) {
443 KNotification::beep();
444 }
445 d->table->setFocus();
446}
447
448void KDatePicker::weekSelected( int index )
449{
450 QDate targetDay = d->selectWeek->itemData( index ).toDateTime().date();
451
452 if ( ! setDate( targetDay ) ) {
453 KNotification::beep();
454 }
455 d->table->setFocus();
456}
457
458void KDatePicker::selectMonthClicked()
459{
460 KLocalizedDate thisDate( date(), calendar() );
461 d->table->setFocus();
462
463 QMenu popup( d->selectMonth );
464 // Populate the pick list with all the month names, this may change by year
465 // JPL do we need to do somethng here for months that fall outside valid range?
466 for ( int m = 1; m <= thisDate.monthsInYear(); m++ ) {
467 popup.addAction( calendar()->monthName( m, thisDate.year() ) )->setData( m );
468 }
469
470 QAction *item = popup.actions()[ thisDate.month() - 1 ];
471 // if this happens the above should already given an assertion
472 if ( item ) {
473 popup.setActiveAction( item );
474 }
475
476 // cancelled
477 if ( ( item = popup.exec( d->selectMonth->mapToGlobal( QPoint( 0, 0 ) ), item ) ) == 0 ) {
478 return;
479 }
480
481 // We need to create a valid date in the month selected so we can find out how many days are
482 // in the month.
483 KLocalizedDate newDate( thisDate.year(), item->data().toInt(), 1, calendar() );
484
485 // If we have succeeded in creating a date in the new month, then try to create the new date,
486 // checking we don't set a day after the last day of the month
487 newDate.setDate( newDate.year(), newDate.month(), qMin( thisDate.day(), newDate.daysInMonth() ) );
488
489 // Set the date, if it's invalid in any way then alert user and don't update
490 if ( ! setDate( newDate.date() ) ) {
491 KNotification::beep();
492 }
493}
494
495void KDatePicker::selectYearClicked()
496{
497 if ( !d->selectYear->isChecked() )
498 return;
499
500 KLocalizedDate thisDate( date(), calendar() );
501
502 KPopupFrame *popup = new KPopupFrame( this );
503 KDatePickerPrivateYearSelector *picker = new KDatePickerPrivateYearSelector( calendar(), date(), popup );
504 picker->resize( picker->sizeHint() );
505 picker->setYear( thisDate.year() );
506 picker->selectAll();
507 popup->setMainWidget( picker );
508 connect( picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)) );
509 picker->setFocus();
510
511 if( popup->exec( d->selectYear->mapToGlobal( QPoint( 0, d->selectMonth->height() ) ) ) ) {
512 // We need to create a valid date in the year/month selected so we can find out how many
513 // days are in the month.
514 KLocalizedDate newDate( picker->year(), thisDate.month(), 1, calendar() );
515
516 // If we have succeeded in creating a date in the new month, then try to create the new
517 // date, checking we don't set a day after the last day of the month
518 newDate.setDate( newDate.year(), newDate.month(), qMin( thisDate.day(), newDate.daysInMonth() ) );
519
520 // Set the date, if it's invalid in any way then alert user and don't update
521 if ( ! setDate( newDate.date() ) ) {
522 KNotification::beep();
523 }
524 }
525 delete popup;
526
527 d->selectYear->setChecked( false );
528}
529
530void KDatePicker::uncheckYearSelector()
531{
532 d->selectYear->setChecked(false);
533 d->selectYear->update();
534}
535
536// ####### KDE4: setEnabled isn't virtual anymore, so this isn't polymorphic.
537// Better reimplement changeEvent() instead.
538void KDatePicker::setEnabled( bool enable )
539{
540 QWidget * const widgets[] = {
541 d->yearForward, d->yearBackward, d->monthForward, d->monthBackward,
542 d->selectMonth, d->selectYear,
543 d->line, d->table, d->selectWeek, d->todayButton
544 };
545 const int Size = sizeof( widgets ) / sizeof( widgets[0] );
546 int count;
547
548 for( count = 0; count < Size; ++count ) {
549 widgets[count]->setEnabled( enable );
550 }
551 d->table->setFocus();
552}
553
554KDateTable *KDatePicker::dateTable() const
555{
556 return d->table;
557}
558
559void KDatePicker::lineEnterPressed()
560{
561 QDate newDate = calendar()->readDate( d->line->text() );
562
563 if ( calendar()->isValid( newDate ) ) {
564 emit( dateEntered( newDate ) );
565 setDate( newDate );
566 d->table->setFocus();
567 } else {
568 KNotification::beep();
569 }
570}
571
572void KDatePicker::todayButtonClicked()
573{
574 setDate( QDate::currentDate() );
575 d->table->setFocus();
576}
577
578QSize KDatePicker::sizeHint() const
579{
580 return QWidget::sizeHint();
581}
582
583void KDatePicker::setFontSize( int s )
584{
585 QWidget * const buttons[] = {
586 d->selectMonth,
587 d->selectYear,
588 };
589 const int NoOfButtons = sizeof( buttons ) / sizeof( buttons[0] );
590 int count;
591 QFont font;
592 QRect r;
593 // -----
594 d->fontsize = s;
595 for( count = 0; count < NoOfButtons; ++count ) {
596 font = buttons[count]->font();
597 font.setPointSize( s );
598 buttons[count]->setFont( font );
599 }
600 d->table->setFontSize( s );
601
602 QFontMetrics metrics( d->selectMonth->fontMetrics() );
603 QString longestMonth;
604
605 for ( int i = 1; ; ++i ) {
606 QString str = calendar()->monthName( i, calendar()->year( date() ), KCalendarSystem::LongName );
607 if ( str.isNull() ) {
608 break;
609 }
610 r = metrics.boundingRect( str );
611
612 if ( r.width() > d->maxMonthRect.width() ) {
613 d->maxMonthRect.setWidth( r.width() );
614 longestMonth = str;
615 }
616 if ( r.height() > d->maxMonthRect.height() ) {
617 d->maxMonthRect.setHeight( r.height() );
618 }
619 }
620
621 QStyleOptionToolButton opt;
622 opt.initFrom( d->selectMonth );
623 opt.text = longestMonth;
624
625 // stolen from QToolButton
626 QSize textSize = metrics.size( Qt::TextShowMnemonic, longestMonth );
627 textSize.setWidth( textSize.width() + metrics.width( QLatin1Char(' ') ) * 2 );
628 int w = textSize.width();
629 int h = textSize.height();
630 opt.rect.setHeight( h ); // PM_MenuButtonIndicator depends on the height
631
632 QSize metricBound = style()->sizeFromContents(
633 QStyle::CT_ToolButton, &opt, QSize( w, h ), d->selectMonth
634 ).expandedTo( QApplication::globalStrut() );
635
636 d->selectMonth->setMinimumSize( metricBound );
637}
638
639int KDatePicker::fontSize() const
640{
641 return d->fontsize;
642}
643
644
645void KDatePicker::setCloseButton( bool enable )
646{
647 if ( enable == ( d->closeButton != 0L ) ) {
648 return;
649 }
650
651 if ( enable ) {
652 d->closeButton = new QToolButton( this );
653 d->closeButton->setAutoRaise( true );
654 d->navigationLayout->addSpacing( KDialog::spacingHint() );
655 d->navigationLayout->addWidget( d->closeButton );
656 d->closeButton->setToolTip( i18nc( "@action:button", "Close" ) );
657 d->closeButton->setIcon( SmallIcon( "window-close" ) );
658 connect( d->closeButton, SIGNAL(clicked()),
659 topLevelWidget(), SLOT(close()) );
660 } else {
661 delete d->closeButton;
662 d->closeButton = 0L;
663 }
664
665 updateGeometry();
666}
667
668bool KDatePicker::hasCloseButton() const
669{
670 return ( d->closeButton );
671}
KCalendarSystem
KCalendarSystem::setDate
bool setDate(QDate &date, int year, int dayOfYear) const
KCalendarSystem::readDate
QDate readDate(const QString &dateString, const QString &dateFormat, bool *ok, KLocale::DateTimeFormatStandard formatStandard) const
KCalendarSystem::monthName
virtual QString monthName(const QDate &date, MonthNameFormat format=LongName) const
KCalendarSystem::LongName
LongName
KComboBox
An enhanced combo box.
Definition: kcombobox.h:149
KDatePicker
A date selection widget.
Definition: kdatepicker.h:56
KDatePicker::setDate
bool setDate(const QDate &date)
Sets the date.
Definition: kdatepicker.cpp:389
KDatePicker::sizeHint
QSize sizeHint() const
The size hint for date pickers.
Definition: kdatepicker.cpp:578
KDatePicker::dateChangedSlot
void dateChangedSlot(const QDate &date)
Definition: kdatepicker.cpp:358
KDatePicker::yearBackwardClicked
void yearBackwardClicked()
Definition: kdatepicker.cpp:440
KDatePicker::tableClickedSlot
void tableClickedSlot()
Definition: kdatepicker.cpp:378
KDatePicker::setCalendar
bool setCalendar(KCalendarSystem *calendar=0)
Changes the calendar system to use.
Definition: kdatepicker.cpp:401
KDatePicker::monthBackwardClicked
void monthBackwardClicked()
Definition: kdatepicker.cpp:424
KDatePicker::todayButtonClicked
void todayButtonClicked()
Definition: kdatepicker.cpp:572
KDatePicker::~KDatePicker
virtual ~KDatePicker()
The destructor.
Definition: kdatepicker.cpp:331
KDatePicker::uncheckYearSelector
void uncheckYearSelector()
Definition: kdatepicker.cpp:530
KDatePicker::KDatePicker
KDatePicker(QWidget *parent=0)
The constructor.
Definition: kdatepicker.cpp:214
KDatePicker::dateEntered
void dateEntered(const QDate &date)
This signal is emitted when enter is pressed and a VALID date has been entered before into the line e...
KDatePicker::hasCloseButton
bool hasCloseButton() const
Definition: kdatepicker.cpp:668
KDatePicker::dateSelected
void dateSelected(const QDate &date)
This signal is emitted each time a day has been selected by clicking on the table (hitting a day in t...
KDatePicker::setFontSize
void setFontSize(int)
Sets the font size of the widgets elements.
Definition: kdatepicker.cpp:583
KDatePicker::monthForwardClicked
void monthForwardClicked()
Definition: kdatepicker.cpp:416
KDatePicker::setCalendarSystem
bool setCalendarSystem(KLocale::CalendarSystem calendarSystem)
Definition: kdatepicker.cpp:411
KDatePicker::fontSize
int fontSize
Definition: kdatepicker.h:61
KDatePicker::dateChanged
void dateChanged(const QDate &date)
This signal is emitted each time the selected date is changed.
KDatePicker::yearForwardClicked
void yearForwardClicked()
Definition: kdatepicker.cpp:432
KDatePicker::lineEnterPressed
void lineEnterPressed()
Definition: kdatepicker.cpp:559
KDatePicker::weekSelected
void weekSelected(int)
Definition: kdatepicker.cpp:448
KDatePicker::setCloseButton
void setCloseButton(bool enable)
By calling this method with enable = true, KDatePicker will show a little close-button in the upper b...
Definition: kdatepicker.cpp:645
KDatePicker::dateTable
KDateTable * dateTable() const
Definition: kdatepicker.cpp:554
KDatePicker::selectMonthClicked
void selectMonthClicked()
Definition: kdatepicker.cpp:458
KDatePicker::eventFilter
virtual bool eventFilter(QObject *o, QEvent *e)
to catch move keyEvents when QLineEdit has keyFocus
Definition: kdatepicker.cpp:336
KDatePicker::date
QDate date
Definition: kdatepicker.h:58
KDatePicker::selectYearClicked
void selectYearClicked()
Definition: kdatepicker.cpp:495
KDatePicker::calendar
const KCalendarSystem * calendar() const
Returns the currently selected calendar system.
Definition: kdatepicker.cpp:396
KDatePicker::resizeEvent
virtual void resizeEvent(QResizeEvent *)
the resize event
Definition: kdatepicker.cpp:353
KDatePicker::setEnabled
void setEnabled(bool enable)
Enables or disables the widget.
Definition: kdatepicker.cpp:538
KDatePicker::tableClicked
void tableClicked()
This signal is emitted when the day has been selected by clicking on it in the table.
KDateTable
Date selection table.
Definition: kdatetable.h:140
KDateValidator
Validates user-entered dates.
Definition: kdatetable.h:113
KDialog::spacingHint
static int spacingHint()
Returns the number of pixels that should be used between widgets inside a dialog according to the KDE...
Definition: kdialog.cpp:432
KGlobalSettings::generalFont
static QFont generalFont()
Returns the default general font.
Definition: kglobalsettings.cpp:446
KIcon
A wrapper around QIcon that provides KDE icon features.
Definition: kicon.h:41
KLineEdit
An enhanced QLineEdit widget for inputting text.
Definition: klineedit.h:150
KLocale::Week
Week
KLocale::Year
Year
KLocale::Month
Month
KLocale::ShortDate
ShortDate
KLocale::CalendarSystem
CalendarSystem
KLocale::LongName
LongName
KLocale::LongNumber
LongNumber
KLocale::ShortNumber
ShortNumber
KLocalizedDate
KLocalizedDate::date
QDate date() const
KLocalizedDate::addDaysTo
bool addDaysTo(int days)
KLocalizedDate::day
int day() const
KLocalizedDate::daysInWeek
int daysInWeek() const
KLocalizedDate::week
int week(int *yearNum=0) const
KLocalizedDate::firstDayOfYear
KLocalizedDate firstDayOfYear() const
KLocalizedDate::month
int month() const
KLocalizedDate::daysInMonth
int daysInMonth() const
KLocalizedDate::lastDayOfYear
KLocalizedDate lastDayOfYear() const
KLocalizedDate::dayOfWeek
int dayOfWeek() const
KLocalizedDate::monthsInYear
int monthsInYear() const
KLocalizedDate::addDays
KLocalizedDate addDays(int days) const
KLocalizedDate::calendar
const KCalendarSystem * calendar() const
KLocalizedDate::isValid
bool isValid() const
KLocalizedDate::dayOfYear
int dayOfYear() const
KLocalizedDate::year
int year() const
KLocalizedDate::setDate
bool setDate(const QDate &date)
KLocalizedDate::daysDifference
int daysDifference(const KLocalizedDate &toDate) const
KLocalizedDate::formatDate
QString formatDate(const QString &formatString, KLocale::DateTimeFormatStandard formatStandard=KLocale::KdeFormat) const
KNotification::beep
static void beep(const QString &reason=QString(), QWidget *widget=0L)
This is a simple substitution for QApplication::beep()
Definition: knotification.cpp:352
KPopupFrame
Frame with popup menu behavior.
Definition: kdatetable.h:42
KPopupFrame::setMainWidget
void setMainWidget(QWidget *m)
Set the main widget.
Definition: kdatetable.cpp:897
KPopupFrame::exec
int exec(const QPoint &p)
Execute the popup window.
Definition: kdatetable.cpp:943
QAction
QFrame
QLineEdit
QMenu
QObject
QToolButton
QWidget
kcalendarsystem.h
kcombobox.h
kdatepicker.h
kdatetable.h
kdebug.h
kdialog.h
kglobal.h
kicon.h
SmallIcon
QPixmap SmallIcon(const QString &name, int force_size, int state, const QStringList &overlays)
Definition: kiconloader.cpp:1553
kiconloader.h
klineedit.h
klocalizeddate.h
i18n
QString i18n(const char *text)
i18nc
QString i18nc(const char *ctxt, const char *text)
knotification.h
KStandardGuiItem::ok
KGuiItem ok()
Returns the 'Ok' gui item.
Definition: kstandardguiitem.cpp:107
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal