Diffstat (limited to 'kaddressbook/features/mergewidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/features/mergewidget.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/kaddressbook/features/mergewidget.cpp b/kaddressbook/features/mergewidget.cpp index 2476e42..1becc2f 100644 --- a/kaddressbook/features/mergewidget.cpp +++ b/kaddressbook/features/mergewidget.cpp | |||
@@ -1,374 +1,376 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | //Added by qt3to4: | ||
27 | #include <Q3GridLayout> | ||
26 | 28 | ||
27 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
28 | #include <kaccelmanager.h> | 30 | #include <kaccelmanager.h> |
29 | #endif //KAB_EMBEDDED | 31 | #endif //KAB_EMBEDDED |
30 | 32 | ||
31 | #include <kdebug.h> | 33 | #include <kdebug.h> |
32 | #include <klistview.h> | 34 | #include <klistview.h> |
33 | #include <klocale.h> | 35 | #include <klocale.h> |
34 | #include <kglobal.h> | 36 | #include <kglobal.h> |
35 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
36 | 38 | ||
37 | #include <kabc/addressbook.h> | 39 | #include <kabc/addressbook.h> |
38 | 40 | ||
39 | #include "kabcore.h" | 41 | #include "kabcore.h" |
40 | 42 | ||
41 | #include "mergewidget.h" | 43 | #include "mergewidget.h" |
42 | 44 | ||
43 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
44 | class MergeFactory : public ExtensionFactory | 46 | class MergeFactory : public ExtensionFactory |
45 | { | 47 | { |
46 | public: | 48 | public: |
47 | ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name ) | 49 | ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name ) |
48 | { | 50 | { |
49 | return new MergeWidget( core, parent, name ); | 51 | return new MergeWidget( core, parent, name ); |
50 | } | 52 | } |
51 | 53 | ||
52 | QString identifier() const | 54 | QString identifier() const |
53 | { | 55 | { |
54 | return "merge"; | 56 | return "merge"; |
55 | } | 57 | } |
56 | }; | 58 | }; |
57 | 59 | ||
58 | extern "C" { | 60 | extern "C" { |
59 | void *init_libkaddrbk_merge() | 61 | void *init_libkaddrbk_merge() |
60 | { | 62 | { |
61 | return ( new MergeFactory ); | 63 | return ( new MergeFactory ); |
62 | } | 64 | } |
63 | } | 65 | } |
64 | #endif //KAB_EMBEDDED | 66 | #endif //KAB_EMBEDDED |
65 | 67 | ||
66 | class ContactItem : public QListViewItem | 68 | class ContactItem : public Q3ListViewItem |
67 | { | 69 | { |
68 | public: | 70 | public: |
69 | ContactItem( KListView *parent, const KABC::Addressee &addressee ) | 71 | ContactItem( KListView *parent, const KABC::Addressee &addressee ) |
70 | : QListViewItem( parent ), mAddressee( addressee ) | 72 | : Q3ListViewItem( parent ), mAddressee( addressee ) |
71 | { | 73 | { |
72 | KABC::Field::List fieldList = KABC::Field::defaultFields(); | 74 | KABC::Field::List fieldList = KABC::Field::defaultFields(); |
73 | KABC::Field::List::ConstIterator it; | 75 | KABC::Field::List::ConstIterator it; |
74 | 76 | ||
75 | int i = 0; | 77 | int i = 0; |
76 | for ( it = fieldList.begin(); it != fieldList.end(); ++it ) | 78 | for ( it = fieldList.begin(); it != fieldList.end(); ++it ) |
77 | setText( i++, (*it)->value( mAddressee ) ); | 79 | setText( i++, (*it)->value( mAddressee ) ); |
78 | } | 80 | } |
79 | 81 | ||
80 | KABC::Addressee addressee() const | 82 | KABC::Addressee addressee() const |
81 | { | 83 | { |
82 | return mAddressee; | 84 | return mAddressee; |
83 | } | 85 | } |
84 | 86 | ||
85 | private: | 87 | private: |
86 | KABC::Addressee mAddressee; | 88 | KABC::Addressee mAddressee; |
87 | }; | 89 | }; |
88 | 90 | ||
89 | MergeWidget::MergeWidget( KABCore *core, QWidget *parent, const char *name ) | 91 | MergeWidget::MergeWidget( KABCore *core, QWidget *parent, const char *name ) |
90 | : ExtensionWidget( core, parent, name ), mBlockUpdate( false ) | 92 | : ExtensionWidget( core, parent, name ), mBlockUpdate( false ) |
91 | { | 93 | { |
92 | #ifdef KAB_EMBEDDED | 94 | #ifdef KAB_EMBEDDED |
93 | if (KGlobal::getOrientation() == KGlobal::Portrait) | 95 | if (KGlobal::getOrientation() == KGlobal::Portrait) |
94 | parent->setMaximumSize( KGlobal::getDesktopWidth() , 180); | 96 | parent->setMaximumSize( KGlobal::getDesktopWidth() , 180); |
95 | #endif //KAB_EMBEDDED | 97 | #endif //KAB_EMBEDDED |
96 | 98 | ||
97 | QGridLayout *topLayout = new QGridLayout( this, 3, 2, KDialog::marginHint(), | 99 | Q3GridLayout *topLayout = new Q3GridLayout( this, 3, 2, KDialog::marginHint(), |
98 | KDialog::spacingHint() ); | 100 | KDialog::spacingHint() ); |
99 | 101 | ||
100 | mContactView = new KListView( this ); | 102 | mContactView = new KListView( this ); |
101 | KABC::Field::List fieldList = KABC::Field::defaultFields(); | 103 | KABC::Field::List fieldList = KABC::Field::defaultFields(); |
102 | KABC::Field::List::ConstIterator it; | 104 | KABC::Field::List::ConstIterator it; |
103 | 105 | ||
104 | for ( it = fieldList.begin(); it != fieldList.end(); ++it ) | 106 | for ( it = fieldList.begin(); it != fieldList.end(); ++it ) |
105 | mContactView->addColumn( (*it)->label() ); | 107 | mContactView->addColumn( (*it)->label() ); |
106 | 108 | ||
107 | mContactView->setEnabled( false ); | 109 | mContactView->setEnabled( false ); |
108 | mContactView->setAllColumnsShowFocus( true ); | 110 | mContactView->setAllColumnsShowFocus( true ); |
109 | topLayout->addMultiCellWidget( mContactView, 0, 2, 0, 0 ); | 111 | topLayout->addMultiCellWidget( mContactView, 0, 2, 0, 0 ); |
110 | 112 | ||
111 | connect( mContactView, SIGNAL( selectionChanged() ), | 113 | connect( mContactView, SIGNAL( selectionChanged() ), |
112 | SLOT( selectionContactViewChanged() ) ); | 114 | SLOT( selectionContactViewChanged() ) ); |
113 | 115 | ||
114 | mMergeAndRemoveButton = new QPushButton( i18n( "Merge and Remove" ), this ); | 116 | mMergeAndRemoveButton = new QPushButton( i18n( "Merge and Remove" ), this ); |
115 | mMergeAndRemoveButton->setEnabled( false ); | 117 | mMergeAndRemoveButton->setEnabled( false ); |
116 | topLayout->addWidget( mMergeAndRemoveButton, 0, 1 ); | 118 | topLayout->addWidget( mMergeAndRemoveButton, 0, 1 ); |
117 | connect( mMergeAndRemoveButton, SIGNAL( clicked() ), SLOT( mergeAndRemove() ) ); | 119 | connect( mMergeAndRemoveButton, SIGNAL( clicked() ), SLOT( mergeAndRemove() ) ); |
118 | 120 | ||
119 | mMergeButton = new QPushButton( i18n( "Merge" ), this ); | 121 | mMergeButton = new QPushButton( i18n( "Merge" ), this ); |
120 | mMergeButton->setEnabled( false ); | 122 | mMergeButton->setEnabled( false ); |
121 | topLayout->addWidget( mMergeButton, 1, 1 ); | 123 | topLayout->addWidget( mMergeButton, 1, 1 ); |
122 | connect( mMergeButton, SIGNAL( clicked() ), SLOT( merge() ) ); | 124 | connect( mMergeButton, SIGNAL( clicked() ), SLOT( merge() ) ); |
123 | 125 | ||
124 | #ifndef KAB_EMBEDDED | 126 | #ifndef KAB_EMBEDDED |
125 | KAcceleratorManager::manage( this ); | 127 | KAcceleratorManager::manage( this ); |
126 | #endif //KAB_EMBEDDED | 128 | #endif //KAB_EMBEDDED |
127 | } | 129 | } |
128 | 130 | ||
129 | MergeWidget::~MergeWidget() | 131 | MergeWidget::~MergeWidget() |
130 | { | 132 | { |
131 | } | 133 | } |
132 | 134 | ||
133 | void MergeWidget::selectionContactViewChanged() | 135 | void MergeWidget::selectionContactViewChanged() |
134 | { | 136 | { |
135 | #ifndef KAB_EMBEDDED | 137 | #ifndef KAB_EMBEDDED |
136 | ContactItem *contactItem = | 138 | ContactItem *contactItem = |
137 | dynamic_cast<ContactItem*>( mContactView->selectedItem() ); | 139 | dynamic_cast<ContactItem*>( mContactView->selectedItem() ); |
138 | #else //KAB_EMBEDDED | 140 | #else //KAB_EMBEDDED |
139 | ContactItem *contactItem =(ContactItem*)( mContactView->selectedItem() ); | 141 | ContactItem *contactItem =(ContactItem*)( mContactView->selectedItem() ); |
140 | #endif //KAB_EMBEDDED | 142 | #endif //KAB_EMBEDDED |
141 | 143 | ||
142 | bool state = (contactItem != 0); | 144 | bool state = (contactItem != 0); |
143 | 145 | ||
144 | mMergeAndRemoveButton->setEnabled( state ); | 146 | mMergeAndRemoveButton->setEnabled( state ); |
145 | mMergeButton->setEnabled( state ); | 147 | mMergeButton->setEnabled( state ); |
146 | } | 148 | } |
147 | 149 | ||
148 | void MergeWidget::contactsSelectionChanged() | 150 | void MergeWidget::contactsSelectionChanged() |
149 | { | 151 | { |
150 | if ( mBlockUpdate ) | 152 | if ( mBlockUpdate ) |
151 | return; | 153 | return; |
152 | 154 | ||
153 | if ( !contactsSelected() ) { | 155 | if ( !contactsSelected() ) { |
154 | mContactView->setEnabled( false ); | 156 | mContactView->setEnabled( false ); |
155 | mContactView->clear(); | 157 | mContactView->clear(); |
156 | mMergeAndRemoveButton->setEnabled( false ); | 158 | mMergeAndRemoveButton->setEnabled( false ); |
157 | mMergeButton->setEnabled( false ); | 159 | mMergeButton->setEnabled( false ); |
158 | } else { | 160 | } else { |
159 | KABC::Addressee::List list = selectedContacts(); | 161 | KABC::Addressee::List list = selectedContacts(); |
160 | if ( list.count() > 1 ) { | 162 | if ( list.count() > 1 ) { |
161 | mContactView->setEnabled( false ); | 163 | mContactView->setEnabled( false ); |
162 | mContactView->clear(); | 164 | mContactView->clear(); |
163 | mMergeAndRemoveButton->setEnabled( false ); | 165 | mMergeAndRemoveButton->setEnabled( false ); |
164 | mMergeButton->setEnabled( false ); | 166 | mMergeButton->setEnabled( false ); |
165 | return; | 167 | return; |
166 | } else { | 168 | } else { |
167 | mContactView->setEnabled( true ); | 169 | mContactView->setEnabled( true ); |
168 | mMasterAddressee = list[ 0 ]; | 170 | mMasterAddressee = list[ 0 ]; |
169 | updateView(); | 171 | updateView(); |
170 | } | 172 | } |
171 | } | 173 | } |
172 | } | 174 | } |
173 | 175 | ||
174 | void MergeWidget::updateView() | 176 | void MergeWidget::updateView() |
175 | { | 177 | { |
176 | mContactView->clear(); | 178 | mContactView->clear(); |
177 | 179 | ||
178 | KABC::AddressBook::Iterator it; | 180 | KABC::AddressBook::Iterator it; |
179 | KABC::AddressBook *ab = core()->addressBook(); | 181 | KABC::AddressBook *ab = core()->addressBook(); |
180 | if ( !ab ) | 182 | if ( !ab ) |
181 | return; | 183 | return; |
182 | 184 | ||
183 | for ( it = ab->begin(); it != ab->end(); ++it ) | 185 | for ( it = ab->begin(); it != ab->end(); ++it ) |
184 | if ( (*it).uid() != mMasterAddressee.uid() ) | 186 | if ( (*it).uid() != mMasterAddressee.uid() ) |
185 | new ContactItem( mContactView, *it ); | 187 | new ContactItem( mContactView, *it ); |
186 | } | 188 | } |
187 | 189 | ||
188 | QString MergeWidget::title() const | 190 | QString MergeWidget::title() const |
189 | { | 191 | { |
190 | return i18n( "Merge Contacts Editor" ); | 192 | return i18n( "Merge Contacts Editor" ); |
191 | } | 193 | } |
192 | 194 | ||
193 | QString MergeWidget::identifier() const | 195 | QString MergeWidget::identifier() const |
194 | { | 196 | { |
195 | return "merge"; | 197 | return "merge"; |
196 | } | 198 | } |
197 | 199 | ||
198 | void MergeWidget::mergeAndRemove() | 200 | void MergeWidget::mergeAndRemove() |
199 | { | 201 | { |
200 | #ifndef KAB_EMBEDDED | 202 | #ifndef KAB_EMBEDDED |
201 | ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() ); | 203 | ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() ); |
202 | #else //KAB_EMBEDDED | 204 | #else //KAB_EMBEDDED |
203 | ContactItem *item = (ContactItem*)( mContactView->currentItem() ); | 205 | ContactItem *item = (ContactItem*)( mContactView->currentItem() ); |
204 | #endif //KAB_EMBEDDED | 206 | #endif //KAB_EMBEDDED |
205 | if ( !item ) | 207 | if ( !item ) |
206 | return; | 208 | return; |
207 | 209 | ||
208 | QString oldUID = item->addressee().uid(); | 210 | QString oldUID = item->addressee().uid(); |
209 | 211 | ||
210 | doMerge( item->addressee() ); | 212 | doMerge( item->addressee() ); |
211 | 213 | ||
212 | KABC::Addressee::List retval; | 214 | KABC::Addressee::List retval; |
213 | retval << mMasterAddressee; | 215 | retval << mMasterAddressee; |
214 | emit modified( retval ); | 216 | emit modified( retval ); |
215 | 217 | ||
216 | mBlockUpdate = true; | 218 | mBlockUpdate = true; |
217 | core()->deleteContacts( oldUID ); | 219 | core()->deleteContacts( QStringList(oldUID) ); |
218 | core()->setContactSelected( mMasterAddressee.uid() ); | 220 | core()->setContactSelected( mMasterAddressee.uid() ); |
219 | mBlockUpdate = false; | 221 | mBlockUpdate = false; |
220 | 222 | ||
221 | updateView(); | 223 | updateView(); |
222 | } | 224 | } |
223 | 225 | ||
224 | void MergeWidget::merge() | 226 | void MergeWidget::merge() |
225 | { | 227 | { |
226 | #ifndef KAB_EMBEDDED | 228 | #ifndef KAB_EMBEDDED |
227 | ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() ); | 229 | ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() ); |
228 | #else //KAB_EMBEDDED | 230 | #else //KAB_EMBEDDED |
229 | ContactItem *item = (ContactItem*)( mContactView->currentItem() ); | 231 | ContactItem *item = (ContactItem*)( mContactView->currentItem() ); |
230 | #endif //KAB_EMBEDDED | 232 | #endif //KAB_EMBEDDED |
231 | if ( !item ) | 233 | if ( !item ) |
232 | return; | 234 | return; |
233 | 235 | ||
234 | doMerge( item->addressee() ); | 236 | doMerge( item->addressee() ); |
235 | 237 | ||
236 | KABC::Addressee::List retval; | 238 | KABC::Addressee::List retval; |
237 | retval << mMasterAddressee; | 239 | retval << mMasterAddressee; |
238 | emit modified( retval ); | 240 | emit modified( retval ); |
239 | 241 | ||
240 | mBlockUpdate = true; | 242 | mBlockUpdate = true; |
241 | core()->setContactSelected( mMasterAddressee.uid() ); | 243 | core()->setContactSelected( mMasterAddressee.uid() ); |
242 | mBlockUpdate = false; | 244 | mBlockUpdate = false; |
243 | 245 | ||
244 | updateView(); | 246 | updateView(); |
245 | } | 247 | } |
246 | 248 | ||
247 | void MergeWidget::doMerge( const KABC::Addressee &addr ) | 249 | void MergeWidget::doMerge( const KABC::Addressee &addr ) |
248 | { | 250 | { |
249 | // ADR + LABEL | 251 | // ADR + LABEL |
250 | KABC::Address::List addresses = addr.addresses(); | 252 | KABC::Address::List addresses = addr.addresses(); |
251 | KABC::Address::List masterAddresses = mMasterAddressee.addresses(); | 253 | KABC::Address::List masterAddresses = mMasterAddressee.addresses(); |
252 | KABC::Address::List::Iterator addrIt ; | 254 | KABC::Address::List::Iterator addrIt ; |
253 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { | 255 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { |
254 | if ( !masterAddresses.contains( *addrIt ) ) | 256 | if ( !masterAddresses.contains( *addrIt ) ) |
255 | mMasterAddressee.insertAddress( *addrIt ); | 257 | mMasterAddressee.insertAddress( *addrIt ); |
256 | } | 258 | } |
257 | 259 | ||
258 | if ( mMasterAddressee.birthday().isNull() && !addr.birthday().isNull() ) | 260 | if ( mMasterAddressee.birthday().isNull() && !addr.birthday().isNull() ) |
259 | mMasterAddressee.setBirthday( addr.birthday() ); | 261 | mMasterAddressee.setBirthday( addr.birthday() ); |
260 | 262 | ||
261 | 263 | ||
262 | // CATEGORIES | 264 | // CATEGORIES |
263 | QStringList::Iterator it; | 265 | QStringList::Iterator it; |
264 | QStringList categories = addr.categories(); | 266 | QStringList categories = addr.categories(); |
265 | QStringList masterCategories = mMasterAddressee.categories(); | 267 | QStringList masterCategories = mMasterAddressee.categories(); |
266 | QStringList newCategories( masterCategories ); | 268 | QStringList newCategories( masterCategories ); |
267 | for ( it = categories.begin(); it != categories.end(); ++it ) | 269 | for ( it = categories.begin(); it != categories.end(); ++it ) |
268 | if ( !masterCategories.contains( *it ) ) | 270 | if ( !masterCategories.contains( *it ) ) |
269 | newCategories.append( *it ); | 271 | newCategories.append( *it ); |
270 | mMasterAddressee.setCategories( newCategories ); | 272 | mMasterAddressee.setCategories( newCategories ); |
271 | 273 | ||
272 | // CLASS | 274 | // CLASS |
273 | if ( !mMasterAddressee.secrecy().isValid() && addr.secrecy().isValid() ) | 275 | if ( !mMasterAddressee.secrecy().isValid() && addr.secrecy().isValid() ) |
274 | mMasterAddressee.setSecrecy( addr.secrecy() ); | 276 | mMasterAddressee.setSecrecy( addr.secrecy() ); |
275 | 277 | ||
276 | 278 | ||
277 | QStringList emails = addr.emails(); | 279 | QStringList emails = addr.emails(); |
278 | QStringList masterEmails = mMasterAddressee.emails(); | 280 | QStringList masterEmails = mMasterAddressee.emails(); |
279 | for ( it = emails.begin(); it != emails.end(); ++it ) | 281 | for ( it = emails.begin(); it != emails.end(); ++it ) |
280 | if ( !masterEmails.contains( *it ) ) | 282 | if ( !masterEmails.contains( *it ) ) |
281 | mMasterAddressee.insertEmail( *it, false ); | 283 | mMasterAddressee.insertEmail( *it, false ); |
282 | 284 | ||
283 | // FN | 285 | // FN |
284 | if ( mMasterAddressee.formattedName().isEmpty() && !addr.formattedName().isEmpty() ) | 286 | if ( mMasterAddressee.formattedName().isEmpty() && !addr.formattedName().isEmpty() ) |
285 | mMasterAddressee.setFormattedName( addr.formattedName() ); | 287 | mMasterAddressee.setFormattedName( addr.formattedName() ); |
286 | 288 | ||
287 | // GEO | 289 | // GEO |
288 | if ( !mMasterAddressee.geo().isValid() && addr.geo().isValid() ) | 290 | if ( !mMasterAddressee.geo().isValid() && addr.geo().isValid() ) |
289 | mMasterAddressee.setGeo( addr.geo() ); | 291 | mMasterAddressee.setGeo( addr.geo() ); |
290 | 292 | ||
291 | /* | 293 | /* |
292 | // KEY | 294 | // KEY |
293 | // LOGO | 295 | // LOGO |
294 | */ | 296 | */ |
295 | 297 | ||
296 | // MAILER | 298 | // MAILER |
297 | if ( mMasterAddressee.mailer().isEmpty() && !addr.mailer().isEmpty() ) | 299 | if ( mMasterAddressee.mailer().isEmpty() && !addr.mailer().isEmpty() ) |
298 | mMasterAddressee.setMailer( addr.mailer() ); | 300 | mMasterAddressee.setMailer( addr.mailer() ); |
299 | 301 | ||
300 | // N | 302 | // N |
301 | if ( mMasterAddressee.assembledName().isEmpty() && !addr.assembledName().isEmpty() ) | 303 | if ( mMasterAddressee.assembledName().isEmpty() && !addr.assembledName().isEmpty() ) |
302 | mMasterAddressee.setNameFromString( addr.assembledName() ); | 304 | mMasterAddressee.setNameFromString( addr.assembledName() ); |
303 | 305 | ||
304 | // NICKNAME | 306 | // NICKNAME |
305 | if ( mMasterAddressee.nickName().isEmpty() && !addr.nickName().isEmpty() ) | 307 | if ( mMasterAddressee.nickName().isEmpty() && !addr.nickName().isEmpty() ) |
306 | mMasterAddressee.setNickName( addr.nickName() ); | 308 | mMasterAddressee.setNickName( addr.nickName() ); |
307 | 309 | ||
308 | // NOTE | 310 | // NOTE |
309 | if ( mMasterAddressee.note().isEmpty() && !addr.note().isEmpty() ) | 311 | if ( mMasterAddressee.note().isEmpty() && !addr.note().isEmpty() ) |
310 | mMasterAddressee.setNote( addr.note() ); | 312 | mMasterAddressee.setNote( addr.note() ); |
311 | 313 | ||
312 | // ORG | 314 | // ORG |
313 | if ( mMasterAddressee.organization().isEmpty() && !addr.organization().isEmpty() ) | 315 | if ( mMasterAddressee.organization().isEmpty() && !addr.organization().isEmpty() ) |
314 | mMasterAddressee.setOrganization( addr.organization() ); | 316 | mMasterAddressee.setOrganization( addr.organization() ); |
315 | 317 | ||
316 | /* | 318 | /* |
317 | // PHOTO | 319 | // PHOTO |
318 | */ | 320 | */ |
319 | 321 | ||
320 | // PROID | 322 | // PROID |
321 | if ( mMasterAddressee.productId().isEmpty() && !addr.productId().isEmpty() ) | 323 | if ( mMasterAddressee.productId().isEmpty() && !addr.productId().isEmpty() ) |
322 | mMasterAddressee.setProductId( addr.productId() ); | 324 | mMasterAddressee.setProductId( addr.productId() ); |
323 | 325 | ||
324 | // REV | 326 | // REV |
325 | if ( mMasterAddressee.revision().isNull() && !addr.revision().isNull() ) | 327 | if ( mMasterAddressee.revision().isNull() && !addr.revision().isNull() ) |
326 | mMasterAddressee.setRevision( addr.revision() ); | 328 | mMasterAddressee.setRevision( addr.revision() ); |
327 | 329 | ||
328 | // ROLE | 330 | // ROLE |
329 | if ( mMasterAddressee.role().isEmpty() && !addr.role().isEmpty() ) | 331 | if ( mMasterAddressee.role().isEmpty() && !addr.role().isEmpty() ) |
330 | mMasterAddressee.setRole( addr.role() ); | 332 | mMasterAddressee.setRole( addr.role() ); |
331 | 333 | ||
332 | // SORT-STRING | 334 | // SORT-STRING |
333 | if ( mMasterAddressee.sortString().isEmpty() && !addr.sortString().isEmpty() ) | 335 | if ( mMasterAddressee.sortString().isEmpty() && !addr.sortString().isEmpty() ) |
334 | mMasterAddressee.setSortString( addr.sortString() ); | 336 | mMasterAddressee.setSortString( addr.sortString() ); |
335 | 337 | ||
336 | /* | 338 | /* |
337 | // SOUND | 339 | // SOUND |
338 | */ | 340 | */ |
339 | 341 | ||
340 | // TEL | 342 | // TEL |
341 | KABC::PhoneNumber::List phones = addr.phoneNumbers(); | 343 | KABC::PhoneNumber::List phones = addr.phoneNumbers(); |
342 | KABC::PhoneNumber::List masterPhones = mMasterAddressee.phoneNumbers(); | 344 | KABC::PhoneNumber::List masterPhones = mMasterAddressee.phoneNumbers(); |
343 | KABC::PhoneNumber::List::ConstIterator phoneIt; | 345 | KABC::PhoneNumber::List::ConstIterator phoneIt; |
344 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) | 346 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) |
345 | if ( !masterPhones.contains( *it ) ) | 347 | if ( !masterPhones.contains( *it ) ) |
346 | mMasterAddressee.insertPhoneNumber( *it ); | 348 | mMasterAddressee.insertPhoneNumber( *it ); |
347 | 349 | ||
348 | // TITLE | 350 | // TITLE |
349 | if ( mMasterAddressee.title().isEmpty() && !addr.title().isEmpty() ) | 351 | if ( mMasterAddressee.title().isEmpty() && !addr.title().isEmpty() ) |
350 | mMasterAddressee.setTitle( addr.title() ); | 352 | mMasterAddressee.setTitle( addr.title() ); |
351 | 353 | ||
352 | // TZ | 354 | // TZ |
353 | if ( !mMasterAddressee.timeZone().isValid() && addr.timeZone().isValid() ) | 355 | if ( !mMasterAddressee.timeZone().isValid() && addr.timeZone().isValid() ) |
354 | mMasterAddressee.setTimeZone( addr.timeZone() ); | 356 | mMasterAddressee.setTimeZone( addr.timeZone() ); |
355 | 357 | ||
356 | // UID // ignore UID | 358 | // UID // ignore UID |
357 | 359 | ||
358 | // URL | 360 | // URL |
359 | if ( mMasterAddressee.url().isEmpty() && !addr.url().isEmpty() ) | 361 | if ( mMasterAddressee.url().isEmpty() && !addr.url().isEmpty() ) |
360 | mMasterAddressee.setUrl( addr.url() ); | 362 | mMasterAddressee.setUrl( addr.url() ); |
361 | 363 | ||
362 | // X- | 364 | // X- |
363 | QStringList customs = addr.customs(); | 365 | QStringList customs = addr.customs(); |
364 | QStringList masterCustoms = mMasterAddressee.customs(); | 366 | QStringList masterCustoms = mMasterAddressee.customs(); |
365 | QStringList newCustoms( masterCustoms ); | 367 | QStringList newCustoms( masterCustoms ); |
366 | for ( it = customs.begin(); it != customs.end(); ++it ) | 368 | for ( it = customs.begin(); it != customs.end(); ++it ) |
367 | if ( !masterCustoms.contains( *it ) ) | 369 | if ( !masterCustoms.contains( *it ) ) |
368 | newCustoms.append( *it ); | 370 | newCustoms.append( *it ); |
369 | mMasterAddressee.setCustoms( newCustoms ); | 371 | mMasterAddressee.setCustoms( newCustoms ); |
370 | } | 372 | } |
371 | 373 | ||
372 | #ifndef KAB_EMBEDDED | 374 | #ifndef KAB_EMBEDDED_ |
373 | #include "mergewidget.moc" | 375 | #include "moc_mergewidget.cpp" |
374 | #endif //KAB_EMBEDDED | 376 | #endif //KAB_EMBEDDED |