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 QQUICKWEEKNUMBERMODEL_P_H
5#define QQUICKWEEKNUMBERMODEL_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/qlocale.h>
20#include <QtQml/qqml.h>
21#include <QtCore/private/qglobal_p.h>
22
23QT_BEGIN_NAMESPACE
24
25class QQuickWeekNumberModelPrivate;
26
27class QQuickWeekNumberModel : public QAbstractListModel
28{
29 Q_OBJECT
30 Q_PROPERTY(int month READ month WRITE setMonth NOTIFY monthChanged FINAL)
31 Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL)
32 Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL)
33 Q_PROPERTY(int count READ rowCount CONSTANT FINAL)
34
35public:
36 explicit QQuickWeekNumberModel(QObject *parent = nullptr);
37
38 int month() const;
39 void setMonth(int month);
40
41 int year() const;
42 void setYear(int year);
43
44 QLocale locale() const;
45 void setLocale(const QLocale &locale);
46
47 Q_INVOKABLE int weekNumberAt(int index) const;
48 Q_INVOKABLE int indexOf(int weekNumber) const;
49
50 enum {
51 WeekNumberRole = Qt::UserRole + 1
52 };
53
54 QHash<int, QByteArray> roleNames() const override;
55 QVariant data(const QModelIndex &index, int role) const override;
56 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
57
58Q_SIGNALS:
59 void monthChanged();
60 void yearChanged();
61 void localeChanged();
62
63private:
64 Q_DISABLE_COPY(QQuickWeekNumberModel)
65 Q_DECLARE_PRIVATE(QQuickWeekNumberModel)
66};
67
68QT_END_NAMESPACE
69
70QML_DECLARE_TYPE(QQuickWeekNumberModel)
71
72#endif // QQUICKWEEKNUMBERMODEL_P_H
73

source code of qtdeclarative/src/quicktemplates/qquickweeknumbermodel_p.h