author | zautrix <zautrix> | 2004-10-29 11:23:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 11:23:51 (UTC) |
commit | 2d28a226645f56a96fe0a8252e0d7e7b2cc4df2e (patch) (unidiff) | |
tree | 183624f038dc3176e89db748f25b024aa75b6365 /kaddressbook/xxportobject.cpp | |
parent | 67146a3d92727f6fe3e92eacdb51da58bc7b0adf (diff) | |
download | kdepimpi-2d28a226645f56a96fe0a8252e0d7e7b2cc4df2e.zip kdepimpi-2d28a226645f56a96fe0a8252e0d7e7b2cc4df2e.tar.gz kdepimpi-2d28a226645f56a96fe0a8252e0d7e7b2cc4df2e.tar.bz2 |
added filedialog to xml im/export
Diffstat (limited to 'kaddressbook/xxportobject.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/xxportobject.cpp | 85 |
1 files changed, 44 insertions, 41 deletions
diff --git a/kaddressbook/xxportobject.cpp b/kaddressbook/xxportobject.cpp index 67e8406..bd9d986 100644 --- a/kaddressbook/xxportobject.cpp +++ b/kaddressbook/xxportobject.cpp | |||
@@ -31,2 +31,3 @@ $Id$ | |||
31 | #include <qmap.h> | 31 | #include <qmap.h> |
32 | #include <qfile.h> | ||
32 | #include <qsignalmapper.h> | 33 | #include <qsignalmapper.h> |
@@ -178,46 +179,48 @@ bool XXPortResourceObject::_exportContacts( const KABC::AddresseeList &list, con | |||
178 | //create new resource | 179 | //create new resource |
179 | KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 )); | 180 | KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 )); |
180 | 181 | ||
181 | if (mResource == 0) | 182 | if (mResource == 0) |
182 | return false; | 183 | return false; |
183 | 184 | ||
184 | if (fileName != QString::null) | 185 | if (fileName != QString::null) { |
185 | mResource->setFileName( fileName ); | 186 | mResource->setFileName( fileName ); |
186 | 187 | } else | |
187 | 188 | return false; | |
188 | KABC::TmpAddressBook tmpAB; | 189 | |
189 | 190 | ||
190 | bool res = tmpAB.addResource( mResource ); | 191 | KABC::TmpAddressBook tmpAB; |
191 | if (res == false) | 192 | |
192 | { | 193 | bool res = tmpAB.addResource( mResource ); |
193 | delete mResource; | 194 | if (res == false) |
194 | return false; | 195 | { |
195 | } | 196 | delete mResource; |
196 | 197 | return false; | |
197 | res = tmpAB.load(); | 198 | } |
198 | if (res == false) | 199 | if ( QFile::exists ( fileName ) ) { |
199 | { | 200 | res = tmpAB.load(); |
200 | //removeResource deletes also the resource object, if the linkcount is 0 | 201 | if (res == false) |
201 | tmpAB.removeResource( mResource ); | 202 | { |
202 | return false; | 203 | //removeResource deletes also the resource object, if the linkcount is 0 |
203 | } | 204 | tmpAB.removeResource( mResource ); |
204 | 205 | return false; | |
205 | 206 | } | |
206 | //Now check if the file has already entries, and ask the user if he wants to delete them first. | 207 | |
207 | if (tmpAB.begin() != tmpAB.end()) | 208 | |
208 | { | 209 | //Now check if the file has already entries, and ask the user if he wants to delete them first. |
209 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); | 210 | if (tmpAB.begin() != tmpAB.end()) |
210 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { | 211 | { |
211 | // Clean the database.. | 212 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); |
212 | tmpAB.clear(); | 213 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { |
214 | // Clean the database.. | ||
215 | tmpAB.clear(); | ||
216 | } | ||
217 | } | ||
213 | } | 218 | } |
214 | } | ||
215 | 219 | ||
220 | KABC::Addressee::List::ConstIterator it; | ||
221 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
222 | tmpAB.insertAddressee(*it); | ||
223 | } | ||
216 | 224 | ||
217 | KABC::Addressee::List::ConstIterator it; | 225 | KABC::Ticket * ticket = tmpAB.requestSaveTicket(mResource); |
218 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
219 | tmpAB.insertAddressee(*it); | ||
220 | } | ||
221 | |||
222 | KABC::Ticket * ticket = tmpAB.requestSaveTicket(mResource); | ||
223 | 226 | ||