Kstars

genericcalendarwidget.h
1/*
2 SPDX-FileCopyrightText: 2010 Akarsh Simha <akarshsimha@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ui_genericcalendarwidget.h"
10
11#include <QDate>
12
13/**
14 *@class GenericCalendarWidget
15 *@author Akarsh Simha
16 *@version 1.0
17 *@short Uses any KDateTable subclass for the date table and provides a calendar with options to choose a month / year.
18 *@note This supports only the Gregorian calendar system for simplicity.
19 *@note This shouldn't be the way to do things in the first place, but
20 * this is until KDatePicker starts supporting overridden
21 * KDateTables and the like
22 */
23
24class GenericCalendarWidget : public QWidget, public Ui::GenericCalendarWidgetUi
25{
27
28 public:
29 /** @short Constructor. Sets up the Ui, connects signals to slots etc. */
31
32 /** @short Empty destructor */
33 virtual ~GenericCalendarWidget() override = default;
34
35 /** @short Returns the selected date */
36 const QDate &date() const;
37
38 public slots:
39 /**
40 * @short Set the month
41 * @param month The month to choose
42 */
43 bool setMonth(int month);
44
45 /**
46 * @short Set the year
47 * @param year The year to choose
48 */
49 bool setYear(int year);
50
51 /**
52 * @short Set the selected day of month
53 * @param date_ The date of the month to choose
54 */
55 bool setDate(int date_);
56
57 /**
58 * @short Set the selected date
59 * @param date_ The date to set
60 */
61 bool setDate(const QDate &date_);
62
63 signals:
64 /**
65 * @short Emitted when the date has been changed
66 * @note Emitted by dateTableDateChanged() which subscribes to KDateTable::dateChanged()
67 */
68 void dateChanged(const QDate &date_);
69
70 private slots:
71
72 /** @short Called when the previous / next year / month buttons are clicked */
73 void previousYearClicked();
74 void nextYearClicked();
75 void previousMonthClicked();
76 void nextMonthClicked();
77
78 /** @short Called when the year changes through the spin box */
79 void yearChanged(int year);
80
81 /** @short Called when the month changes through the combo box */
82 void monthChanged(int month);
83
84 /**
85 * @short Subscribes to KDateTable::dateChanged() and echoes it by emitting this widget's dateChanged signals
86 * @note For details on parameters, see KDateTable::dateChanged()
87 */
88 void dateChangedSlot(const QDate &date_);
89
90 private:
91 /** @short Fills the month combo box with month names */
92 void populateMonthNames();
93
94 /** @short Returns a link to the KCalendarSystem in use */
95 const KCalendarSystem *calendar() const;
96
97 QDate m_Date;
98};
Uses any KDateTable subclass for the date table and provides a calendar with options to choose a mont...
virtual ~GenericCalendarWidget() override=default
Empty destructor.
bool setYear(int year)
Set the year.
GenericCalendarWidget(KDateTable &dateTable, QWidget *parent=nullptr)
Constructor.
bool setMonth(int month)
Set the month.
const QDate & date() const
Returns the selected date.
void dateChanged(const QDate &date_)
Emitted when the date has been changed.
bool setDate(int date_)
Set the selected day of month.
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.