author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kabc/vcardformatimpl.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | kabc/vcardformatimpl.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index 580c28b..2417874 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp | |||
@@ -28,6 +28,9 @@ $Id$ | |||
28 | #include <qfile.h> | 28 | #include <qfile.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | //Added by qt3to4: | ||
32 | #include <Q3CString> | ||
33 | #include <Q3PtrList> | ||
31 | 34 | ||
32 | #include <kdebug.h> | 35 | #include <kdebug.h> |
33 | #include <kmdcodec.h> | 36 | #include <kmdcodec.h> |
@@ -54,7 +57,7 @@ bool VCardFormatImpl::load( Addressee &addressee, QFile *file ) | |||
54 | kdDebug(5700) << "VCardFormat::load()" << endl; | 57 | kdDebug(5700) << "VCardFormat::load()" << endl; |
55 | 58 | ||
56 | QByteArray fdata = file->readAll(); | 59 | QByteArray fdata = file->readAll(); |
57 | QCString data(fdata.data(), fdata.size()+1); | 60 | Q3CString data(fdata.data(), fdata.size()+1); |
58 | 61 | ||
59 | VCardEntity e( data ); | 62 | VCardEntity e( data ); |
60 | 63 | ||
@@ -75,7 +78,7 @@ bool VCardFormatImpl::load( Addressee &addressee, QFile *file ) | |||
75 | bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) | 78 | bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) |
76 | { | 79 | { |
77 | 80 | ||
78 | QCString data(file->readAll().data(), file->size()+1); | 81 | Q3CString data(file->readAll().data(), file->size()+1); |
79 | VCardEntity e( data ); | 82 | VCardEntity e( data ); |
80 | 83 | ||
81 | VCardListIterator it( e.cardList() ); | 84 | VCardListIterator it( e.cardList() ); |
@@ -108,7 +111,7 @@ void VCardFormatImpl::save( const Addressee &addressee, QFile *file ) | |||
108 | vcardlist.append( v ); | 111 | vcardlist.append( v ); |
109 | vcards.setCardList( vcardlist ); | 112 | vcards.setCardList( vcardlist ); |
110 | 113 | ||
111 | QCString vcardData = vcards.asString(); | 114 | Q3CString vcardData = vcards.asString(); |
112 | file->writeBlock( (const char*)vcardData, vcardData.length() ); | 115 | file->writeBlock( (const char*)vcardData, vcardData.length() ); |
113 | } | 116 | } |
114 | 117 | ||
@@ -129,11 +132,11 @@ void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file | |||
129 | 132 | ||
130 | bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) | 133 | bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) |
131 | { | 134 | { |
132 | QPtrList<ContentLine> contentLines = v->contentLineList(); | 135 | Q3PtrList<ContentLine> contentLines = v->contentLineList(); |
133 | ContentLine *cl; | 136 | ContentLine *cl; |
134 | 137 | ||
135 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { | 138 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { |
136 | QCString n = cl->name(); | 139 | Q3CString n = cl->name(); |
137 | if ( n.left( 2 ) == "X-" ) { | 140 | if ( n.left( 2 ) == "X-" ) { |
138 | n = n.mid( 2 ); | 141 | n = n.mid( 2 ); |
139 | int posDash = n.find( "-" ); | 142 | int posDash = n.find( "-" ); |
@@ -219,7 +222,7 @@ bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) | |||
219 | break; | 222 | break; |
220 | 223 | ||
221 | case EntityBirthday: | 224 | case EntityBirthday: |
222 | addressee.setBirthday( readDateValue( cl ) ); | 225 | addressee.setBirthday( (QDateTime) readDateValue( cl ) ); |
223 | break; | 226 | break; |
224 | 227 | ||
225 | case EntityRevision: | 228 | case EntityRevision: |
@@ -530,7 +533,7 @@ int VCardFormatImpl::readAddressParam( ContentLine *cl ) | |||
530 | int type = 0; | 533 | int type = 0; |
531 | ParamList params = cl->paramList(); | 534 | ParamList params = cl->paramList(); |
532 | ParamListIterator it( params ); | 535 | ParamListIterator it( params ); |
533 | QCString tmpStr; | 536 | Q3CString tmpStr; |
534 | for( ; it.current(); ++it ) { | 537 | for( ; it.current(); ++it ) { |
535 | if ( (*it)->name().upper() == "TYPE" ) { | 538 | if ( (*it)->name().upper() == "TYPE" ) { |
536 | tmpStr = (*it)->value().lower(); | 539 | tmpStr = (*it)->value().lower(); |
@@ -609,7 +612,7 @@ PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) | |||
609 | int type = 0; | 612 | int type = 0; |
610 | ParamList params = cl->paramList(); | 613 | ParamList params = cl->paramList(); |
611 | ParamListIterator it( params ); | 614 | ParamListIterator it( params ); |
612 | QCString tmpStr; | 615 | Q3CString tmpStr; |
613 | for( ; it.current(); ++it ) { | 616 | for( ; it.current(); ++it ) { |
614 | if ( (*it)->name() == "TYPE" ) { | 617 | if ( (*it)->name() == "TYPE" ) { |
615 | tmpStr = (*it)->value().lower(); | 618 | tmpStr = (*it)->value().lower(); |
@@ -870,7 +873,7 @@ void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType ty | |||
870 | QImage img = pic.data(); | 873 | QImage img = pic.data(); |
871 | if ( intern ) { // only for vCard export we really write the data inline | 874 | if ( intern ) { // only for vCard export we really write the data inline |
872 | QByteArray data; | 875 | QByteArray data; |
873 | QDataStream s( data, IO_WriteOnly ); | 876 | QDataStream s( &data, QIODevice::WriteOnly ); |
874 | s.setVersion( 4 ); // to produce valid png files | 877 | s.setVersion( 4 ); // to produce valid png files |
875 | s << img; | 878 | s << img; |
876 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 879 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
@@ -959,7 +962,7 @@ void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, co | |||
959 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 962 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
960 | } else { // save sound in cache | 963 | } else { // save sound in cache |
961 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); | 964 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); |
962 | if ( file.open( IO_WriteOnly ) ) { | 965 | if ( file.open( QIODevice::WriteOnly ) ) { |
963 | file.writeBlock( data ); | 966 | file.writeBlock( data ); |
964 | } | 967 | } |
965 | cl.setValue( new TextValue( "<dummy>" ) ); | 968 | cl.setValue( new TextValue( "<dummy>" ) ); |
@@ -991,7 +994,7 @@ Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee & | |||
991 | QByteArray data; | 994 | QByteArray data; |
992 | if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache | 995 | if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache |
993 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); | 996 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); |
994 | if ( file.open( IO_ReadOnly ) ) { | 997 | if ( file.open( QIODevice::ReadOnly ) ) { |
995 | data = file.readAll(); | 998 | data = file.readAll(); |
996 | file.close(); | 999 | file.close(); |
997 | } | 1000 | } |