1/* This file is part of the KDE libraries
2 Copyright (C) 2001 Waldo Bastian (bastian@kde.org)
3 Copyright (c) 2007 John Layt <john@layt.net>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KDATEWIDGET_H
21#define KDATEWIDGET_H
22
23#include <kdeui_export.h>
24
25#include <QtGui/QWidget>
26
27#include "klocale.h"
28
29class KCalendarSystem;
30
31class QDate;
32
33/**
34 * @short A date selection widget.
35 *
36 * This widget can be used to display or allow user selection of a date.
37 *
38 * \image html kdatewidget.png "KDE Date Widget"
39 *
40 * @see KDatePicker
41 *
42 * @author Waldo Bastian <bastian@kde.org>, John Layt <john@layt.net>
43 */
44class KDEUI_EXPORT KDateWidget : public QWidget
45{
46 Q_OBJECT
47 Q_PROPERTY( QDate date READ date WRITE setDate NOTIFY changed USER true )
48//FIXME Q_PROPERTY( KCalendarSystem calendar READ calendar WRITE setCalendar USER true )
49
50public:
51 /**
52 * Constructs a date selection widget.
53 */
54 explicit KDateWidget( QWidget *parent = 0 );
55
56 /**
57 * Constructs a date selection widget with the initial date set to @p date.
58 */
59 explicit KDateWidget( const QDate &date, QWidget *parent = 0 );
60
61 /**
62 * Destructs the date selection widget.
63 */
64 virtual ~KDateWidget();
65
66 // KDE5 remove const &
67 /**
68 * Returns the currently selected date.
69 */
70 const QDate& date() const;
71
72 /**
73 * Changes the selected date to @p date.
74 *
75 * @return @c true if the date was successfully set, @c false otherwise
76 */
77 bool setDate( const QDate &date );
78
79 /**
80 * Returns the currently selected calendar system.
81 *
82 * @return a KCalendarSystem object
83 */
84 const KCalendarSystem *calendar() const;
85
86 /**
87 * Changes the calendar system to use. Can use its own local locale if set.
88 *
89 * @param calendar the calendar system object to use, defaults to global
90 *
91 * @return @c true if the calendar system was successfully set, @c false otherwise
92 */
93 bool setCalendar( KCalendarSystem *calendar = 0 );
94
95 /**
96 * Changes the calendar system to use. Will always use global locale.
97 *
98 * @param calendarType the calendar system type to use
99 *
100 * @return @c true if the calendar system was successfully set, @c false otherwise
101 */
102 bool setCalendar( const QString &calendarType );
103
104 /**
105 * @since 4.6
106 *
107 * Changes the calendar system to use. Will always use global locale.
108 *
109 * @param calendarSystem the calendar system to use
110 * @return @c true if the calendar system was successfully set, @c false otherwise
111 */
112 bool setCalendarSystem( KLocale::CalendarSystem calendarSystem );
113
114Q_SIGNALS:
115 /**
116 * Emitted whenever the date of the widget
117 * is changed, either with setDate() or via user selection.
118 */
119 void changed( const QDate& date );
120
121protected:
122 void init( const QDate& date );
123
124protected Q_SLOTS:
125 void slotDateChanged();
126
127private:
128 class KDateWidgetPrivate;
129 KDateWidgetPrivate * const d;
130};
131
132#endif // KDATEWIDGET_H
133
134