Diffstat (limited to 'kaddressbook/xxportobject.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/xxportobject.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kaddressbook/xxportobject.cpp b/kaddressbook/xxportobject.cpp index bd9d986..2d8d0ff 100644 --- a/kaddressbook/xxportobject.cpp +++ b/kaddressbook/xxportobject.cpp | |||
@@ -178,99 +178,99 @@ bool XXPortResourceObject::_exportContacts( const KABC::AddresseeList &list, con | |||
178 | { | 178 | { |
179 | //create new resource | 179 | //create new resource |
180 | KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 )); | 180 | KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 )); |
181 | 181 | ||
182 | if (mResource == 0) | 182 | if (mResource == 0) |
183 | return false; | 183 | return false; |
184 | 184 | ||
185 | if (fileName != QString::null) { | 185 | if (fileName != QString::null) { |
186 | mResource->setFileName( fileName ); | 186 | mResource->setFileName( fileName ); |
187 | } else | 187 | } else |
188 | return false; | 188 | return false; |
189 | 189 | ||
190 | 190 | ||
191 | KABC::TmpAddressBook tmpAB; | 191 | KABC::TmpAddressBook tmpAB; |
192 | 192 | ||
193 | bool res = tmpAB.addResource( mResource ); | 193 | bool res = tmpAB.addResource( mResource ); |
194 | if (res == false) | 194 | if (res == false) |
195 | { | 195 | { |
196 | delete mResource; | 196 | delete mResource; |
197 | return false; | 197 | return false; |
198 | } | 198 | } |
199 | if ( QFile::exists ( fileName ) ) { | 199 | if ( QFile::exists ( fileName ) ) { |
200 | res = tmpAB.load(); | 200 | res = tmpAB.load(); |
201 | if (res == false) | 201 | if (res == false) |
202 | { | 202 | { |
203 | //removeResource deletes also the resource object, if the linkcount is 0 | 203 | //removeResource deletes also the resource object, if the linkcount is 0 |
204 | tmpAB.removeResource( mResource ); | 204 | tmpAB.removeResource( mResource ); |
205 | return false; | 205 | return false; |
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | //Now check if the file has already entries, and ask the user if he wants to delete them first. | 209 | //Now check if the file has already entries, and ask the user if he wants to delete them first. |
210 | if (tmpAB.begin() != tmpAB.end()) | 210 | if (tmpAB.begin() != tmpAB.end()) |
211 | { | 211 | { |
212 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); | 212 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); |
213 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { | 213 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { |
214 | // Clean the database.. | 214 | // Clean the database.. |
215 | tmpAB.clear(); | 215 | tmpAB.clear(); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | KABC::Addressee::List::ConstIterator it; | 220 | KABC::Addressee::List::ConstIterator it; |
221 | for ( it = list.begin(); it != list.end(); ++it ) { | 221 | for ( it = list.begin(); it != list.end(); ++it ) { |
222 | tmpAB.insertAddressee(*it); | 222 | tmpAB.insertAddressee(*it); |
223 | } | 223 | } |
224 | 224 | ||
225 | KABC::Ticket * ticket = tmpAB.requestSaveTicket(mResource); | 225 | KABC::Ticket * ticket = tmpAB.requestSaveTicket(mResource); |
226 | 226 | ||
227 | res = false; | 227 | res = false; |
228 | if (ticket != 0) | 228 | if (ticket != 0) |
229 | res = tmpAB.save( ticket ); | 229 | res = tmpAB.save( ticket ); |
230 | 230 | ||
231 | //removeResource deletes also the resource object, if the linkcount is 0 | 231 | //removeResource deletes also the resource object, if the linkcount is 0 |
232 | tmpAB.removeResource( mResource ); | 232 | tmpAB.removeResource( mResource ); |
233 | 233 | ||
234 | return res; | 234 | return res; |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | KABC::AddresseeList XXPortResourceObject::_importContacts( const QString& identifier, const QString& fileName ) const | 238 | KABC::AddresseeList XXPortResourceObject::_importContacts( const QString& identifier, const QString& fileName ) const |
239 | { | 239 | { |
240 | 240 | ||
241 | 241 | ||
242 | KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 )); | 242 | KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 )); |
243 | 243 | ||
244 | if (mResource == 0) | 244 | if (mResource == 0) |
245 | return KABC::AddresseeList(); | 245 | return KABC::AddresseeList(); |
246 | 246 | ||
247 | KABC::AddresseeList adrlst; | 247 | KABC::AddresseeList adrlst; |
248 | 248 | ||
249 | if (fileName != QString::null) | 249 | if (fileName != QString::null) |
250 | mResource->setFileName( fileName ); | 250 | mResource->setFileName( fileName ); |
251 | 251 | ||
252 | 252 | ||
253 | KABC::TmpAddressBook tmpAB; | 253 | KABC::TmpAddressBook tmpAB; |
254 | 254 | ||
255 | bool res = tmpAB.addResource( mResource ); | 255 | bool res = tmpAB.addResource( mResource ); |
256 | if (res == false) | 256 | if (res == false) |
257 | { | 257 | { |
258 | delete mResource; | 258 | delete mResource; |
259 | return KABC::AddresseeList(); | 259 | return KABC::AddresseeList(); |
260 | } | 260 | } |
261 | 261 | ||
262 | res = tmpAB.load(); | 262 | res = tmpAB.load(); |
263 | 263 | ||
264 | adrlst = tmpAB.allAddressees(); | 264 | adrlst = tmpAB.allAddressees(); |
265 | 265 | ||
266 | //remove resource deletes also the Resourceobject, if the linkcount is 0 | 266 | //remove resource deletes also the Resourceobject, if the linkcount is 0 |
267 | tmpAB.removeResource( mResource ); | 267 | tmpAB.removeResource( mResource ); |
268 | 268 | ||
269 | return adrlst; | 269 | return adrlst; |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | 273 | ||
274 | #ifndef KAB_EMBEDDED | 274 | #ifndef KAB_EMBEDDED_ |
275 | #include "xxportobject.moc" | 275 | #include "moc_xxportobject.cpp" |
276 | #endif //KAB_EMBEDDED | 276 | #endif //KAB_EMBEDDED |