Diffstat (limited to 'kaddressbook/xxport/vcard_xxport.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/xxport/vcard_xxport.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp index adf47cd..4819341 100644 --- a/kaddressbook/xxport/vcard_xxport.cpp +++ b/kaddressbook/xxport/vcard_xxport.cpp | |||
@@ -87,21 +87,21 @@ bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString | |||
87 | QString name; | 87 | QString name; |
88 | 88 | ||
89 | if ( list.count() == 1 ) | 89 | if ( list.count() == 1 ) |
90 | name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; | 90 | name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; |
91 | else | 91 | else |
92 | name = "addressbook.vcf"; | 92 | name = "addressbook.vcf"; |
93 | 93 | ||
94 | #ifndef KAB_EMBEDDED | 94 | #ifndef KAB_EMBEDDED |
95 | QString fileName = KFileDialog::getSaveFileName( name ); | 95 | QString fileName = KFileDialog::getSaveFileName( name ); |
96 | #else //KAB_EMBEDDED | 96 | #else //KAB_EMBEDDED |
97 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); | 97 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); |
98 | #endif //KAB_EMBEDDED | 98 | #endif //KAB_EMBEDDED |
99 | 99 | ||
100 | if ( fileName.isEmpty() ) | 100 | if ( fileName.isEmpty() ) |
101 | return true; | 101 | return false; |
102 | 102 | ||
103 | QFile outFile( fileName ); | 103 | QFile outFile( fileName ); |
104 | if ( !outFile.open( IO_WriteOnly ) ) { | 104 | if ( !outFile.open( IO_WriteOnly ) ) { |
105 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 105 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
106 | KMessageBox::error( parentWidget(), text.arg( fileName ) ); | 106 | KMessageBox::error( parentWidget(), text.arg( fileName ) ); |
107 | return false; | 107 | return false; |
@@ -165,57 +165,57 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const | |||
165 | KIO::NetAccess::removeTempFile( fileName ); | 165 | KIO::NetAccess::removeTempFile( fileName ); |
166 | 166 | ||
167 | } else { | 167 | } else { |
168 | QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); | 168 | QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); |
169 | KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); | 169 | KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); |
170 | } | 170 | } |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | #else //KAB_EMBEDDED | 175 | #else //KAB_EMBEDDED |
176 | 176 | ||
177 | 177 | ||
178 | if ( !XXPortManager::importData.isEmpty() ) | 178 | if ( !XXPortManager::importData.isEmpty() ) |
179 | addrList = parseVCard( XXPortManager::importData ); | 179 | addrList = parseVCard( XXPortManager::importData ); |
180 | else { | 180 | else { |
181 | if ( XXPortManager::importURL.isEmpty() ) | 181 | if ( XXPortManager::importURL.isEmpty() ) |
182 | { | 182 | { |
183 | fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); | 183 | fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); |
184 | if ( fileName.isEmpty() ) | 184 | if ( fileName.isEmpty() ) |
185 | return addrList; | 185 | return addrList; |
186 | 186 | ||
187 | } | 187 | } |
188 | else | 188 | else |
189 | { | 189 | { |
190 | //US url = XXPortManager::importURL; | 190 | //US url = XXPortManager::importURL; |
191 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); | 191 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); |
192 | if ( url.isEmpty() ) | 192 | if ( url.isEmpty() ) |
193 | return addrList; | 193 | return addrList; |
194 | 194 | ||
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | QFile file( fileName ); | 198 | QFile file( fileName ); |
199 | 199 | ||
200 | file.open( IO_ReadOnly ); | 200 | file.open( IO_ReadOnly ); |
201 | QByteArray rawData = file.readAll(); | 201 | QByteArray rawData = file.readAll(); |
202 | file.close(); | 202 | file.close(); |
203 | 203 | ||
204 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 204 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
205 | addrList = parseVCard( data ); | 205 | addrList = parseVCard( data ); |
206 | 206 | ||
207 | } | 207 | } |
208 | #endif //KAB_EMBEDDED | 208 | #endif //KAB_EMBEDDED |
209 | 209 | ||
210 | return addrList; | 210 | return addrList; |
211 | } | 211 | } |
212 | 212 | ||
213 | KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const | 213 | KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const |
214 | { | 214 | { |
215 | 215 | ||
216 | KABC::VCardTool tool; | 216 | KABC::VCardTool tool; |
217 | KABC::AddresseeList addrList; | 217 | KABC::AddresseeList addrList; |
218 | addrList = tool.parseVCards( data ); | 218 | addrList = tool.parseVCards( data ); |
219 | // LR : I switched to the code, which is in current cvs HEAD | 219 | // LR : I switched to the code, which is in current cvs HEAD |
220 | /* | 220 | /* |
221 | uint numVCards = data.contains( "BEGIN:VCARD", false ); | 221 | uint numVCards = data.contains( "BEGIN:VCARD", false ); |