KDELibs4Support

ksystemtimezone.h
Go to the documentation of this file.
1 /*
2  This file is part of the KDE libraries
3  Copyright (c) 2005-2007,2009-2012 David Jarvie <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
27 #ifndef _KSYSTEMTIMEZONE_H
28 #define _KSYSTEMTIMEZONE_H
29 
30 #include <kdelibs4support_export.h>
31 #include "ktimezone.h"
32 
33 #include <QObject>
34 #include <QDateTime>
35 #include <QList>
36 #include <QString>
37 #include <QByteArray>
38 
40 class KSystemTimeZonePrivate;
41 class KSystemTimeZonesPrivate;
42 class KSystemTimeZoneSourcePrivate;
43 class KSystemTimeZoneDataPrivate;
44 
94 class KDELIBS4SUPPORT_EXPORT KSystemTimeZones : public QObject
95 {
96  Q_OBJECT
97 public:
99 
106  static KTimeZones *timeZones();
107 
113  static const KTimeZones::ZoneMap zones();
114 
126  static KTimeZone zone(const QString &name);
127 
138  static KTimeZone readZone(const QString &name);
139 
167  static KTimeZone local();
168 
187  static KTimeZone realLocalZone();
188 
208  static void setLocalZone(const KTimeZone &tz);
209 
230  static bool isSimulated();
231 
237  static QString zoneinfoDir();
238 
245  static bool isTimeZoneDaemonAvailable();
246 
247 private Q_SLOTS:
248  // Connected to D-Bus signals
249  void configChanged();
250  void zonetabChanged(const QString &zonetab);
251  void zoneDefinitionChanged(const QString &zone);
252 
253 private:
255 
256  KSystemTimeZonesPrivate *const d;
257  friend class KSystemTimeZonesPrivate;
258 };
259 
282 class KDELIBS4SUPPORT_EXPORT KSystemTimeZone : public KTimeZone //krazy:exclude=dpointer (no d-pointer for KTimeZone derived classes)
283 {
284 public:
285 
296  KSystemTimeZone(KSystemTimeZoneSource *source, const QString &name,
297  const QString &countryCode = QString(), float latitude = UNKNOWN, float longitude = UNKNOWN,
298  const QString &comment = QString());
299 
300  ~KSystemTimeZone();
301 
302 private:
303  // d-pointer is in KSystemTimeZoneBackend.
304  // This is a requirement for classes inherited from KTimeZone.
305 };
306 
320 class KDELIBS4SUPPORT_EXPORT KSystemTimeZoneBackend : public KTimeZoneBackend //krazy:exclude=dpointer (non-const d-pointer for KTimeZoneBackend-derived classes)
321 {
322 public:
325  const QString &countryCode, float latitude, float longitude, const QString &comment);
326 
328 
334  KTimeZoneBackend *clone() const override;
335 
341  QByteArray type() const override;
342 
363  int offsetAtZoneTime(const KTimeZone *caller, const QDateTime &zoneDateTime, int *secondOffset) const override;
364 
381  int offsetAtUtc(const KTimeZone *caller, const QDateTime &utcDateTime) const override;
382 
396  int offset(const KTimeZone *caller, time_t t) const override;
397 
411  bool isDstAtUtc(const KTimeZone *caller, const QDateTime &utcDateTime) const override;
412 
423  bool isDst(const KTimeZone *caller, time_t t) const override;
424 
425 private:
426  KSystemTimeZonePrivate *d; // non-const
427 };
428 
439 class KDELIBS4SUPPORT_EXPORT KSystemTimeZoneSource : public KTimeZoneSource
440 {
441 public:
446  virtual ~KSystemTimeZoneSource();
447 
457  KTimeZoneData *parse(const KTimeZone &zone) const override;
458 
469  static void startParseBlock();
470 
474  static void endParseBlock();
475 
476 private:
477  KSystemTimeZoneSourcePrivate *const d;
478 };
479 
490 {
491  friend class KSystemTimeZoneSource;
492 
493 public:
497  virtual ~KSystemTimeZoneData();
498 
500  KSystemTimeZoneData &operator=(const KSystemTimeZoneData &);
501 
510  KTimeZoneData *clone() const override;
511 
517  QList<QByteArray> abbreviations() const override;
518  QByteArray abbreviation(const QDateTime &utcDateTime) const override;
519 
527  QList<int> utcOffsets() const override;
528 
529 private:
530  KSystemTimeZoneDataPrivate *const d;
531 };
532 
533 #endif
virtual QByteArray type() const
Returns the class name of the data represented by this instance.
Definition: ktimezone.cpp:455
Base class for the parsed data returned by a KTimeZoneSource class.
Definition: ktimezone.h:1302
virtual int offsetAtZoneTime(const KTimeZone *caller, const QDateTime &zoneDateTime, int *secondOffset) const
Implements KTimeZone::offsetAtZoneTime().
Definition: ktimezone.cpp:465
virtual KTimeZoneData * parse(const KTimeZone &zone) const
Extracts detail information for one time zone from the source database.
Definition: ktimezone.cpp:980
The KTimeZones class represents a time zone database which consists of a collection of individual tim...
Definition: ktimezone.h:308
The KSystemTimeZone class represents a time zone in the system database.
Backend class for KSystemTimeZone class.
virtual KTimeZoneBackend * clone() const
Creates a copy of this instance.
Definition: ktimezone.cpp:460
virtual bool isDst(const KTimeZone *caller, time_t t) const
Implements KTimeZone::isDst().
Definition: ktimezone.cpp:574
Time zone functions.
A class to read and parse system time zone data.
Base class representing a time zone.
Definition: ktimezone.h:415
virtual int offsetAtUtc(const KTimeZone *caller, const QDateTime &utcDateTime) const
Implements KTimeZone::offsetAtUtc().
Definition: ktimezone.cpp:526
virtual int offset(const KTimeZone *caller, time_t t) const
Implements KTimeZone::offset().
Definition: ktimezone.cpp:557
Base class representing a source of time zone information.
Definition: ktimezone.h:1231
virtual bool isDstAtUtc(const KTimeZone *caller, const QDateTime &utcDateTime) const
Implements KTimeZone::isDstAtUtc().
Definition: ktimezone.cpp:562
Parsed system time zone data.
The KSystemTimeZones class represents the system time zone database, consisting of a collection of in...
Base backend class for KTimeZone classes.
Definition: ktimezone.h:1121
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jul 9 2020 22:57:49 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.