• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

KCalCore Library

  • sources
  • kde-4.12
  • kdepimlibs
  • kcalcore
duration.h
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
5  Copyright (c) 2007 David Jarvie <djarvie@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
31 #ifndef KCALCORE_DURATION_H
32 #define KCALCORE_DURATION_H
33 
34 #include "kcalcore_export.h"
35 
36 #include <QDataStream>
37 #include <QMetaType>
38 
39 class KDateTime;
40 
41 namespace KCalCore {
42 
55 class KCALCORE_EXPORT Duration
56 {
57 public:
61  enum Type {
62  Seconds,
63  Days
64  };
65 
69  Duration();
70 
82  Duration(const KDateTime &start, const KDateTime &end);
83 
95  Duration(const KDateTime &start, const KDateTime &end, Type type);
96 
103  // Keep the following implicit since instances are often used in integer evaluations.
104  Duration(int duration, Type type = Seconds); //krazy:exclude=explicit
105 
111  Duration(const Duration &duration);
112 
116  ~Duration();
117 
123  Duration &operator=(const Duration &duration);
124 
128  operator bool() const;
129 
133  bool operator!() const {
134  return !operator bool();
135  }
136 
141  bool operator<(const Duration &other) const;
142 
147  bool operator<=(const Duration &other) const
148  {
149  return !other.operator<(*this);
150  }
151 
156  bool operator>(const Duration &other) const
157  {
158  return other.operator<(*this);
159  }
160 
165  bool operator>=(const Duration &other) const
166  {
167  return !operator<(other);
168  }
169 
177  bool operator==(const Duration &other) const;
178 
186  bool operator!=(const Duration &other) const
187  {
188  return !operator==(other);
189  }
190 
197  Duration &operator+=(const Duration &other);
198 
207  Duration operator+(const Duration &other) const
208  {
209  return Duration(*this) += other;
210  }
211 
215  Duration operator-() const;
216 
224  Duration &operator-=(const Duration &other);
225 
234  Duration operator-(const Duration &other) const
235  {
236  return Duration(*this) += other;
237  }
238 
243  Duration &operator*=(int value);
244 
251  Duration operator*(int value) const
252  {
253  return Duration(*this) *= value;
254  }
255 
260  Duration &operator/=(int value);
261 
268  Duration operator/(int value) const
269  {
270  return Duration(*this) /= value;
271  }
272 
280  KDateTime end(const KDateTime &start) const;
281 
285  Type type() const;
286 
291  bool isDaily() const;
292 
296  int asSeconds() const;
297 
303  int asDays() const;
304 
310  int value() const;
311 
312 private:
313  //@cond PRIVATE
314  class Private;
315  Private *const d;
316  //@endcond
317 
318  friend KCALCORE_EXPORT QDataStream &operator<<(QDataStream &s, const KCalCore::Duration &);
319  friend KCALCORE_EXPORT QDataStream &operator>>(QDataStream &s, KCalCore::Duration &);
320 };
321 
327 KCALCORE_EXPORT QDataStream &operator<<(QDataStream &out, const KCalCore::Duration &);
328 
334 KCALCORE_EXPORT QDataStream &operator>>(QDataStream &in, KCalCore::Duration &);
335 
336 }
337 
338 Q_DECLARE_METATYPE(KCalCore::Duration)
339 
340 #endif
KCalCore::Duration
Represents a span of time measured in seconds or days.
Definition: duration.h:55
KCalCore::Duration::operator>
bool operator>(const Duration &other) const
Returns true if this duration is greater than the other.
Definition: duration.h:156
KCalCore::Duration::operator<=
bool operator<=(const Duration &other) const
Returns true if this duration is smaller than or equal to the other.
Definition: duration.h:147
KCalCore::Duration::operator!=
bool operator!=(const Duration &other) const
Returns true if this duration is not equal to the other.
Definition: duration.h:186
KCalCore::Duration::operator/
Duration operator/(int value) const
Divides a duration by a value.
Definition: duration.h:268
KCalCore::Duration::Seconds
duration is a number of seconds
Definition: duration.h:62
KCalCore::Duration::Type
Type
The unit of time used to define the duration.
Definition: duration.h:61
KCalCore::Duration::operator-
Duration operator-(const Duration &other) const
Returns the difference between another duration and this.
Definition: duration.h:234
KCalCore::operator>>
KCALCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalCore::Alarm::Ptr &)
Alarm deserializer.
Definition: alarm.cpp:863
KCalCore::Duration::operator+
Duration operator+(const Duration &other) const
Adds two durations.
Definition: duration.h:207
KCalCore::Duration::operator>=
bool operator>=(const Duration &other) const
Returns true if this duration is greater than or equal to the other.
Definition: duration.h:165
KCalCore::Duration::operator*
Duration operator*(int value) const
Multiplies a duration by a value.
Definition: duration.h:251
KCalCore::operator<<
KCALCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalCore::Alarm::Ptr &)
Alarm serializer.
Definition: alarm.cpp:853
KCalCore::Duration::operator!
bool operator!() const
Returns true if this duration is zero.
Definition: duration.h:133
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:59:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCalCore Library

Skip menu "KCalCore Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal