KWidgetsAddons

kdatepicker.cpp
1 /* -*- C++ -*-
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 1997 Tim D. Gilman <[email protected]>
4  SPDX-FileCopyrightText: 1998-2001 Mirko Boehm ([email protected])
5  SPDX-FileCopyrightText: 2007 John Layt <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #include "kdatepicker.h"
11 #include "kdatepicker_p.h"
12 #include "kdatetable_p.h"
13 #include <kpopupframe.h>
14 
15 #include <QApplication>
16 #include <QComboBox>
17 #include <QFont>
18 #include <QFontDatabase>
19 #include <QKeyEvent>
20 #include <QLayout>
21 #include <QMenu>
22 #include <QStyle>
23 #include <QToolButton>
24 
25 #include "moc_kdatepicker.cpp"
26 #include "moc_kdatepicker_p.cpp"
27 
28 class DatePickerValidator : public QValidator
29 {
30  Q_OBJECT
31 public:
32  DatePickerValidator(KDatePicker *parent)
33  : QValidator(parent)
34  , picker(parent)
35  {
36  }
37 
38  State validate(QString &text, int &) const override
39  {
40  return toDate(text).isValid() ? QValidator::Acceptable : QValidator::Intermediate;
41  }
42 
43  QDate toDate(const QString &text) const
44  {
46  QLocale locale = picker->locale();
47 
48  QDate date;
49  for (int i = 0; i < 3; i++) {
50  date = locale.toDate(text, formats[i]);
51  if (date.isValid()) {
52  break;
53  }
54  }
55  return date;
56  }
57 
58 private:
59  KDatePicker *const picker;
60 };
61 
62 // Week numbers are defined by ISO 8601
63 // See http://www.merlyn.demon.co.uk/weekinfo.htm for details
64 
65 KDatePickerPrivateYearSelector::KDatePickerPrivateYearSelector(const QDate &currentDate, QWidget *parent)
66  : QLineEdit(parent)
67  , val(new QIntValidator(this))
68  , result(0)
69 {
70  oldDate = currentDate;
71 
73 
74  setFrame(false);
75 
76  // TODO: Find a way to get that from QLocale
77  // val->setRange( calendar->year( calendar->earliestValidDate() ),
78  // calendar->year( calendar->latestValidDate() ) );
79  setValidator(val);
80 
81  connect(this, &QLineEdit::returnPressed, this, &KDatePickerPrivateYearSelector::yearEnteredSlot);
82 }
83 
84 void KDatePickerPrivateYearSelector::yearEnteredSlot()
85 {
86  bool ok;
87  int newYear;
88 
89  // check if entered value is a number
90  newYear = text().toInt(&ok);
91  if (!ok) {
93  return;
94  }
95 
96  // check if new year will lead to a valid date
97  if (QDate(newYear, oldDate.month(), oldDate.day()).isValid()) {
98  result = newYear;
99  Q_EMIT closeMe(1);
100  } else {
102  }
103 }
104 
105 int KDatePickerPrivateYearSelector::year()
106 {
107  return result;
108 }
109 
110 void KDatePickerPrivateYearSelector::setYear(int year)
111 {
112  setText(QString::number(year));
113 }
114 
115 class KDatePickerPrivate
116 {
117  Q_DECLARE_TR_FUNCTIONS(KDatePicker)
118 
119 public:
120  KDatePickerPrivate(KDatePicker *q)
121  : q(q)
122  , closeButton(nullptr)
123  , selectWeek(nullptr)
124  , todayButton(nullptr)
125  , navigationLayout(nullptr)
126  {
127  }
128 
129  void fillWeeksCombo();
130  QDate validDateInYearMonth(int year, int month);
131 
132  /// the date table
133  KDatePicker *q;
134 
135  QToolButton *closeButton;
136  QComboBox *selectWeek;
137  QToolButton *todayButton;
138  QBoxLayout *navigationLayout;
139 
140  /// the year forward button
141  QToolButton *yearForward;
142  /// the year backward button
143  QToolButton *yearBackward;
144  /// the month forward button
145  QToolButton *monthForward;
146  /// the month backward button
147  QToolButton *monthBackward;
148  /// the button for selecting the month directly
149  QToolButton *selectMonth;
150  /// the button for selecting the year directly
151  QToolButton *selectYear;
152  /// the line edit to enter the date directly
153  QLineEdit *line;
154  /// the validator for the line edit:
155  DatePickerValidator *val;
156  /// the date table
157  KDateTable *table;
158  /// the widest month string in pixels:
159  QSize maxMonthRect;
160 
161  /// the font size for the widget
162  int fontsize;
163 };
164 
165 void KDatePickerPrivate::fillWeeksCombo()
166 {
167  // every year can have a different number of weeks
168  // it could be that we had 53,1..52 and now 1..53 which is the same number but different
169  // so always fill with new values
170  // We show all week numbers for all weeks between first day of year to last day of year
171  // This of course can be a list like 53,1,2..52
172 
173  const QDate thisDate = q->date();
174  const int thisYear = thisDate.year();
175  QDate day(thisDate.year(), 1, 1);
176  const QDate lastDayOfYear = QDate(thisDate.year() + 1, 1, 1).addDays(-1);
177 
178  selectWeek->clear();
179 
180  // Starting from the first day in the year, loop through the year a week at a time
181  // adding an entry to the week combo for each week in the year
182 
183  for (; day.isValid() && day <= lastDayOfYear; day = day.addDays(7)) {
184  // Get the ISO week number for the current day and what year that week is in
185  // e.g. 1st day of this year may fall in week 53 of previous year
186  int weekYear = thisYear;
187  const int week = day.weekNumber(&weekYear);
188  QString weekString = tr("Week %1").arg(QString::number(week));
189 
190  // show that this is a week from a different year
191  if (weekYear != thisYear) {
192  weekString += QLatin1Char('*');
193  }
194 
195  // when the week is selected, go to the same weekday as the one
196  // that is currently selected in the date table
197  QDate targetDate = day.addDays(thisDate.dayOfWeek() - day.dayOfWeek());
198  selectWeek->addItem(weekString, targetDate);
199 
200  // make sure that the week of the lastDayOfYear is always inserted: in Chinese calendar
201  // system, this is not always the case
202  if (day < lastDayOfYear //
203  && day.daysTo(lastDayOfYear) < 7 //
204  && lastDayOfYear.weekNumber() != day.weekNumber()) {
205  day = lastDayOfYear.addDays(-7);
206  }
207  }
208 }
209 
210 QDate KDatePickerPrivate::validDateInYearMonth(int year, int month)
211 {
212  QDate newDate;
213 
214  // Try to create a valid date in this year and month
215  // First try the first of the month, then try last of month
216  if (QDate(year, month, 1).isValid()) {
217  newDate = QDate(year, month, 1);
218  } else if (QDate(year, month + 1, 1).isValid()) {
219  newDate = QDate(year, month + 1, 1).addDays(-1);
220  } else {
221  newDate = QDate::fromJulianDay(0);
222  }
223 
224  return newDate;
225 }
226 
228  : QFrame(parent)
229  , d(new KDatePickerPrivate(this))
230 {
231  initWidget(QDate::currentDate());
232 }
233 
234 KDatePicker::KDatePicker(const QDate &date_, QWidget *parent)
235  : QFrame(parent)
236  , d(new KDatePickerPrivate(this))
237 {
238  initWidget(date_);
239 }
240 
241 void KDatePicker::initWidget(const QDate &date_)
242 {
243  const int horizontalSpacing = style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
244 
245  QBoxLayout *topLayout = new QVBoxLayout(this);
246  topLayout->setSpacing(0);
247  topLayout->setContentsMargins(0, 0, 0, 0);
248 
249  d->navigationLayout = new QHBoxLayout();
250  d->navigationLayout->setSpacing(0);
251  d->navigationLayout->setContentsMargins(0, 0, 0, 0);
252  topLayout->addLayout(d->navigationLayout);
253  d->navigationLayout->addStretch();
254  d->yearBackward = new QToolButton(this);
255  d->yearBackward->setAutoRaise(true);
256  d->navigationLayout->addWidget(d->yearBackward);
257  d->monthBackward = new QToolButton(this);
258  d->monthBackward->setAutoRaise(true);
259  d->navigationLayout->addWidget(d->monthBackward);
260  d->navigationLayout->addSpacing(horizontalSpacing);
261 
262  d->selectMonth = new QToolButton(this);
263  d->selectMonth->setAutoRaise(true);
264  d->navigationLayout->addWidget(d->selectMonth);
265  d->selectYear = new QToolButton(this);
266  d->selectYear->setCheckable(true);
267  d->selectYear->setAutoRaise(true);
268  d->navigationLayout->addWidget(d->selectYear);
269  d->navigationLayout->addSpacing(horizontalSpacing);
270 
271  d->monthForward = new QToolButton(this);
272  d->monthForward->setAutoRaise(true);
273  d->navigationLayout->addWidget(d->monthForward);
274  d->yearForward = new QToolButton(this);
275  d->yearForward->setAutoRaise(true);
276  d->navigationLayout->addWidget(d->yearForward);
277  d->navigationLayout->addStretch();
278 
279  d->line = new QLineEdit(this);
280  d->val = new DatePickerValidator(this);
281  d->table = new KDateTable(this);
282  setFocusProxy(d->table);
283 
285  if (d->fontsize == -1) {
287  }
288 
289  d->fontsize++; // Make a little bigger
290 
291  d->selectWeek = new QComboBox(this); // read only week selection
292  d->selectWeek->setFocusPolicy(Qt::NoFocus);
293  d->todayButton = new QToolButton(this);
294  d->todayButton->setIcon(QIcon::fromTheme(QStringLiteral("go-jump-today")));
295 
296  d->yearForward->setToolTip(tr("Next year", "@info:tooltip"));
297  d->yearBackward->setToolTip(tr("Previous year", "@info:tooltip"));
298  d->monthForward->setToolTip(tr("Next month", "@info:tooltip"));
299  d->monthBackward->setToolTip(tr("Previous month", "@info:tooltip"));
300  d->selectWeek->setToolTip(tr("Select a week", "@info:tooltip"));
301  d->selectMonth->setToolTip(tr("Select a month", "@info:tooltip"));
302  d->selectYear->setToolTip(tr("Select a year", "@info:tooltip"));
303  d->todayButton->setToolTip(tr("Select the current day", "@info:tooltip"));
304 
305  // -----
306  setFontSize(d->fontsize);
307  d->line->setValidator(d->val);
308  d->line->installEventFilter(this);
310  d->yearForward->setIcon(QIcon::fromTheme(QStringLiteral("arrow-left-double")));
311  d->yearBackward->setIcon(QIcon::fromTheme(QStringLiteral("arrow-right-double")));
312  d->monthForward->setIcon(QIcon::fromTheme(QStringLiteral("arrow-left")));
313  d->monthBackward->setIcon(QIcon::fromTheme(QStringLiteral("arrow-right")));
314  } else {
315  d->yearForward->setIcon(QIcon::fromTheme(QStringLiteral("arrow-right-double")));
316  d->yearBackward->setIcon(QIcon::fromTheme(QStringLiteral("arrow-left-double")));
317  d->monthForward->setIcon(QIcon::fromTheme(QStringLiteral("arrow-right")));
318  d->monthBackward->setIcon(QIcon::fromTheme(QStringLiteral("arrow-left")));
319  }
320 
321  connect(d->table, QOverload<const QDate &>::of(&KDateTable::dateChanged), this, &KDatePicker::dateChangedSlot);
322  connect(d->table, &KDateTable::tableClicked, this, &KDatePicker::tableClickedSlot);
323  connect(d->monthForward, &QAbstractButton::clicked, this, &KDatePicker::monthForwardClicked);
324  connect(d->monthBackward, &QAbstractButton::clicked, this, &KDatePicker::monthBackwardClicked);
325  connect(d->yearForward, &QAbstractButton::clicked, this, &KDatePicker::yearForwardClicked);
326  connect(d->yearBackward, &QAbstractButton::clicked, this, &KDatePicker::yearBackwardClicked);
327  connect(d->selectWeek, QOverload<int>::of(&QComboBox::activated), this, &KDatePicker::weekSelected);
328  connect(d->todayButton, &QAbstractButton::clicked, this, &KDatePicker::todayButtonClicked);
329  connect(d->selectMonth, &QAbstractButton::clicked, this, &KDatePicker::selectMonthClicked);
330  connect(d->selectYear, &QAbstractButton::toggled, this, &KDatePicker::selectYearClicked);
331  connect(d->line, &QLineEdit::returnPressed, this, &KDatePicker::lineEnterPressed);
332 
333  topLayout->addWidget(d->table);
334 
335  QBoxLayout *bottomLayout = new QHBoxLayout();
336  bottomLayout->setContentsMargins(0, 0, 0, 0);
337  bottomLayout->setSpacing(0);
338  topLayout->addLayout(bottomLayout);
339 
340  bottomLayout->addWidget(d->todayButton);
341  bottomLayout->addWidget(d->line);
342  bottomLayout->addWidget(d->selectWeek);
343 
344  d->table->setDate(date_);
345  dateChangedSlot(date_); // needed because table emits changed only when newDate != oldDate
346 }
347 
348 KDatePicker::~KDatePicker() = default;
349 
351 {
352  if (e->type() == QEvent::KeyPress) {
353  QKeyEvent *k = (QKeyEvent *)e;
354 
355  if ((k->key() == Qt::Key_PageUp) //
356  || (k->key() == Qt::Key_PageDown) //
357  || (k->key() == Qt::Key_Up) //
358  || (k->key() == Qt::Key_Down)) {
359  QApplication::sendEvent(d->table, e);
360  d->table->setFocus();
361  return true; // eat event
362  }
363  }
364  return QFrame::eventFilter(o, e);
365 }
366 
368 {
370 }
371 
372 void KDatePicker::dateChangedSlot(const QDate &date_)
373 {
374  d->line->setText(locale().toString(date_, QLocale::ShortFormat));
375  d->selectMonth->setText(locale().standaloneMonthName(date_.month(), QLocale::LongFormat));
376  d->fillWeeksCombo();
377 
378  // calculate the item num in the week combo box; normalize selected day so as if 1.1. is the first day of the week
379  QDate firstDay(date_.year(), 1, 1);
380  // If we cannot successfully create the 1st of the year, this can only mean that
381  // the 1st is before the earliest valid date in the current calendar system, so use
382  // the earliestValidDate as the first day.
383  // In particular covers the case of Gregorian where 1/1/-4713 is not a valid QDate
384  d->selectWeek->setCurrentIndex((date_.dayOfYear() + firstDay.dayOfWeek() - 2) / 7);
385  d->selectYear->setText(QString::number(date_.year()).rightJustified(4, QLatin1Char('0')));
386 
387  Q_EMIT dateChanged(date_);
388 }
389 
390 void KDatePicker::tableClickedSlot()
391 {
394 }
395 
396 // TODO KF6: remove the const & from the returned QDate
397 const QDate &KDatePicker::date() const
398 {
399  return d->table->date();
400 }
401 
402 bool KDatePicker::setDate(const QDate &date_)
403 {
404  // the table setDate does validity checking for us
405  // this also emits dateChanged() which then calls our dateChangedSlot()
406  return d->table->setDate(date_);
407 }
408 
409 void KDatePicker::monthForwardClicked()
410 {
411  if (!setDate(date().addMonths(1))) {
413  }
414  d->table->setFocus();
415 }
416 
417 void KDatePicker::monthBackwardClicked()
418 {
419  if (!setDate(date().addMonths(-1))) {
421  }
422  d->table->setFocus();
423 }
424 
425 void KDatePicker::yearForwardClicked()
426 {
427  if (!setDate(d->table->date().addYears(1))) {
429  }
430  d->table->setFocus();
431 }
432 
433 void KDatePicker::yearBackwardClicked()
434 {
435  if (!setDate(d->table->date().addYears(-1))) {
437  }
438  d->table->setFocus();
439 }
440 
441 void KDatePicker::weekSelected(int index)
442 {
443  QDate targetDay = d->selectWeek->itemData(index).toDateTime().date();
444 
445  if (!setDate(targetDay)) {
447  }
448  d->table->setFocus();
449 }
450 
451 void KDatePicker::selectMonthClicked()
452 {
453  QDate thisDate(date());
454  d->table->setFocus();
455 
456  QMenu popup(d->selectMonth);
457  // Populate the pick list with all the month names, this may change by year
458  // JPL do we need to do something here for months that fall outside valid range?
459  const int monthsInYear = QDate(thisDate.year() + 1, 1, 1).addDays(-1).month();
460  for (int m = 1; m <= monthsInYear; m++) {
461  popup.addAction(locale().standaloneMonthName(m))->setData(m);
462  }
463 
464  QAction *item = popup.actions()[thisDate.month() - 1];
465  // if this happens the above should already given an assertion
466  if (item) {
467  popup.setActiveAction(item);
468  }
469 
470  // cancelled
471  if ((item = popup.exec(d->selectMonth->mapToGlobal(QPoint(0, 0)), item)) == nullptr) {
472  return;
473  }
474 
475  // We need to create a valid date in the month selected so we can find out how many days are
476  // in the month.
477  QDate newDate(thisDate.year(), item->data().toInt(), 1);
478 
479  // If we have succeeded in creating a date in the new month, then try to create the new date,
480  // checking we don't set a day after the last day of the month
481  newDate.setDate(newDate.year(), newDate.month(), qMin(thisDate.day(), newDate.daysInMonth()));
482 
483  // Set the date, if it's invalid in any way then alert user and don't update
484  if (!setDate(newDate)) {
486  }
487 }
488 
489 void KDatePicker::selectYearClicked()
490 {
491  if (!d->selectYear->isChecked()) {
492  return;
493  }
494 
495  QDate thisDate(date());
496 
497  KPopupFrame *popup = new KPopupFrame(this);
498  KDatePickerPrivateYearSelector *picker = new KDatePickerPrivateYearSelector(date(), popup);
499  picker->resize(picker->sizeHint());
500  picker->setYear(thisDate.year());
501  picker->selectAll();
502  popup->setMainWidget(picker);
503  connect(picker, &KDatePickerPrivateYearSelector::closeMe, popup, &KPopupFrame::close);
504  picker->setFocus();
505 
506  if (popup->exec(d->selectYear->mapToGlobal(QPoint(0, d->selectMonth->height())))) {
507  // We need to create a valid date in the year/month selected so we can find out how many
508  // days are in the month.
509  QDate newDate(picker->year(), thisDate.month(), 1);
510 
511  // If we have succeeded in creating a date in the new month, then try to create the new
512  // date, checking we don't set a day after the last day of the month
513  newDate = QDate(newDate.year(), newDate.month(), qMin(thisDate.day(), newDate.daysInMonth()));
514 
515  // Set the date, if it's invalid in any way then alert user and don't update
516  if (!setDate(newDate)) {
518  }
519  }
520  delete popup;
521 
522  d->selectYear->setChecked(false);
523 }
524 
525 void KDatePicker::uncheckYearSelector()
526 {
527  d->selectYear->setChecked(false);
528  d->selectYear->update();
529 }
530 
531 void KDatePicker::changeEvent(QEvent *event)
532 {
533  if (event && event->type() == QEvent::EnabledChange) {
534  if (isEnabled()) {
535  d->table->setFocus();
536  }
537  }
538 }
539 
540 KDateTable *KDatePicker::dateTable() const
541 {
542  return d->table;
543 }
544 
545 void KDatePicker::lineEnterPressed()
546 {
547  const QDate newDate = d->val->toDate(d->line->text());
548 
549  if (newDate.isValid()) {
550  Q_EMIT dateEntered(newDate);
551  setDate(newDate);
552  d->table->setFocus();
553  } else {
555  }
556 }
557 
558 void KDatePicker::todayButtonClicked()
559 {
561  d->table->setFocus();
562 }
563 
565 {
566  return QWidget::sizeHint();
567 }
568 
570 {
571  QWidget *const buttons[] = {
572  d->selectMonth,
573  d->selectYear,
574  };
575  QFont font;
576  QRect r;
577  // -----
578  d->fontsize = s;
579  for (QWidget *button : buttons) {
580  font = button->font();
581  font.setPointSize(s);
582  button->setFont(font);
583  }
584  d->table->setFontSize(s);
585 
586  QFontMetrics metrics(d->selectMonth->fontMetrics());
587  QString longestMonth;
588 
589  for (int i = 1;; ++i) {
591  if (str.isNull()) {
592  break;
593  }
594  r = metrics.boundingRect(str);
595 
596  if (r.width() > d->maxMonthRect.width()) {
597  d->maxMonthRect.setWidth(r.width());
598  longestMonth = str;
599  }
600  if (r.height() > d->maxMonthRect.height()) {
601  d->maxMonthRect.setHeight(r.height());
602  }
603  }
604 
606  opt.initFrom(d->selectMonth);
607  opt.text = longestMonth;
608 
609  // stolen from QToolButton
610  QSize textSize = metrics.size(Qt::TextShowMnemonic, longestMonth);
611  textSize.setWidth(textSize.width() + metrics.horizontalAdvance(QLatin1Char(' ')) * 2);
612  int w = textSize.width();
613  int h = textSize.height();
614  opt.rect.setHeight(h); // PM_MenuButtonIndicator depends on the height
615 
616  QSize metricBound = style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(w, h), d->selectMonth);
617 
618  d->selectMonth->setMinimumSize(metricBound);
619 }
620 
621 int KDatePicker::fontSize() const
622 {
623  return d->fontsize;
624 }
625 
627 {
628  if (enable == (d->closeButton != nullptr)) {
629  return;
630  }
631 
632  if (enable) {
633  d->closeButton = new QToolButton(this);
634  d->closeButton->setAutoRaise(true);
635  const int horizontalSpacing = style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
636  d->navigationLayout->addSpacing(horizontalSpacing);
637  d->navigationLayout->addWidget(d->closeButton);
638  d->closeButton->setToolTip(tr("Close", "@action:button"));
639  d->closeButton->setIcon(QIcon::fromTheme(QStringLiteral("window-close")));
641  } else {
642  delete d->closeButton;
643  d->closeButton = nullptr;
644  }
645 
646  updateGeometry();
647 }
648 
650 {
651  return (d->closeButton);
652 }
653 
654 #include "kdatepicker.moc"
bool isRightToLeft()
void dateChanged(const QDate &date)
This signal is emitted each time the selected date is changed.
bool close()
void setPointSize(int pointSize)
QEvent::Type type() const const
void setContentsMargins(int left, int top, int right, int bottom)
int width() const const
bool setDate(const QDate &date)
Sets the date.
void updateGeometry()
KGuiItem ok()
Returns the &#39;Ok&#39; gui item.
QVariant data() const const
QStyle * style() const const
virtual int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const const =0
void setActiveAction(QAction *act)
int height() const const
int day() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
QAction * addAction(const QString &text)
bool isNull() const const
KDatePicker(QWidget *parent=nullptr)
The constructor.
void initFrom(const QWidget *widget)
int pointSize() const const
int dayOfWeek() const const
bool isEnabled() const const
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
QString number(int n, int base)
QWidget * topLevelWidget() const const
int toInt(bool *ok) const const
Q_OBJECTQ_OBJECT
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...
int toInt(bool *ok, int base) const const
void setWidth(int width)
void setFocusProxy(QWidget *w)
void clicked(bool checked)
void activated(int index)
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...
bool sendEvent(QObject *receiver, QEvent *event)
bool isValid() const const
int daysInMonth() const const
int fontSize() const
Returns the font size of the widget elements.
bool hasCloseButton() const
int exec(const QPoint &p)
Execute the popup window.
virtual bool eventFilter(QObject *watched, QEvent *event)
const QDate & date() const
QAction * exec()
QLocale locale() const const
void setData(const QVariant &userData)
virtual QValidator::State validate(QString &input, int &pos) const const =0
int key() const const
void setFont(const QFont &)
bool eventFilter(QObject *o, QEvent *e) override
to catch move keyEvents when QLineEdit has keyFocus
virtual QSize sizeHint() const const
void returnPressed()
bool setDate(int year, int month, int day)
QFont systemFont(QFontDatabase::SystemFont type)
void setCloseButton(bool enable)
By calling this method with enable = true, KDatePicker will show a little close-button in the upper b...
PM_LayoutHorizontalSpacing
int width() const const
void resizeEvent(QResizeEvent *) override
the resize event
QDate toDate(const QString &string, QLocale::FormatType format) const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QDate currentDate()
void toggled(bool checked)
Frame with popup menu behavior.
Definition: kpopupframe.h:24
QString standaloneMonthName(int month, QLocale::FormatType type) const const
int height() const const
TextShowMnemonic
int dayOfYear() const const
QIcon fromTheme(const QString &name)
~KDatePicker() override
The destructor.
QDate addDays(qint64 ndays) const const
QDate fromJulianDay(qint64 jd)
A date selection widget.
Definition: kdatepicker.h:39
virtual void resizeEvent(QResizeEvent *event)
QSize sizeHint() const override
The size hint for date pickers.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QList< QAction * > actions() const const
int year() const const
void setFrame(bool)
void setFontSize(int)
Sets the font size of the widgets elements.
void tableClicked()
This signal is emitted when the day has been selected by clicking on it in the table.
int month() const const
virtual bool event(QEvent *e) override
bool isValid() const
Return if the current user input is valid.
virtual QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const const =0
Key_PageUp
void setSpacing(int spacing)
int pointSize() const const
void setMainWidget(QWidget *m)
Set the main widget.
Q_EMITQ_EMIT
QLocale locale() const const
void addLayout(QLayout *layout, int stretch)
void setValidator(const QValidator *validator)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Apr 20 2021 22:44:06 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.