• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

libkdepim

addresseediffalgo.cpp

Go to the documentation of this file.
00001 /*
00002   This file is part of libkdepim.
00003 
00004   Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Library General Public
00008   License as published by the Free Software Foundation; either
00009   version 2 of the License, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Library General Public License for more details.
00015 
00016   You should have received a copy of the GNU Library General Public License
00017   along with this library; see the file COPYING.LIB.  If not, write to
00018   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019   Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "addresseediffalgo.h"
00023 #include <QList>
00024 
00025 using namespace KPIM;
00026 
00027 static bool compareString( const QString &left, const QString &right )
00028 {
00029   if ( left.isEmpty() && right.isEmpty() ) {
00030     return true;
00031   } else {
00032     return left == right;
00033   }
00034 }
00035 
00036 AddresseeDiffAlgo::AddresseeDiffAlgo( const KABC::Addressee &leftAddressee,
00037                                       const KABC::Addressee &rightAddressee )
00038   : mLeftAddressee( leftAddressee ), mRightAddressee( rightAddressee )
00039 {
00040 }
00041 
00042 void AddresseeDiffAlgo::run()
00043 {
00044   begin();
00045 
00046   if ( !compareString( mLeftAddressee.uid(), mRightAddressee.uid() ) ) {
00047     conflictField( KABC::Addressee::uidLabel(), mLeftAddressee.uid(), mRightAddressee.uid() );
00048   }
00049 
00050   if ( !compareString( mLeftAddressee.name(), mRightAddressee.name() ) ) {
00051     conflictField( KABC::Addressee::nameLabel(), mLeftAddressee.name(), mRightAddressee.name() );
00052   }
00053 
00054   if ( !compareString( mLeftAddressee.formattedName(), mRightAddressee.formattedName() ) ) {
00055     conflictField( KABC::Addressee::formattedNameLabel(),
00056                    mLeftAddressee.formattedName(), mRightAddressee.formattedName() );
00057   }
00058 
00059   if ( !compareString( mLeftAddressee.familyName(), mRightAddressee.familyName() ) ) {
00060     conflictField( KABC::Addressee::familyNameLabel(),
00061                    mLeftAddressee.familyName(), mRightAddressee.familyName() );
00062   }
00063 
00064   if ( !compareString( mLeftAddressee.givenName(), mRightAddressee.givenName() ) ) {
00065     conflictField( KABC::Addressee::givenNameLabel(),
00066                    mLeftAddressee.givenName(), mRightAddressee.givenName() );
00067   }
00068 
00069   if ( !compareString( mLeftAddressee.additionalName(), mRightAddressee.additionalName() ) ) {
00070     conflictField( KABC::Addressee::additionalNameLabel(),
00071                    mLeftAddressee.additionalName(), mRightAddressee.additionalName() );
00072   }
00073 
00074   if ( !compareString( mLeftAddressee.prefix(), mRightAddressee.prefix() ) ) {
00075     conflictField( KABC::Addressee::prefixLabel(),
00076                    mLeftAddressee.prefix(), mRightAddressee.prefix() );
00077   }
00078 
00079   if ( !compareString( mLeftAddressee.suffix(), mRightAddressee.suffix() ) ) {
00080     conflictField( KABC::Addressee::suffixLabel(),
00081                    mLeftAddressee.suffix(), mRightAddressee.suffix() );
00082   }
00083 
00084   if ( !compareString( mLeftAddressee.nickName(), mRightAddressee.nickName() ) ) {
00085     conflictField( KABC::Addressee::nickNameLabel(),
00086                    mLeftAddressee.nickName(), mRightAddressee.nickName() );
00087   }
00088 
00089   if ( mLeftAddressee.birthday() != mRightAddressee.birthday() ) {
00090     conflictField( KABC::Addressee::birthdayLabel(),
00091                    mLeftAddressee.birthday().toString(), mRightAddressee.birthday().toString() );
00092   }
00093 
00094   if ( !compareString( mLeftAddressee.mailer(), mRightAddressee.mailer() ) ) {
00095     conflictField( KABC::Addressee::mailerLabel(),
00096                    mLeftAddressee.mailer(), mRightAddressee.mailer() );
00097   }
00098 
00099   if ( mLeftAddressee.timeZone() != mRightAddressee.timeZone() ) {
00100     conflictField( KABC::Addressee::timeZoneLabel(),
00101                    mLeftAddressee.timeZone().toString(), mRightAddressee.timeZone().toString() );
00102   }
00103 
00104   if ( mLeftAddressee.geo() != mRightAddressee.geo() ) {
00105     conflictField( KABC::Addressee::geoLabel(),
00106                    mLeftAddressee.geo().toString(), mRightAddressee.geo().toString() );
00107   }
00108 
00109   if ( !compareString( mLeftAddressee.title(), mRightAddressee.title() ) ) {
00110     conflictField( KABC::Addressee::titleLabel(), mLeftAddressee.title(), mRightAddressee.title() );
00111   }
00112 
00113   if ( !compareString( mLeftAddressee.role(), mRightAddressee.role() ) ) {
00114     conflictField( KABC::Addressee::roleLabel(), mLeftAddressee.role(), mRightAddressee.role() );
00115   }
00116 
00117   if ( !compareString( mLeftAddressee.organization(), mRightAddressee.organization() ) ) {
00118     conflictField( KABC::Addressee::organizationLabel(),
00119                    mLeftAddressee.organization(), mRightAddressee.organization() );
00120   }
00121 
00122   if ( !compareString( mLeftAddressee.note(), mRightAddressee.note() ) ) {
00123     conflictField( KABC::Addressee::noteLabel(), mLeftAddressee.note(), mRightAddressee.note() );
00124   }
00125 
00126   if ( !compareString( mLeftAddressee.productId(), mRightAddressee.productId() ) ) {
00127     conflictField( KABC::Addressee::productIdLabel(),
00128                    mLeftAddressee.productId(), mRightAddressee.productId() );
00129   }
00130 
00131   if ( !compareString( mLeftAddressee.sortString(), mRightAddressee.sortString() ) ) {
00132     conflictField( KABC::Addressee::sortStringLabel(),
00133                    mLeftAddressee.sortString(), mRightAddressee.sortString() );
00134   }
00135 
00136   if ( mLeftAddressee.secrecy() != mRightAddressee.secrecy() ) {
00137     conflictField( KABC::Addressee::secrecyLabel(),
00138                    mLeftAddressee.secrecy().toString(), mRightAddressee.secrecy().toString() );
00139   }
00140 
00141   if ( mLeftAddressee.url() != mRightAddressee.url() ) {
00142     conflictField( KABC::Addressee::urlLabel(),
00143                    mLeftAddressee.url().prettyUrl(), mRightAddressee.url().prettyUrl() );
00144   }
00145 
00146   if ( mLeftAddressee.logo() != mRightAddressee.logo() ) {
00147   }
00148 
00149   if ( mLeftAddressee.photo() != mRightAddressee.photo() ) {
00150   }
00151 
00152   diffList( "emails", mLeftAddressee.emails(), mRightAddressee.emails() );
00153 
00154   diffList( "Phone Numbers", mLeftAddressee.phoneNumbers(), mRightAddressee.phoneNumbers() );
00155   diffList( "Addresses", mLeftAddressee.addresses(), mRightAddressee.addresses() );
00156 
00157   end();
00158 }
00159 
00160 QString AddresseeDiffAlgo::toString( const KABC::PhoneNumber &number )
00161 {
00162   return number.number();
00163 }
00164 
00165 QString AddresseeDiffAlgo::toString( const KABC::Address &addr )
00166 {
00167   return addr.formattedAddress();
00168 }
00169 
00170 template <class L>
00171 void AddresseeDiffAlgo::diffList( const QString &id,
00172                                   const QList<L> &left, const QList<L> &right )
00173 {
00174   for ( int i = 0; i < left.count(); ++i ) {
00175     if ( !right.contains( left[ i ] ) ) {
00176       additionalLeftField( id, toString( left[ i ] ) );
00177     }
00178   }
00179 
00180   for ( int i = 0; i < right.count(); ++i ) {
00181     if ( !left.contains( right[ i ] ) ) {
00182       additionalRightField( id, toString( right[ i ] ) );
00183     }
00184   }
00185 }

libkdepim

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

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.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