22 #include "addresseediffalgo.h"
26 static bool compareString(
const TQString &left,
const TQString &right )
28 if ( left.isEmpty() && right.isEmpty() )
34 AddresseeDiffAlgo::AddresseeDiffAlgo(
const TDEABC::Addressee &leftAddressee,
35 const TDEABC::Addressee &rightAddressee )
36 : mLeftAddressee( leftAddressee ), mRightAddressee( rightAddressee )
40 void AddresseeDiffAlgo::run()
44 if ( !compareString( mLeftAddressee.uid(), mRightAddressee.uid() ) )
45 conflictField( TDEABC::Addressee::uidLabel(), mLeftAddressee.uid(), mRightAddressee.uid() );
47 if ( !compareString( mLeftAddressee.name(), mRightAddressee.name() ) )
48 conflictField( TDEABC::Addressee::nameLabel(), mLeftAddressee.name(), mRightAddressee.name() );
50 if ( !compareString( mLeftAddressee.formattedName(), mRightAddressee.formattedName() ) )
51 conflictField( TDEABC::Addressee::formattedNameLabel(), mLeftAddressee.formattedName(), mRightAddressee.formattedName() );
53 if ( !compareString( mLeftAddressee.familyName(), mRightAddressee.familyName() ) )
54 conflictField( TDEABC::Addressee::familyNameLabel(), mLeftAddressee.familyName(), mRightAddressee.familyName() );
56 if ( !compareString( mLeftAddressee.givenName(), mRightAddressee.givenName() ) )
57 conflictField( TDEABC::Addressee::givenNameLabel(), mLeftAddressee.givenName(), mRightAddressee.givenName() );
59 if ( !compareString( mLeftAddressee.additionalName(), mRightAddressee.additionalName() ) )
60 conflictField( TDEABC::Addressee::additionalNameLabel(), mLeftAddressee.additionalName(), mRightAddressee.additionalName() );
62 if ( !compareString( mLeftAddressee.prefix(), mRightAddressee.prefix() ) )
63 conflictField( TDEABC::Addressee::prefixLabel(), mLeftAddressee.prefix(), mRightAddressee.prefix() );
65 if ( !compareString( mLeftAddressee.suffix(), mRightAddressee.suffix() ) )
66 conflictField( TDEABC::Addressee::suffixLabel(), mLeftAddressee.suffix(), mRightAddressee.suffix() );
68 if ( !compareString( mLeftAddressee.nickName(), mRightAddressee.nickName() ) )
69 conflictField( TDEABC::Addressee::nickNameLabel(), mLeftAddressee.nickName(), mRightAddressee.nickName() );
71 if ( mLeftAddressee.birthday() != mRightAddressee.birthday() )
72 conflictField( TDEABC::Addressee::birthdayLabel(), mLeftAddressee.birthday().toString(),
73 mRightAddressee.birthday().toString() );
75 if ( !compareString( mLeftAddressee.mailer(), mRightAddressee.mailer() ) )
76 conflictField( TDEABC::Addressee::mailerLabel(), mLeftAddressee.mailer(), mRightAddressee.mailer() );
78 if ( mLeftAddressee.timeZone() != mRightAddressee.timeZone() )
79 conflictField( TDEABC::Addressee::timeZoneLabel(), mLeftAddressee.timeZone().asString(), mRightAddressee.timeZone().asString() );
81 if ( mLeftAddressee.geo() != mRightAddressee.geo() )
82 conflictField( TDEABC::Addressee::geoLabel(), mLeftAddressee.geo().asString(), mRightAddressee.geo().asString() );
84 if ( !compareString( mLeftAddressee.title(), mRightAddressee.title() ) )
85 conflictField( TDEABC::Addressee::titleLabel(), mLeftAddressee.title(), mRightAddressee.title() );
87 if ( !compareString( mLeftAddressee.role(), mRightAddressee.role() ) )
88 conflictField( TDEABC::Addressee::roleLabel(), mLeftAddressee.role(), mRightAddressee.role() );
90 if ( !compareString( mLeftAddressee.organization(), mRightAddressee.organization() ) )
91 conflictField( TDEABC::Addressee::organizationLabel(), mLeftAddressee.organization(), mRightAddressee.organization() );
93 if ( !compareString( mLeftAddressee.note(), mRightAddressee.note() ) )
94 conflictField( TDEABC::Addressee::noteLabel(), mLeftAddressee.note(), mRightAddressee.note() );
96 if ( !compareString( mLeftAddressee.productId(), mRightAddressee.productId() ) )
97 conflictField( TDEABC::Addressee::productIdLabel(), mLeftAddressee.productId(), mRightAddressee.productId() );
99 if ( !compareString( mLeftAddressee.sortString(), mRightAddressee.sortString() ) )
100 conflictField( TDEABC::Addressee::sortStringLabel(), mLeftAddressee.sortString(), mRightAddressee.sortString() );
102 if ( mLeftAddressee.secrecy() != mRightAddressee.secrecy() ) {
103 conflictField( TDEABC::Addressee::secrecyLabel(), mLeftAddressee.secrecy().asString(), mRightAddressee.secrecy().asString() );
105 if ( mLeftAddressee.url()!= mRightAddressee.url() )
106 conflictField( TDEABC::Addressee::urlLabel(), mLeftAddressee.url().prettyURL(),
107 mRightAddressee.url().prettyURL() );
109 if ( mLeftAddressee.logo() != mRightAddressee.logo() ) {
112 if ( mLeftAddressee.photo() != mRightAddressee.photo() ) {
115 diffList(
"emails", mLeftAddressee.emails(), mRightAddressee.emails() );
117 diffList(
"Phone Numbers", mLeftAddressee.phoneNumbers(), mRightAddressee.phoneNumbers() );
118 diffList(
"Addresses", mLeftAddressee.addresses(), mRightAddressee.addresses() );
123 TQString AddresseeDiffAlgo::toString(
const TDEABC::PhoneNumber &number )
125 return number.number();
128 TQString AddresseeDiffAlgo::toString(
const TDEABC::Address &addr )
130 return addr.formattedAddress();
134 void AddresseeDiffAlgo::diffList(
const TQString &
id,
135 const TQValueList<L> &left,
const TQValueList<L> &right )
137 for ( uint i = 0; i < left.count(); ++i ) {
138 if ( right.find( left[ i ] ) == right.end() )
139 additionalLeftField(
id, toString( left[ i ] ) );
142 for ( uint i = 0; i < right.count(); ++i ) {
143 if ( left.find( right[ i ] ) == left.end() )
144 additionalRightField(
id, toString( right[ i ] ) );
TDEPIM classes for drag and drop of mails.