1 | /* |
2 | This file is part of the KContacts framework. |
3 | SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef KCONTACTS_TIMEZONE_H |
9 | #define KCONTACTS_TIMEZONE_H |
10 | |
11 | #include "kcontacts_export.h" |
12 | #include <QSharedDataPointer> |
13 | #include <QString> |
14 | |
15 | namespace KContacts |
16 | { |
17 | /** |
18 | * @short Time zone information. |
19 | * |
20 | * This class stores information about a time zone. |
21 | */ |
22 | class KCONTACTS_EXPORT TimeZone |
23 | { |
24 | friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const TimeZone &); |
25 | friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, TimeZone &); |
26 | |
27 | public: |
28 | /** |
29 | * Construct invalid time zone. |
30 | */ |
31 | TimeZone(); |
32 | |
33 | /** |
34 | * Construct time zone. |
35 | * |
36 | * @param offset Offset in minutes relative to UTC. |
37 | */ |
38 | TimeZone(int offset); |
39 | |
40 | /** |
41 | * Copy constructor. |
42 | */ |
43 | TimeZone(const TimeZone &other); |
44 | |
45 | /** |
46 | * Destroys the time zone. |
47 | */ |
48 | ~TimeZone(); |
49 | |
50 | /** |
51 | * Set time zone offset relative to UTC. |
52 | * |
53 | * @param offset Offset in minutes. |
54 | */ |
55 | void setOffset(int offset); |
56 | |
57 | /** |
58 | * Return offset in minutes relative to UTC. |
59 | */ |
60 | Q_REQUIRED_RESULT int offset() const; |
61 | |
62 | /** |
63 | * Return, if this time zone object is valid. |
64 | */ |
65 | Q_REQUIRED_RESULT bool isValid() const; |
66 | |
67 | Q_REQUIRED_RESULT bool operator==(const TimeZone &other) const; |
68 | Q_REQUIRED_RESULT bool operator!=(const TimeZone &other) const; |
69 | TimeZone &operator=(const TimeZone &other); |
70 | |
71 | /** |
72 | * Return string representation of time zone offset. |
73 | */ |
74 | Q_REQUIRED_RESULT QString toString() const; |
75 | |
76 | private: |
77 | class Private; |
78 | QSharedDataPointer<Private> d; |
79 | }; |
80 | |
81 | /** |
82 | * Serializes the @p timezone object into the @p stream. |
83 | */ |
84 | KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const TimeZone &timeZone); |
85 | |
86 | /** |
87 | * Initializes the @p timezone object from the @p stream. |
88 | */ |
89 | KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, TimeZone &timeZone); |
90 | } |
91 | Q_DECLARE_TYPEINFO(KContacts::TimeZone, Q_RELOCATABLE_TYPE); |
92 | |
93 | #endif |
94 | |