File indexing completed on 2024-04-21 14:55:51

0001 /* This file is part of the KDE libraries
0002    Copyright (C) 2002 Hans Petter bieker <bieker@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License version 2 as published by the Free Software Foundation.
0007 
0008    This library is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    Library General Public License for more details.
0012 
0013    You should have received a copy of the GNU Library General Public License
0014    along with this library; see the file COPYING.LIB.  If not, write to
0015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0016    Boston, MA 02110-1301, USA.
0017 */
0018 
0019 #ifndef KDATETIMEWIDGET
0020 #define KDATETIMEWIDGET
0021 
0022 #include <kdelibs4support_export.h>
0023 
0024 #include <QWidget>
0025 #include <QDateTime>
0026 
0027 /**
0028  * @short A combination of a date and a time selection widget.
0029  *
0030  * This widget can be used to display or allow user selection of date and time.
0031  *
0032  * @see KDateWidget
0033  *
0034  * \image html kdatetimewidget.png "KDE Date Time Widget"
0035  *
0036  * @author Hans Petter Bieker <bieker@kde.org>
0037  */
0038 class KDELIBS4SUPPORT_EXPORT KDateTimeWidget : public QWidget
0039 {
0040     Q_OBJECT
0041     Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY valueChanged USER true)
0042 
0043 public:
0044     /**
0045      * Constructs a date and time selection widget.
0046      */
0047     KDELIBS4SUPPORT_DEPRECATED explicit KDateTimeWidget(QWidget *parent = nullptr);
0048 
0049     /**
0050      * Constructs a date and time selection widget with the initial date and
0051      * time set to @p datetime.
0052      */
0053     KDELIBS4SUPPORT_DEPRECATED explicit KDateTimeWidget(const QDateTime &datetime,
0054                              QWidget *parent = nullptr);
0055 
0056     /**
0057      * Destructs the date and time selection widget.
0058      */
0059     ~KDateTimeWidget() override;
0060 
0061     /**
0062      * Returns the currently selected date and time.
0063      */
0064     QDateTime dateTime() const;
0065 
0066 public Q_SLOTS:
0067     /**
0068      * Changes the selected date and time to @p datetime.
0069      */
0070     void setDateTime(const QDateTime &datetime);
0071 
0072 Q_SIGNALS:
0073     /**
0074      * Emitted whenever the date or time of the widget
0075      * is changed, either with setDateTime() or via user selection.
0076      */
0077     void valueChanged(const QDateTime &datetime);
0078 
0079 private:
0080     void initWidget();
0081 
0082 private Q_SLOTS:
0083     void slotValueChanged();
0084 
0085 private:
0086     class KDateTimeWidgetPrivate;
0087     KDateTimeWidgetPrivate *const d;
0088 };
0089 
0090 #endif