File indexing completed on 2024-04-21 03:53:35

0001 /*
0002     This file is part of the KContacts framework.
0003     SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KCONTACTS_TIMEZONE_H
0009 #define KCONTACTS_TIMEZONE_H
0010 
0011 #include "kcontacts_export.h"
0012 #include <QSharedDataPointer>
0013 #include <QString>
0014 
0015 namespace KContacts
0016 {
0017 /**
0018  * @short Time zone information.
0019  *
0020  * This class stores information about a time zone.
0021  */
0022 class KCONTACTS_EXPORT TimeZone
0023 {
0024     friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const TimeZone &);
0025     friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, TimeZone &);
0026 
0027 public:
0028     /**
0029      * Construct invalid time zone.
0030      */
0031     TimeZone();
0032 
0033     /**
0034      * Construct time zone.
0035      *
0036      * @param offset Offset in minutes relative to UTC.
0037      */
0038     TimeZone(int offset);
0039 
0040     /**
0041      * Copy constructor.
0042      */
0043     TimeZone(const TimeZone &other);
0044 
0045     /**
0046      * Destroys the time zone.
0047      */
0048     ~TimeZone();
0049 
0050     /**
0051      * Set time zone offset relative to UTC.
0052      *
0053      * @param offset Offset in minutes.
0054      */
0055     void setOffset(int offset);
0056 
0057     /**
0058      * Return offset in minutes relative to UTC.
0059      */
0060     Q_REQUIRED_RESULT int offset() const;
0061 
0062     /**
0063      * Return, if this time zone object is valid.
0064      */
0065     Q_REQUIRED_RESULT bool isValid() const;
0066 
0067     Q_REQUIRED_RESULT bool operator==(const TimeZone &other) const;
0068     Q_REQUIRED_RESULT bool operator!=(const TimeZone &other) const;
0069     TimeZone &operator=(const TimeZone &other);
0070 
0071     /**
0072      * Return string representation of time zone offset.
0073      */
0074     Q_REQUIRED_RESULT QString toString() const;
0075 
0076 private:
0077     class Private;
0078     QSharedDataPointer<Private> d;
0079 };
0080 
0081 /**
0082  * Serializes the @p timezone object into the @p stream.
0083  */
0084 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const TimeZone &timeZone);
0085 
0086 /**
0087  * Initializes the @p timezone object from the @p stream.
0088  */
0089 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, TimeZone &timeZone);
0090 }
0091 Q_DECLARE_TYPEINFO(KContacts::TimeZone, Q_RELOCATABLE_TYPE);
0092 
0093 #endif