KCalendarCore

period.h
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 2001-2003 Cornelius Schumacher <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
18 #ifndef KCALCORE_PERIOD_H
19 #define KCALCORE_PERIOD_H
20 
21 #include "kcalendarcore_export.h"
22 #include "duration.h"
23 
24 #include <QDateTime>
25 #include <QDataStream>
26 #include <QMetaType>
27 #include <QVector>
28 
29 class QTimeZone;
30 
31 namespace KCalendarCore
32 {
33 
38 class KCALENDARCORE_EXPORT Period
39 {
40 public:
45 
49  Period();
50 
57  Period(const QDateTime &start, const QDateTime &end);
58 
65  Period(const QDateTime &start, const Duration &duration);
66 
73  Period(const Period &period);
74 
78  ~Period();
79 
86  bool operator<(const Period &other) const;
87 
94  bool operator>(const Period &other) const
95  {
96  return other.operator < (*this);
97  }
98 
107  bool operator==(const Period &other) const;
108 
115  bool operator!=(const Period &other) const
116  {
117  return !operator==(other);
118  }
119 
125  Period &operator=(const Period &other);
126 
130  Q_REQUIRED_RESULT QDateTime start() const;
131 
135  Q_REQUIRED_RESULT QDateTime end() const;
136 
149  Q_REQUIRED_RESULT Duration duration() const;
150 
162  Q_REQUIRED_RESULT Duration duration(Duration::Type type) const;
163 
168  Q_REQUIRED_RESULT bool hasDuration() const;
169 
184  void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone);
185 
186 private:
187  //@cond PRIVATE
188  class Private;
189  Private *const d;
190  //@endcond
191 
192  friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &stream,
193  const KCalendarCore::Period &period);
194 
195  friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &stream,
196  KCalendarCore::Period &period);
197 };
198 
200 KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const KCalendarCore::Period &period);
201 
203 KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &stream, KCalendarCore::Period &period);
204 
209 KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key);
210 }
211 
212 //@cond PRIVATE
213 Q_DECLARE_METATYPE(KCalendarCore::Period)
214 Q_DECLARE_TYPEINFO(KCalendarCore::Period, Q_MOVABLE_TYPE);
215 //@endcond
216 
217 #endif
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Alarm serializer.
Definition: alarm.cpp:825
bool operator!=(const Period &other) const
Returns true if this period is not equal to the other one.
Definition: period.h:115
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Alarm deserializer.
Definition: alarm.cpp:849
Represents a span of time measured in seconds or days.
Definition: duration.h:44
The period can be defined by either a start time and an end time or by a start time and a duration...
Definition: period.h:38
QVector< Period > List
List of periods.
Definition: period.h:44
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
Return a hash value for a Period argument.
Definition: period.cpp:154
This file is part of the API for handling calendar data and defines the Duration class.
Type
The unit of time used to define the duration.
Definition: duration.h:50
bool operator>(const Period &other) const
Returns true if the start of this period is later than the start of the other one.
Definition: period.h:94
Namespace for all KCalendarCore types.
Definition: alarm.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Sep 25 2020 22:51:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.