| 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 | * \class KContacts::TimeZone |
| 19 | * \inheaderfile KContacts/TimeZone |
| 20 | * \inmodule KContacts |
| 21 | * |
| 22 | * \brief Time zone information. |
| 23 | * |
| 24 | * This class stores information about a time zone. |
| 25 | */ |
| 26 | class KCONTACTS_EXPORT TimeZone |
| 27 | { |
| 28 | friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const TimeZone &); |
| 29 | friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, TimeZone &); |
| 30 | |
| 31 | public: |
| 32 | /*! |
| 33 | * Construct invalid time zone. |
| 34 | */ |
| 35 | TimeZone(); |
| 36 | |
| 37 | /*! |
| 38 | * Construct time zone. |
| 39 | * |
| 40 | * \a offset Offset in minutes relative to UTC. |
| 41 | */ |
| 42 | TimeZone(int offset); |
| 43 | |
| 44 | TimeZone(const TimeZone &other); |
| 45 | |
| 46 | ~TimeZone(); |
| 47 | |
| 48 | /*! |
| 49 | * Set time zone offset relative to UTC. |
| 50 | * |
| 51 | * \a offset Offset in minutes. |
| 52 | */ |
| 53 | void setOffset(int offset); |
| 54 | |
| 55 | /*! |
| 56 | * Return offset in minutes relative to UTC. |
| 57 | */ |
| 58 | Q_REQUIRED_RESULT int offset() const; |
| 59 | |
| 60 | /*! |
| 61 | * Return, if this time zone object is valid. |
| 62 | */ |
| 63 | Q_REQUIRED_RESULT bool isValid() const; |
| 64 | |
| 65 | /*! |
| 66 | */ |
| 67 | Q_REQUIRED_RESULT bool operator==(const TimeZone &other) const; |
| 68 | |
| 69 | /*! |
| 70 | */ |
| 71 | Q_REQUIRED_RESULT bool operator!=(const TimeZone &other) const; |
| 72 | TimeZone &operator=(const TimeZone &other); |
| 73 | |
| 74 | /*! |
| 75 | * Return string representation of time zone offset. |
| 76 | */ |
| 77 | Q_REQUIRED_RESULT QString toString() const; |
| 78 | |
| 79 | private: |
| 80 | class Private; |
| 81 | QSharedDataPointer<Private> d; |
| 82 | }; |
| 83 | |
| 84 | /*! |
| 85 | * \relates KContacts::TimeZone |
| 86 | * |
| 87 | * Serializes the \a timeZone object into the \a stream. |
| 88 | */ |
| 89 | KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const TimeZone &timeZone); |
| 90 | |
| 91 | /*! |
| 92 | * \relates KContacts::TimeZone |
| 93 | * |
| 94 | * Initializes the \a timeZone object from the \a stream. |
| 95 | */ |
| 96 | KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, TimeZone &timeZone); |
| 97 | } |
| 98 | Q_DECLARE_TYPEINFO(KContacts::TimeZone, Q_RELOCATABLE_TYPE); |
| 99 | |
| 100 | #endif |
| 101 | |