summaryrefslogtreecommitdiffabout
path: root/kabc/vcardformatimpl.cpp
authorzautrix <zautrix>2005-11-12 23:42:08 (UTC)
committer zautrix <zautrix>2005-11-12 23:42:08 (UTC)
commit4145dc4a513d5899d8a2b9e4573d8140d871b386 (patch) (side-by-side diff)
tree11bb2010757a65d90c2ed7e4d40d4e72d218eeb9 /kabc/vcardformatimpl.cpp
parent9e47202fd38512cc523c09cf8878f4c5d836e777 (diff)
downloadkdepimpi-4145dc4a513d5899d8a2b9e4573d8140d871b386.zip
kdepimpi-4145dc4a513d5899d8a2b9e4573d8140d871b386.tar.gz
kdepimpi-4145dc4a513d5899d8a2b9e4573d8140d871b386.tar.bz2
fix
Diffstat (limited to 'kabc/vcardformatimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardformatimpl.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp
index 26fd4f0..580c28b 100644
--- a/kabc/vcardformatimpl.cpp
+++ b/kabc/vcardformatimpl.cpp
@@ -832,82 +832,86 @@ Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl )
if ( isIntern ) {
QString vstr = QString::fromUtf8( v->asString() );
qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct");
/*US
vstr.replace( "\\n", "\r\n" );
vstr.replace( "\\:", ":" );
vstr.replace( "\\,", "," );
vstr.replace( "\\;", ";" );
*/
vstr.replace( QRegExp("\\\\n"), "\r\n" );
vstr.replace( QRegExp("\\\\:"), ":" );
vstr.replace( QRegExp("\\\\,"), "," );
vstr.replace( QRegExp("\\\\;"), ";" );
Addressee *addr = new Addressee;
readFromString( vstr, *addr );
agent.setAddressee( addr );
} else {
agent.setUrl( QString::fromUtf8( v->asString() ) );
}
return agent;
}
+#include <qstringlist.h>
void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern )
{
ContentLine cl;
cl.setName( EntityTypeToParamName( type ) );
-
+ // qDebug( "IIIMMMMM %s",QImage::outputFormatList ().join("-").latin1() );
if ( pic.isIntern() && pic.data().isNull() )
return;
if ( !pic.isIntern() && pic.url().isEmpty() )
return;
ParamList params;
if ( pic.isIntern() ) {
QImage img = pic.data();
if ( intern ) { // only for vCard export we really write the data inline
QByteArray data;
QDataStream s( data, IO_WriteOnly );
s.setVersion( 4 ); // to produce valid png files
s << img;
cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) );
-
+ params.append( new Param( "ENCODING", "b" ) );
+ if ( !pic.type().isEmpty() )
+ params.append( new Param( "TYPE", pic.type().utf8() ) );
} else { // save picture in cache
QString dir;
if ( type == EntityPhoto )
dir = "photos";
if ( type == EntityLogo )
dir = "logos";
-
- img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() );
- cl.setValue( new TextValue( "<dummy>" ) );
+ QString imUrl = locateLocal( "data", "kabc/" + dir + "/" + addr.uid() );
+ KABC::Picture* ppic =(KABC::Picture*) &pic;
+ ppic->setUrl( imUrl );
+ img.save(imUrl, "PNG" );
+ cl.setValue( new TextValue( pic.url().utf8() ) );
+ params.append( new Param( "VALUE", "uri" ) );
}
- params.append( new Param( "ENCODING", "b" ) );
- if ( !pic.type().isEmpty() )
- params.append( new Param( "TYPE", pic.type().utf8() ) );
+
} else {
cl.setValue( new TextValue( pic.url().utf8() ) );
params.append( new Param( "VALUE", "uri" ) );
}
cl.setParamList( params );
vcard->add( cl );
}
Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr )
{
Picture pic;
bool isInline = false;
QString picType;
TextValue *v = (TextValue *)cl->value();
ParamList params = cl->paramList();
ParamListIterator it( params );
for( ; it.current(); ++it ) {
if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" )
isInline = true;
if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() )
picType = QString::fromUtf8( (*it)->value() );