Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 60ca3e0d authored by Laurent Montel's avatar Laurent Montel 😁

Fix PREF

parent 0175275f
......@@ -1293,6 +1293,11 @@ Email::List Addressee::emailList() const
return d->mEmails;
}
void Addressee::setEmailList(const Email::List &list)
{
d->mEmails = list;
}
void Addressee::setEmails( const QStringList& emails )
{
d->mEmails.clear();
......
......@@ -699,7 +699,7 @@ class KABC_EXPORT Addressee
@param list The list of email addresses.
*/
void setEmails( const QStringList& list);
void setEmailList(const Email::List &list);
/**
Insert a phone number. If a phone number with the same id already exists
in this addressee it is not duplicated.
......
......@@ -188,16 +188,31 @@ QByteArray VCardTool::createVCards( const Addressee::List &list,
bool pref = true;
for ( emailIt = emailList.begin(); emailIt != emailEnd; ++emailIt ) {
bool needToAddPref = false;
VCardLine line( QLatin1String( "EMAIL" ), (*emailIt).mail() );
if ( pref == true && emailList.count() > 1 ) {
line.addParameter( QLatin1String( "TYPE" ), QLatin1String( "PREF" ) );
needToAddPref = true;
pref = false;
}
QMapIterator<QString, QStringList> i((*emailIt).parameters());
bool foundType = false;
while (i.hasNext()) {
i.next();
qDebug()<<" i.key()"<<i.key()<<" i.value().join(QLatin1S"<<i.value().join(QLatin1String(","));
line.addParameter( i.key(), i.value().join(QLatin1String(",")) );
QStringList valueStringList = i.value();
if (i.key().toLower() == QLatin1String( "type" )) {
if (!valueStringList.contains(QLatin1String("PREF"))) {
if (needToAddPref) {
valueStringList.append(QLatin1String( "PREF" ));
} else {
needToAddPref = false;
}
}
foundType = true;
}
line.addParameter( i.key(), valueStringList.join(QLatin1String(",")) );
}
if (!foundType && needToAddPref) {
line.addParameter( QLatin1String( "TYPE" ), QLatin1String( "PREF" ) );
}
card.addLine( line );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment