author | ulf69 <ulf69> | 2004-08-20 00:36:50 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-20 00:36:50 (UTC) |
commit | d39b363278224b969d4c2945d32968c980b5d842 (patch) (unidiff) | |
tree | 418087aff444216ddb08fcd94fa7fdbfa6d46947 | |
parent | f4149cef5f3be19d64c9c53130a62de0ec28ee44 (diff) | |
download | kdepimpi-d39b363278224b969d4c2945d32968c980b5d842.zip kdepimpi-d39b363278224b969d4c2945d32968c980b5d842.tar.gz kdepimpi-d39b363278224b969d4c2945d32968c980b5d842.tar.bz2 |
performance optimization during vCard loading
-rw-r--r-- | kabc/vcardformatimpl.cpp | 51 | ||||
-rw-r--r-- | kabc/vcardformatimpl.h | 4 |
2 files changed, 29 insertions, 26 deletions
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index 3fcaf94..bd9a57b 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp | |||
@@ -54,6 +54,7 @@ bool VCardFormatImpl::load( Addressee &addressee, QFile *file ) | |||
54 | 54 | ||
55 | if ( it.current() ) { | 55 | if ( it.current() ) { |
56 | VCard v(*it.current()); | 56 | //US VCard v(*it.current()); |
57 | loadAddressee( addressee, v ); | 57 | //US loadAddressee( addressee, v ); |
58 | loadAddressee( addressee, it.current() ); | ||
58 | return true; | 59 | return true; |
59 | } | 60 | } |
@@ -74,7 +75,8 @@ bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFi | |||
74 | 75 | ||
75 | for (; it.current(); ++it) { | 76 | for (; it.current(); ++it) { |
76 | VCard v(*it.current()); | 77 | //US VCard v(*it.current()); |
77 | Addressee addressee; | 78 | Addressee addressee; |
78 | loadAddressee( addressee, v ); | 79 | //US loadAddressee( addressee, v ); |
80 | loadAddressee( addressee, it.current() ); | ||
79 | addressee.setResource( resource ); | 81 | addressee.setResource( resource ); |
80 | addressBook->insertAddressee( addressee ); | 82 | addressBook->insertAddressee( addressee ); |
@@ -123,7 +125,7 @@ void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file | |||
123 | } | 125 | } |
124 | 126 | ||
125 | bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard &v ) | 127 | bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) |
126 | { | 128 | { |
127 | QPtrList<ContentLine> contentLines = v.contentLineList(); | 129 | QPtrList<ContentLine> contentLines = v->contentLineList(); |
128 | ContentLine *cl; | 130 | ContentLine *cl; |
129 | 131 | ||
@@ -785,17 +787,17 @@ void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent ) | |||
785 | if ( addr ) { | 787 | if ( addr ) { |
786 | writeToString( (*addr), vstr ); | 788 | writeToString( (*addr), vstr ); |
787 | 789 | ||
788 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); | 790 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); |
789 | /*US | 791 | /*US |
790 | vstr.replace( ":", "\\:" ); | 792 | vstr.replace( ":", "\\:" ); |
791 | vstr.replace( ",", "\\," ); | 793 | vstr.replace( ",", "\\," ); |
792 | vstr.replace( ";", "\\;" ); | 794 | vstr.replace( ";", "\\;" ); |
793 | vstr.replace( "\r\n", "\\n" ); | 795 | vstr.replace( "\r\n", "\\n" ); |
794 | */ | 796 | */ |
795 | vstr.replace( QRegExp(":"), "\\:" ); | 797 | vstr.replace( QRegExp(":"), "\\:" ); |
796 | vstr.replace( QRegExp(","), "\\," ); | 798 | vstr.replace( QRegExp(","), "\\," ); |
797 | vstr.replace( QRegExp(";"), "\\;" ); | 799 | vstr.replace( QRegExp(";"), "\\;" ); |
798 | vstr.replace( QRegExp("\r\n"), "\\n" ); | 800 | vstr.replace( QRegExp("\r\n"), "\\n" ); |
799 | 801 | ||
800 | cl.setValue( new TextValue( vstr.utf8() ) ); | 802 | cl.setValue( new TextValue( vstr.utf8() ) ); |
801 | } else | 803 | } else |
@@ -826,5 +828,5 @@ Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) | |||
826 | QString vstr = QString::fromUtf8( v->asString() ); | 828 | QString vstr = QString::fromUtf8( v->asString() ); |
827 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); | 829 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); |
828 | /*US | 830 | /*US |
829 | vstr.replace( "\\n", "\r\n" ); | 831 | vstr.replace( "\\n", "\r\n" ); |
830 | vstr.replace( "\\:", ":" ); | 832 | vstr.replace( "\\:", ":" ); |
@@ -832,9 +834,9 @@ Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) | |||
832 | vstr.replace( "\\;", ";" ); | 834 | vstr.replace( "\\;", ";" ); |
833 | */ | 835 | */ |
834 | vstr.replace( QRegExp("\\n"), "\r\n" ); | 836 | vstr.replace( QRegExp("\\n"), "\r\n" ); |
835 | vstr.replace( QRegExp("\\:"), ":" ); | 837 | vstr.replace( QRegExp("\\:"), ":" ); |
836 | vstr.replace( QRegExp("\\,"), "," ); | 838 | vstr.replace( QRegExp("\\,"), "," ); |
837 | vstr.replace( QRegExp("\\;"), ";" ); | 839 | vstr.replace( QRegExp("\\;"), ";" ); |
838 | 840 | ||
839 | Addressee *addr = new Addressee; | 841 | Addressee *addr = new Addressee; |
840 | readFromString( vstr, *addr ); | 842 | readFromString( vstr, *addr ); |
@@ -867,5 +869,5 @@ void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType ty | |||
867 | s << img; | 869 | s << img; |
868 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 870 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
869 | 871 | ||
870 | } else { // save picture in cache | 872 | } else { // save picture in cache |
871 | QString dir; | 873 | QString dir; |
@@ -882,5 +884,5 @@ void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType ty | |||
882 | params.append( new Param( "TYPE", pic.type().utf8() ) ); | 884 | params.append( new Param( "TYPE", pic.type().utf8() ) ); |
883 | } else { | 885 | } else { |
884 | 886 | ||
885 | cl.setValue( new TextValue( pic.url().utf8() ) ); | 887 | cl.setValue( new TextValue( pic.url().utf8() ) ); |
886 | params.append( new Param( "VALUE", "uri" ) ); | 888 | params.append( new Param( "VALUE", "uri" ) ); |
@@ -1002,6 +1004,7 @@ bool VCardFormatImpl::readFromString( const QString &vcard, Addressee &addressee | |||
1002 | 1004 | ||
1003 | if ( it.current() ) { | 1005 | if ( it.current() ) { |
1004 | VCard v(*it.current()); | 1006 | //US VCard v(*it.current()); |
1005 | loadAddressee( addressee, v ); | 1007 | //US loadAddressee( addressee, v ); |
1008 | loadAddressee( addressee, it.current() ); | ||
1006 | return true; | 1009 | return true; |
1007 | } | 1010 | } |
diff --git a/kabc/vcardformatimpl.h b/kabc/vcardformatimpl.h index 2dd68d9..fa3d55f 100644 --- a/kabc/vcardformatimpl.h +++ b/kabc/vcardformatimpl.h | |||
@@ -43,5 +43,5 @@ class AddressBook; | |||
43 | /** | 43 | /** |
44 | @short Implementation of vCard backend for address book. | 44 | @short Implementation of vCard backend for address book. |
45 | 45 | ||
46 | This class implements reading and writing of address book information using | 46 | This class implements reading and writing of address book information using |
47 | the vCard format. It requires the vCard lib from kdepim. | 47 | the vCard format. It requires the vCard lib from kdepim. |
@@ -59,5 +59,5 @@ class VCardFormatImpl | |||
59 | 59 | ||
60 | protected: | 60 | protected: |
61 | bool loadAddressee( Addressee &, VCARD::VCard & ); | 61 | bool loadAddressee( Addressee &, VCARD::VCard * ); |
62 | void saveAddressee( const Addressee &, VCARD::VCard *, bool intern ); | 62 | void saveAddressee( const Addressee &, VCARD::VCard *, bool intern ); |
63 | 63 | ||