1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtOrganizer module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#ifndef QORGANIZERRECURRENCERULE_H
35#define QORGANIZERRECURRENCERULE_H
36
37#include <QtCore/qdatetime.h>
38#include <QtCore/qmetatype.h>
39#include <QtCore/qset.h>
40#include <QtCore/qshareddata.h>
41
42#include <QtOrganizer/qorganizerglobal.h>
43
44QT_BEGIN_NAMESPACE_ORGANIZER
45
46class QOrganizerRecurrenceRulePrivate;
47class Q_ORGANIZER_EXPORT QOrganizerRecurrenceRule
48{
49public:
50 enum Frequency {
51 Invalid = 0,
52 Daily,
53 Weekly,
54 Monthly,
55 Yearly
56 };
57
58 enum Month {
59 January = 1,
60 February,
61 March,
62 April,
63 May,
64 June,
65 July,
66 August,
67 September,
68 October,
69 November,
70 December
71 };
72
73 enum LimitType {
74 NoLimit = 0,
75 CountLimit,
76 DateLimit
77 };
78
79 QOrganizerRecurrenceRule();
80 QOrganizerRecurrenceRule(const QOrganizerRecurrenceRule &other);
81 ~QOrganizerRecurrenceRule();
82
83 QOrganizerRecurrenceRule &operator=(const QOrganizerRecurrenceRule &other);
84
85 bool operator==(const QOrganizerRecurrenceRule &other) const;
86 inline bool operator!=(const QOrganizerRecurrenceRule &other) const { return !operator==(other); }
87
88 void setFrequency(Frequency freq);
89 Frequency frequency() const;
90
91 void setLimit(int count);
92 void setLimit(const QDate &date);
93 void clearLimit();
94
95 LimitType limitType() const;
96 int limitCount() const;
97 QDate limitDate() const;
98
99 void setInterval(int interval);
100 int interval() const;
101
102 void setDaysOfWeek(const QSet<Qt::DayOfWeek> &days);
103 QSet<Qt::DayOfWeek> daysOfWeek() const;
104
105 void setDaysOfMonth(const QSet<int> &days);
106 QSet<int> daysOfMonth() const;
107
108 void setDaysOfYear(const QSet<int> &days);
109 QSet<int> daysOfYear() const;
110
111 void setMonthsOfYear(const QSet<Month> &months);
112 QSet<Month> monthsOfYear() const;
113
114 void setWeeksOfYear(const QSet<int> &weeks);
115 QSet<int> weeksOfYear() const;
116
117 void setFirstDayOfWeek(Qt::DayOfWeek day);
118 Qt::DayOfWeek firstDayOfWeek() const;
119
120 void setPositions(const QSet<int> &pos);
121 QSet<int> positions() const;
122
123private:
124 QSharedDataPointer<QOrganizerRecurrenceRulePrivate> d;
125};
126
127//hash functions
128Q_ORGANIZER_EXPORT uint qHash(const QOrganizerRecurrenceRule &rule);
129
130#ifndef QT_NO_DEBUG_STREAM
131Q_ORGANIZER_EXPORT QDebug operator<<(QDebug dbg, const QOrganizerRecurrenceRule &rule);
132#endif // QT_NO_DEBUG_STREAM
133
134inline uint qHash(QOrganizerRecurrenceRule::Month month)
135{
136 return static_cast<uint>(month);
137}
138
139QT_END_NAMESPACE_ORGANIZER
140
141QT_BEGIN_NAMESPACE
142Q_DECLARE_TYPEINFO(QTORGANIZER_PREPEND_NAMESPACE(QOrganizerRecurrenceRule), Q_MOVABLE_TYPE);
143QT_END_NAMESPACE
144
145Q_DECLARE_METATYPE(QTORGANIZER_PREPEND_NAMESPACE(QOrganizerRecurrenceRule))
146Q_DECLARE_METATYPE(QSet<QTORGANIZER_PREPEND_NAMESPACE(QOrganizerRecurrenceRule)>)
147Q_DECLARE_METATYPE(QSet<QDate>)
148
149#endif // QORGANIZERRECURRENCERULE_H
150

source code of qtpim/src/organizer/qorganizerrecurrencerule.h