summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-08-20 00:36:50 (UTC)
committer ulf69 <ulf69>2004-08-20 00:36:50 (UTC)
commitd39b363278224b969d4c2945d32968c980b5d842 (patch) (side-by-side diff)
tree418087aff444216ddb08fcd94fa7fdbfa6d46947
parentf4149cef5f3be19d64c9c53130a62de0ec28ee44 (diff)
downloadkdepimpi-d39b363278224b969d4c2945d32968c980b5d842.zip
kdepimpi-d39b363278224b969d4c2945d32968c980b5d842.tar.gz
kdepimpi-d39b363278224b969d4c2945d32968c980b5d842.tar.bz2
performance optimization during vCard loading
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardformatimpl.cpp51
-rw-r--r--kabc/vcardformatimpl.h4
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 )
if ( it.current() ) {
- VCard v(*it.current());
- loadAddressee( addressee, v );
+//US VCard v(*it.current());
+//US loadAddressee( addressee, v );
+ loadAddressee( addressee, it.current() );
return true;
}
@@ -74,7 +75,8 @@ bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFi
for (; it.current(); ++it) {
- VCard v(*it.current());
+//US VCard v(*it.current());
Addressee addressee;
- loadAddressee( addressee, v );
+//US loadAddressee( addressee, v );
+ loadAddressee( addressee, it.current() );
addressee.setResource( resource );
addressBook->insertAddressee( addressee );
@@ -123,7 +125,7 @@ void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file
}
-bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard &v )
+bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v )
{
- QPtrList<ContentLine> contentLines = v.contentLineList();
+ QPtrList<ContentLine> contentLines = v->contentLineList();
ContentLine *cl;
@@ -785,17 +787,17 @@ void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent )
if ( addr ) {
writeToString( (*addr), vstr );
-
+
qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct");
-/*US
+/*US
vstr.replace( ":", "\\:" );
vstr.replace( ",", "\\," );
vstr.replace( ";", "\\;" );
vstr.replace( "\r\n", "\\n" );
-*/
- vstr.replace( QRegExp(":"), "\\:" );
- vstr.replace( QRegExp(","), "\\," );
- vstr.replace( QRegExp(";"), "\\;" );
- vstr.replace( QRegExp("\r\n"), "\\n" );
-
+*/
+ vstr.replace( QRegExp(":"), "\\:" );
+ vstr.replace( QRegExp(","), "\\," );
+ vstr.replace( QRegExp(";"), "\\;" );
+ vstr.replace( QRegExp("\r\n"), "\\n" );
+
cl.setValue( new TextValue( vstr.utf8() ) );
} else
@@ -826,5 +828,5 @@ Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl )
QString vstr = QString::fromUtf8( v->asString() );
qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct");
-/*US
+/*US
vstr.replace( "\\n", "\r\n" );
vstr.replace( "\\:", ":" );
@@ -832,9 +834,9 @@ Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl )
vstr.replace( "\\;", ";" );
*/
- vstr.replace( QRegExp("\\n"), "\r\n" );
- vstr.replace( QRegExp("\\:"), ":" );
- vstr.replace( QRegExp("\\,"), "," );
- vstr.replace( QRegExp("\\;"), ";" );
-
+ vstr.replace( QRegExp("\\n"), "\r\n" );
+ vstr.replace( QRegExp("\\:"), ":" );
+ vstr.replace( QRegExp("\\,"), "," );
+ vstr.replace( QRegExp("\\;"), ";" );
+
Addressee *addr = new Addressee;
readFromString( vstr, *addr );
@@ -867,5 +869,5 @@ void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType ty
s << img;
cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) );
-
+
} else { // save picture in cache
QString dir;
@@ -882,5 +884,5 @@ void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType ty
params.append( new Param( "TYPE", pic.type().utf8() ) );
} else {
-
+
cl.setValue( new TextValue( pic.url().utf8() ) );
params.append( new Param( "VALUE", "uri" ) );
@@ -1002,6 +1004,7 @@ bool VCardFormatImpl::readFromString( const QString &vcard, Addressee &addressee
if ( it.current() ) {
- VCard v(*it.current());
- loadAddressee( addressee, v );
+//US VCard v(*it.current());
+//US loadAddressee( addressee, v );
+ loadAddressee( addressee, it.current() );
return true;
}
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;
/**
@short Implementation of vCard backend for address book.
-
+
This class implements reading and writing of address book information using
the vCard format. It requires the vCard lib from kdepim.
@@ -59,5 +59,5 @@ class VCardFormatImpl
protected:
- bool loadAddressee( Addressee &, VCARD::VCard & );
+ bool loadAddressee( Addressee &, VCARD::VCard * );
void saveAddressee( const Addressee &, VCARD::VCard *, bool intern );