Fix typo found by Yuri Chornoivan
[kdepim.git] / libkdepim / addresseediffalgo.cpp
bloba136be8c00e631899e73b6115a16546e2fac26d5
1 /*
2 This file is part of libkdepim.
4 Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #include "addresseediffalgo.h"
23 #include <QList>
25 using namespace KPIM;
27 static bool compareString( const QString &left, const QString &right )
29 if ( left.isEmpty() && right.isEmpty() ) {
30 return true;
31 } else {
32 return left == right;
36 AddresseeDiffAlgo::AddresseeDiffAlgo( const KABC::Addressee &leftAddressee,
37 const KABC::Addressee &rightAddressee )
38 : mLeftAddressee( leftAddressee ), mRightAddressee( rightAddressee )
42 void AddresseeDiffAlgo::run()
44 begin();
46 if ( !compareString( mLeftAddressee.uid(), mRightAddressee.uid() ) ) {
47 conflictField( KABC::Addressee::uidLabel(), mLeftAddressee.uid(), mRightAddressee.uid() );
50 if ( !compareString( mLeftAddressee.name(), mRightAddressee.name() ) ) {
51 conflictField( KABC::Addressee::nameLabel(), mLeftAddressee.name(), mRightAddressee.name() );
54 if ( !compareString( mLeftAddressee.formattedName(), mRightAddressee.formattedName() ) ) {
55 conflictField( KABC::Addressee::formattedNameLabel(),
56 mLeftAddressee.formattedName(), mRightAddressee.formattedName() );
59 if ( !compareString( mLeftAddressee.familyName(), mRightAddressee.familyName() ) ) {
60 conflictField( KABC::Addressee::familyNameLabel(),
61 mLeftAddressee.familyName(), mRightAddressee.familyName() );
64 if ( !compareString( mLeftAddressee.givenName(), mRightAddressee.givenName() ) ) {
65 conflictField( KABC::Addressee::givenNameLabel(),
66 mLeftAddressee.givenName(), mRightAddressee.givenName() );
69 if ( !compareString( mLeftAddressee.additionalName(), mRightAddressee.additionalName() ) ) {
70 conflictField( KABC::Addressee::additionalNameLabel(),
71 mLeftAddressee.additionalName(), mRightAddressee.additionalName() );
74 if ( !compareString( mLeftAddressee.prefix(), mRightAddressee.prefix() ) ) {
75 conflictField( KABC::Addressee::prefixLabel(),
76 mLeftAddressee.prefix(), mRightAddressee.prefix() );
79 if ( !compareString( mLeftAddressee.suffix(), mRightAddressee.suffix() ) ) {
80 conflictField( KABC::Addressee::suffixLabel(),
81 mLeftAddressee.suffix(), mRightAddressee.suffix() );
84 if ( !compareString( mLeftAddressee.nickName(), mRightAddressee.nickName() ) ) {
85 conflictField( KABC::Addressee::nickNameLabel(),
86 mLeftAddressee.nickName(), mRightAddressee.nickName() );
89 if ( mLeftAddressee.birthday() != mRightAddressee.birthday() ) {
90 conflictField( KABC::Addressee::birthdayLabel(),
91 mLeftAddressee.birthday().toString(), mRightAddressee.birthday().toString() );
94 if ( !compareString( mLeftAddressee.mailer(), mRightAddressee.mailer() ) ) {
95 conflictField( KABC::Addressee::mailerLabel(),
96 mLeftAddressee.mailer(), mRightAddressee.mailer() );
99 if ( mLeftAddressee.timeZone() != mRightAddressee.timeZone() ) {
100 conflictField( KABC::Addressee::timeZoneLabel(),
101 mLeftAddressee.timeZone().toString(), mRightAddressee.timeZone().toString() );
104 if ( mLeftAddressee.geo() != mRightAddressee.geo() ) {
105 conflictField( KABC::Addressee::geoLabel(),
106 mLeftAddressee.geo().toString(), mRightAddressee.geo().toString() );
109 if ( !compareString( mLeftAddressee.title(), mRightAddressee.title() ) ) {
110 conflictField( KABC::Addressee::titleLabel(), mLeftAddressee.title(), mRightAddressee.title() );
113 if ( !compareString( mLeftAddressee.role(), mRightAddressee.role() ) ) {
114 conflictField( KABC::Addressee::roleLabel(), mLeftAddressee.role(), mRightAddressee.role() );
117 if ( !compareString( mLeftAddressee.organization(), mRightAddressee.organization() ) ) {
118 conflictField( KABC::Addressee::organizationLabel(),
119 mLeftAddressee.organization(), mRightAddressee.organization() );
122 if ( !compareString( mLeftAddressee.note(), mRightAddressee.note() ) ) {
123 conflictField( KABC::Addressee::noteLabel(), mLeftAddressee.note(), mRightAddressee.note() );
126 if ( !compareString( mLeftAddressee.productId(), mRightAddressee.productId() ) ) {
127 conflictField( KABC::Addressee::productIdLabel(),
128 mLeftAddressee.productId(), mRightAddressee.productId() );
131 if ( !compareString( mLeftAddressee.sortString(), mRightAddressee.sortString() ) ) {
132 conflictField( KABC::Addressee::sortStringLabel(),
133 mLeftAddressee.sortString(), mRightAddressee.sortString() );
136 if ( mLeftAddressee.secrecy() != mRightAddressee.secrecy() ) {
137 conflictField( KABC::Addressee::secrecyLabel(),
138 mLeftAddressee.secrecy().toString(), mRightAddressee.secrecy().toString() );
141 if ( mLeftAddressee.url() != mRightAddressee.url() ) {
142 conflictField( KABC::Addressee::urlLabel(),
143 mLeftAddressee.url().prettyUrl(), mRightAddressee.url().prettyUrl() );
146 if ( mLeftAddressee.logo() != mRightAddressee.logo() ) {
149 if ( mLeftAddressee.photo() != mRightAddressee.photo() ) {
152 diffList( "emails", mLeftAddressee.emails(), mRightAddressee.emails() );
154 diffList( "Phone Numbers", mLeftAddressee.phoneNumbers(), mRightAddressee.phoneNumbers() );
155 diffList( "Addresses", mLeftAddressee.addresses(), mRightAddressee.addresses() );
157 end();
160 QString AddresseeDiffAlgo::toString( const KABC::PhoneNumber &number )
162 return number.number();
165 QString AddresseeDiffAlgo::toString( const KABC::Address &addr )
167 return addr.formattedAddress();
170 template <class L>
171 void AddresseeDiffAlgo::diffList( const QString &id,
172 const QList<L> &left, const QList<L> &right )
174 for ( int i = 0; i < left.count(); ++i ) {
175 if ( !right.contains( left[ i ] ) ) {
176 additionalLeftField( id, toString( left[ i ] ) );
180 for ( int i = 0; i < right.count(); ++i ) {
181 if ( !left.contains( right[ i ] ) ) {
182 additionalRightField( id, toString( right[ i ] ) );