1 | // Copyright (C) 2021 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICKMONTHMODEL_P_H |
5 | #define QQUICKMONTHMODEL_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtCore/qabstractitemmodel.h> |
19 | #include <QtCore/qdatetime.h> |
20 | #include <QtCore/qlocale.h> |
21 | #include <QtQml/qqml.h> |
22 | #include <QtCore/private/qglobal_p.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QQuickMonthModelPrivate; |
27 | |
28 | class QQuickMonthModel : public QAbstractListModel |
29 | { |
30 | Q_OBJECT |
31 | Q_PROPERTY(int month READ month WRITE setMonth NOTIFY monthChanged FINAL) |
32 | Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL) |
33 | Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) |
34 | Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) |
35 | Q_PROPERTY(int count READ rowCount CONSTANT FINAL) |
36 | |
37 | public: |
38 | explicit QQuickMonthModel(QObject *parent = nullptr); |
39 | |
40 | int month() const; |
41 | void setMonth(int month); |
42 | |
43 | int year() const; |
44 | void setYear(int year); |
45 | |
46 | QLocale locale() const; |
47 | void setLocale(const QLocale &locale); |
48 | |
49 | QString title() const; |
50 | void setTitle(const QString &title); |
51 | |
52 | Q_INVOKABLE QDate dateAt(int index) const; |
53 | Q_INVOKABLE int indexOf(const QDate &date) const; |
54 | |
55 | enum { |
56 | DateRole = Qt::UserRole + 1, |
57 | DayRole, |
58 | TodayRole, |
59 | WeekNumberRole, |
60 | MonthRole, |
61 | YearRole |
62 | }; |
63 | |
64 | QHash<int, QByteArray> roleNames() const override; |
65 | QVariant data(const QModelIndex &index, int role) const override; |
66 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
67 | |
68 | Q_SIGNALS: |
69 | void monthChanged(); |
70 | void yearChanged(); |
71 | void localeChanged(); |
72 | void titleChanged(); |
73 | |
74 | private: |
75 | Q_DISABLE_COPY(QQuickMonthModel) |
76 | Q_DECLARE_PRIVATE(QQuickMonthModel) |
77 | }; |
78 | |
79 | QT_END_NAMESPACE |
80 | |
81 | QML_DECLARE_TYPE(QQuickMonthModel) |
82 | |
83 | #endif // QQUICKMONTHMODEL_P_H |
84 |