~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/widgets/qdatetimeedit.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the widgets module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QDATETIMEEDIT_H
 
30
#define QDATETIMEEDIT_H
 
31
 
 
32
#include <QtCore/qdatetime.h>
 
33
#include <QtGui/qabstractspinbox.h>
 
34
 
 
35
class QDateTimeEditPrivate;
 
36
class Q_GUI_EXPORT QDateTimeEdit : public QAbstractSpinBox
 
37
{
 
38
    Q_OBJECT
 
39
 
 
40
    Q_ENUMS(Section)
 
41
    Q_FLAGS(Sections)
 
42
    Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged)
 
43
    Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged)
 
44
    Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChangedu)
 
45
    Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate RESET clearMaximumDate)
 
46
    Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate RESET clearMinimumDate)
 
47
    Q_PROPERTY(QTime maximumTime READ maximumTime WRITE setMaximumTime RESET clearMaximumTime)
 
48
    Q_PROPERTY(QTime minimumTime READ minimumTime WRITE setMinimumTime RESET clearMinimumTime)
 
49
    Q_PROPERTY(Section currentSection READ currentSection WRITE setCurrentSection)
 
50
    Q_PROPERTY(Sections displayedSections READ displayedSections)
 
51
    Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
 
52
 
 
53
public:
 
54
    enum Section {
 
55
        NoSection = 0x0000,
 
56
        AmPmSection = 0x0001,
 
57
        MSecSection = 0x0002,
 
58
        SecondSection = 0x0004,
 
59
        MinuteSection = 0x0008,
 
60
        HourSection   = 0x0010,
 
61
        DaySection    = 0x0100,
 
62
        MonthSection  = 0x0200,
 
63
        YearSection   = 0x0400,
 
64
        TimeSections_Mask = AmPmSection|MSecSection|SecondSection|MinuteSection|HourSection,
 
65
        DateSections_Mask = DaySection|MonthSection|YearSection
 
66
    };
 
67
 
 
68
    Q_DECLARE_FLAGS(Sections, Section)
 
69
 
 
70
    explicit QDateTimeEdit(QWidget *parent = 0);
 
71
    explicit QDateTimeEdit(const QDateTime &dt, QWidget *parent = 0);
 
72
    explicit QDateTimeEdit(const QDate &d, QWidget *parent = 0);
 
73
    explicit QDateTimeEdit(const QTime &t, QWidget *parent = 0);
 
74
 
 
75
    QDateTime dateTime() const;
 
76
    QDate date() const;
 
77
    QTime time() const;
 
78
 
 
79
    QDate minimumDate() const;
 
80
    void setMinimumDate(const QDate &min);
 
81
    void clearMinimumDate();
 
82
 
 
83
    QDate maximumDate() const;
 
84
    void setMaximumDate(const QDate &max);
 
85
    void clearMaximumDate();
 
86
 
 
87
    void setDateRange(const QDate &min, const QDate &max);
 
88
 
 
89
    QTime minimumTime() const;
 
90
    void setMinimumTime(const QTime &min);
 
91
    void clearMinimumTime();
 
92
 
 
93
    QTime maximumTime() const;
 
94
    void setMaximumTime(const QTime &max);
 
95
    void clearMaximumTime();
 
96
 
 
97
    void setTimeRange(const QTime &min, const QTime &max);
 
98
 
 
99
    Sections displayedSections() const;
 
100
    Section currentSection() const;
 
101
    void setCurrentSection(Section section);
 
102
 
 
103
    QString sectionText(Section s) const;
 
104
 
 
105
    QString displayFormat() const;
 
106
    void setDisplayFormat(const QString &format);
 
107
 
 
108
    QSize sizeHint() const;
 
109
 
 
110
    virtual void clear();
 
111
    virtual void stepBy(int steps);
 
112
 
 
113
    bool event(QEvent *e);
 
114
signals:
 
115
    void dateTimeChanged(const QDateTime &date);
 
116
    void timeChanged(const QTime &date);
 
117
    void dateChanged(const QDate &date);
 
118
 
 
119
public slots:
 
120
    void setDateTime(const QDateTime &dateTime);
 
121
    void setDate(const QDate &date);
 
122
    void setTime(const QTime &time);
 
123
 
 
124
protected:
 
125
    virtual void keyPressEvent(QKeyEvent *e);
 
126
    virtual void wheelEvent(QWheelEvent *e);
 
127
    virtual void focusInEvent(QFocusEvent *e);
 
128
    virtual bool focusNextPrevChild(bool next);
 
129
    virtual QValidator::State validate(QString &input, int &pos) const;
 
130
    virtual QDateTime dateTimeFromText(const QString &text) const;
 
131
    virtual QString textFromDateTime(const QDateTime &dt) const;
 
132
    virtual StepEnabled stepEnabled() const;
 
133
 
 
134
private:
 
135
    Q_DECLARE_PRIVATE(QDateTimeEdit)
 
136
    Q_DISABLE_COPY(QDateTimeEdit)
 
137
};
 
138
 
 
139
class Q_GUI_EXPORT QTimeEdit : public QDateTimeEdit
 
140
{
 
141
    Q_OBJECT
 
142
public:
 
143
    QTimeEdit(QWidget *parent = 0);
 
144
    QTimeEdit(const QTime &t, QWidget *parent = 0);
 
145
};
 
146
 
 
147
class Q_GUI_EXPORT QDateEdit : public QDateTimeEdit
 
148
{
 
149
    Q_OBJECT
 
150
public:
 
151
    QDateEdit(QWidget *parent = 0);
 
152
    QDateEdit(const QDate &t, QWidget *parent = 0);
 
153
};
 
154
 
 
155
Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeEdit::Sections)
 
156
 
 
157
 
 
158
#endif // QDATETIMEEDIT_H