summaryrefslogtreecommitdiffabout
path: root/kaddressbook/xxport/vcard_xxport.cpp
Unidiff
Diffstat (limited to 'kaddressbook/xxport/vcard_xxport.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/xxport/vcard_xxport.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp
index 9a8fa68..64b9071 100644
--- a/kaddressbook/xxport/vcard_xxport.cpp
+++ b/kaddressbook/xxport/vcard_xxport.cpp
@@ -26,14 +26,16 @@
26 Copyright (c) 2004 Ulf Schenk 26 Copyright (c) 2004 Ulf Schenk
27 27
28 $Id$ 28 $Id$
29*/ 29*/
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <q3textstream.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34//Added by qt3to4:
35#include <Q3CString>
34 36
35#include <kabc/vcardconverter.h> 37#include <kabc/vcardconverter.h>
36#include <kabc/vcardparser/vcardtool.h> 38#include <kabc/vcardparser/vcardtool.h>
37#include <kfiledialog.h> 39#include <kfiledialog.h>
38#ifndef KAB_EMBEDDED 40#ifndef KAB_EMBEDDED
39#include <kio/netaccess.h> 41#include <kio/netaccess.h>
@@ -99,20 +101,20 @@ bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString
99#endif //KAB_EMBEDDED 101#endif //KAB_EMBEDDED
100 102
101 if ( fileName.isEmpty() ) 103 if ( fileName.isEmpty() )
102 return false; 104 return false;
103 105
104 QFile outFile( fileName ); 106 QFile outFile( fileName );
105 if ( !outFile.open( IO_WriteOnly ) ) { 107 if ( !outFile.open( QIODevice::WriteOnly ) ) {
106 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 108 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
107 KMessageBox::error( parentWidget(), text.arg( fileName ) ); 109 KMessageBox::error( parentWidget(), text.arg( fileName ) );
108 return false; 110 return false;
109 } 111 }
110 112
111 QTextStream t( &outFile ); 113 Q3TextStream t( &outFile );
112 t.setEncoding( QTextStream::UnicodeUTF8 ); 114 t.setEncoding( Q3TextStream::UnicodeUTF8 );
113 115
114 KABC::Addressee::List::ConstIterator it; 116 KABC::Addressee::List::ConstIterator it;
115 for ( it = list.begin(); it != list.end(); ++it ) { 117 for ( it = list.begin(); it != list.end(); ++it ) {
116 KABC::VCardConverter converter; 118 KABC::VCardConverter converter;
117 QString vcard; 119 QString vcard;
118 120
@@ -150,13 +152,13 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const
150 if ( url.isEmpty() ) 152 if ( url.isEmpty() )
151 return addrList; 153 return addrList;
152 QString caption( i18n( "vCard Import Failed" ) ); 154 QString caption( i18n( "vCard Import Failed" ) );
153 if ( KIO::NetAccess::download( url, fileName ) ) { 155 if ( KIO::NetAccess::download( url, fileName ) ) {
154 QFile file( fileName ); 156 QFile file( fileName );
155 157
156 file.open( IO_ReadOnly ); 158 file.open( QIODevice::ReadOnly );
157 QByteArray rawData = file.readAll(); 159 QByteArray rawData = file.readAll();
158 file.close(); 160 file.close();
159 161
160 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 162 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
161 addrList = parseVCard( data ); 163 addrList = parseVCard( data );
162 164
@@ -193,14 +195,14 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const
193 qDebug("VCardXXPort::importContacts Urls at the moment not supported"); 195 qDebug("VCardXXPort::importContacts Urls at the moment not supported");
194 if ( url.isEmpty() ) 196 if ( url.isEmpty() )
195 return addrList; 197 return addrList;
196 198
197 } 199 }
198 QFile file( fileName ); 200 QFile file( fileName );
199 if ( file.open( IO_ReadOnly ) ) { 201 if ( file.open( QIODevice::ReadOnly ) ) {
200 QCString rawData ( file.readAll().data(),file.size()+1); 202 Q3CString rawData ( file.readAll().data(),file.size()+1);
201 file.close(); 203 file.close();
202 int start = 0; 204 int start = 0;
203#ifndef DESKTOP_VERSION 205#ifndef DESKTOP_VERSION
204 while ( start < rawData.size()-2 ) { 206 while ( start < rawData.size()-2 ) {
205 if ( rawData.at( start ) == '\r' ) 207 if ( rawData.at( start ) == '\r' )
206 if ( rawData.at( start+1 ) == '\n' ) 208 if ( rawData.at( start+1 ) == '\n' )
@@ -264,9 +266,9 @@ KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const
264 KMessageBox::sorry( parentWidget(), text ); 266 KMessageBox::sorry( parentWidget(), text );
265 } 267 }
266 return addrList; 268 return addrList;
267} 269}
268 270
269 271
270#ifndef KAB_EMBEDDED 272#ifndef KAB_EMBEDDED_
271#include "vcard_xxport.moc" 273#include "moc_vcard_xxport.cpp"
272#endif //KAB_EMBEDDED 274#endif //KAB_EMBEDDED