• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

kabc

timezone.cpp
00001 /*
00002     This file is part of libkabc.
00003     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "timezone.h"
00022 
00023 #include <QtCore/QDataStream>
00024 #include <QtCore/QSharedData>
00025 
00026 using namespace KABC;
00027 
00028 class TimeZone::Private : public QSharedData
00029 {
00030   public:
00031     Private( int offset = 0, bool valid = false )
00032       : mOffset( offset ), mValid( valid )
00033     {
00034     }
00035 
00036     Private( const Private &other )
00037       : QSharedData( other )
00038     {
00039       mOffset = other.mOffset;
00040       mValid = other.mValid;
00041     }
00042 
00043     int mOffset;
00044     bool mValid;
00045 };
00046 
00047 TimeZone::TimeZone()
00048   : d( new Private )
00049 {
00050 }
00051 
00052 TimeZone::TimeZone( int offset )
00053   : d( new Private( offset, true ) )
00054 {
00055 }
00056 
00057 TimeZone::TimeZone( const TimeZone &other )
00058   : d( other.d )
00059 {
00060 }
00061 
00062 TimeZone::~TimeZone()
00063 {
00064 }
00065 
00066 void TimeZone::setOffset( int offset )
00067 {
00068   d->mOffset = offset;
00069   d->mValid = true;
00070 }
00071 
00072 int TimeZone::offset() const
00073 {
00074   return d->mOffset;
00075 }
00076 
00077 bool TimeZone::isValid() const
00078 {
00079   return d->mValid;
00080 }
00081 
00082 bool TimeZone::operator==( const TimeZone &t ) const
00083 {
00084   if ( !t.isValid() && !isValid() ) {
00085     return true;
00086   }
00087 
00088   if ( !t.isValid() || !isValid() ) {
00089     return false;
00090   }
00091 
00092   if ( t.d->mOffset == d->mOffset ) {
00093     return true;
00094   }
00095 
00096   return false;
00097 }
00098 
00099 bool TimeZone::operator!=( const TimeZone &t ) const
00100 {
00101   return !( *this == t );
00102 }
00103 
00104 TimeZone &TimeZone::operator=( const TimeZone &other )
00105 {
00106   if ( this != &other ) {
00107     d = other.d;
00108   }
00109 
00110   return *this;
00111 }
00112 
00113 QString TimeZone::toString() const
00114 {
00115   QString str;
00116 
00117   str += QString::fromLatin1( "TimeZone {\n" );
00118   str += QString::fromLatin1( "  Offset: %1\n" ).arg( d->mOffset );
00119   str += QString::fromLatin1( "}\n" );
00120 
00121   return str;
00122 }
00123 
00124 QDataStream &KABC::operator<<( QDataStream &s, const TimeZone &zone )
00125 {
00126   return s << zone.d->mOffset << zone.d->mValid;
00127 }
00128 
00129 QDataStream &KABC::operator>>( QDataStream &s, TimeZone &zone )
00130 {
00131   s >> zone.d->mOffset >> zone.d->mValid;
00132 
00133   return s;
00134 }

kabc

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal