libkdepim Library API Documentation

addresseediffalgo.cpp

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., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #include "addresseediffalgo.h" 00023 00024 using namespace KPIM; 00025 00026 static bool compareString( const QString &left, const QString &right ) 00027 { 00028 if ( left.isEmpty() && right.isEmpty() ) 00029 return true; 00030 else 00031 return left == right; 00032 } 00033 00034 AddresseeDiffAlgo::AddresseeDiffAlgo( const KABC::Addressee &leftAddressee, 00035 const KABC::Addressee &rightAddressee ) 00036 : mLeftAddressee( leftAddressee ), mRightAddressee( rightAddressee ) 00037 { 00038 } 00039 00040 void AddresseeDiffAlgo::run() 00041 { 00042 begin(); 00043 00044 if ( !compareString( mLeftAddressee.uid(), mRightAddressee.uid() ) ) 00045 conflictField( KABC::Addressee::uidLabel(), mLeftAddressee.uid(), mRightAddressee.uid() ); 00046 00047 if ( !compareString( mLeftAddressee.name(), mRightAddressee.name() ) ) 00048 conflictField( KABC::Addressee::nameLabel(), mLeftAddressee.name(), mRightAddressee.name() ); 00049 00050 if ( !compareString( mLeftAddressee.formattedName(), mRightAddressee.formattedName() ) ) 00051 conflictField( KABC::Addressee::formattedNameLabel(), mLeftAddressee.formattedName(), mRightAddressee.formattedName() ); 00052 00053 if ( !compareString( mLeftAddressee.familyName(), mRightAddressee.familyName() ) ) 00054 conflictField( KABC::Addressee::familyNameLabel(), mLeftAddressee.familyName(), mRightAddressee.familyName() ); 00055 00056 if ( !compareString( mLeftAddressee.givenName(), mRightAddressee.givenName() ) ) 00057 conflictField( KABC::Addressee::givenNameLabel(), mLeftAddressee.givenName(), mRightAddressee.givenName() ); 00058 00059 if ( !compareString( mLeftAddressee.additionalName(), mRightAddressee.additionalName() ) ) 00060 conflictField( KABC::Addressee::additionalNameLabel(), mLeftAddressee.additionalName(), mRightAddressee.additionalName() ); 00061 00062 if ( !compareString( mLeftAddressee.prefix(), mRightAddressee.prefix() ) ) 00063 conflictField( KABC::Addressee::prefixLabel(), mLeftAddressee.prefix(), mRightAddressee.prefix() ); 00064 00065 if ( !compareString( mLeftAddressee.suffix(), mRightAddressee.suffix() ) ) 00066 conflictField( KABC::Addressee::suffixLabel(), mLeftAddressee.suffix(), mRightAddressee.suffix() ); 00067 00068 if ( !compareString( mLeftAddressee.nickName(), mRightAddressee.nickName() ) ) 00069 conflictField( KABC::Addressee::nickNameLabel(), mLeftAddressee.nickName(), mRightAddressee.nickName() ); 00070 00071 if ( mLeftAddressee.birthday() != mRightAddressee.birthday() ) 00072 conflictField( KABC::Addressee::birthdayLabel(), mLeftAddressee.birthday().toString(), 00073 mRightAddressee.birthday().toString() ); 00074 00075 if ( !compareString( mLeftAddressee.mailer(), mRightAddressee.mailer() ) ) 00076 conflictField( KABC::Addressee::mailerLabel(), mLeftAddressee.mailer(), mRightAddressee.mailer() ); 00077 00078 if ( mLeftAddressee.timeZone() != mRightAddressee.timeZone() ) 00079 conflictField( KABC::Addressee::timeZoneLabel(), mLeftAddressee.timeZone().asString(), mRightAddressee.timeZone().asString() ); 00080 00081 if ( mLeftAddressee.geo() != mRightAddressee.geo() ) 00082 conflictField( KABC::Addressee::geoLabel(), mLeftAddressee.geo().asString(), mRightAddressee.geo().asString() ); 00083 00084 if ( !compareString( mLeftAddressee.title(), mRightAddressee.title() ) ) 00085 conflictField( KABC::Addressee::titleLabel(), mLeftAddressee.title(), mRightAddressee.title() ); 00086 00087 if ( !compareString( mLeftAddressee.role(), mRightAddressee.role() ) ) 00088 conflictField( KABC::Addressee::roleLabel(), mLeftAddressee.role(), mRightAddressee.role() ); 00089 00090 if ( !compareString( mLeftAddressee.organization(), mRightAddressee.organization() ) ) 00091 conflictField( KABC::Addressee::organizationLabel(), mLeftAddressee.organization(), mRightAddressee.organization() ); 00092 00093 if ( !compareString( mLeftAddressee.note(), mRightAddressee.note() ) ) 00094 conflictField( KABC::Addressee::noteLabel(), mLeftAddressee.note(), mRightAddressee.note() ); 00095 00096 if ( !compareString( mLeftAddressee.productId(), mRightAddressee.productId() ) ) 00097 conflictField( KABC::Addressee::productIdLabel(), mLeftAddressee.productId(), mRightAddressee.productId() ); 00098 00099 if ( !compareString( mLeftAddressee.sortString(), mRightAddressee.sortString() ) ) 00100 conflictField( KABC::Addressee::sortStringLabel(), mLeftAddressee.sortString(), mRightAddressee.sortString() ); 00101 00102 if ( mLeftAddressee.secrecy() != mRightAddressee.secrecy() ) { 00103 conflictField( KABC::Addressee::secrecyLabel(), mLeftAddressee.secrecy().asString(), mRightAddressee.secrecy().asString() ); 00104 } 00105 00106 if ( mLeftAddressee.logo() != mRightAddressee.logo() ) { 00107 } 00108 00109 if ( mLeftAddressee.photo() != mRightAddressee.photo() ) { 00110 } 00111 00112 diffList( "Phone Numbers", mLeftAddressee.phoneNumbers(), mRightAddressee.phoneNumbers() ); 00113 diffList( "Addresses", mLeftAddressee.addresses(), mRightAddressee.addresses() ); 00114 00115 end(); 00116 } 00117 00118 QString AddresseeDiffAlgo::toString( const KABC::PhoneNumber &number ) 00119 { 00120 return number.number(); 00121 } 00122 00123 QString AddresseeDiffAlgo::toString( const KABC::Address &addr ) 00124 { 00125 return addr.formattedAddress(); 00126 } 00127 00128 template <class L> 00129 void AddresseeDiffAlgo::diffList( const QString &id, 00130 const QValueList<L> &left, const QValueList<L> &right ) 00131 { 00132 for ( uint i = 0; i < left.count(); ++i ) { 00133 if ( right.find( left[ i ] ) == right.end() ) 00134 additionalLeftField( id, toString( left[ i ] ) ); 00135 } 00136 00137 for ( uint i = 0; i < right.count(); ++i ) { 00138 if ( left.find( right[ i ] ) == left.end() ) 00139 additionalRightField( id, toString( right[ i ] ) ); 00140 } 00141 }
KDE Logo
This file is part of the documentation for libkdepim Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:29 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003