Changeset View
Changeset View
Standalone View
Standalone View
conversion/kabcconversion.cpp
Show First 20 Lines • Show All 482 Lines • ▼ Show 20 Lines | KContacts::Addressee toKABC(const Kolab::Contact &contact) | ||||
if (contact.bDay().isValid()) { | if (contact.bDay().isValid()) { | ||||
addressee.setBirthday(toDate(contact.bDay()).dateTime()); | addressee.setBirthday(toDate(contact.bDay()).dateTime()); | ||||
} | } | ||||
if (!contact.titles().empty()) { | if (!contact.titles().empty()) { | ||||
addressee.setTitle(fromStdString(contact.titles().at(0))); //TODO support multiple | addressee.setTitle(fromStdString(contact.titles().at(0))); //TODO support multiple | ||||
} | } | ||||
if (!contact.urls().empty()) { | if (!contact.urls().empty()) { | ||||
addressee.setUrl(QUrl(fromStdString(contact.urls().at(0).url()))); //TODO support multiple | KContacts::ResourceLocatorUrl url; | ||||
url.setUrl(QUrl(fromStdString(contact.urls().at(0).url()))); //TODO support multiple | |||||
addressee.setUrl(url); | |||||
foreach(const Kolab::Url &u, contact.urls()) { | foreach(const Kolab::Url &u, contact.urls()) { | ||||
if (u.type() == Kolab::Url::Blog) { | if (u.type() == Kolab::Url::Blog) { | ||||
addressee.insertCustom("KADDRESSBOOK", "BlogFeed", fromStdString(u.url())); | addressee.insertCustom("KADDRESSBOOK", "BlogFeed", fromStdString(u.url())); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | Kolab::Contact fromKABC(const KContacts::Addressee &addressee) | ||||
if (!relateds.empty()) { | if (!relateds.empty()) { | ||||
businessAff.setRelateds(relateds); | businessAff.setRelateds(relateds); | ||||
} | } | ||||
if (!(businessAff == Kolab::Affiliation())) { | if (!(businessAff == Kolab::Affiliation())) { | ||||
c.setAffiliations(std::vector<Kolab::Affiliation>() << businessAff); | c.setAffiliations(std::vector<Kolab::Affiliation>() << businessAff); | ||||
} | } | ||||
std::vector<Kolab::Url> urls; | std::vector<Kolab::Url> urls; | ||||
if (!addressee.url().isEmpty()) { | if (!addressee.url().url().isEmpty()) { | ||||
urls.push_back(Kolab::Url(toStdString(addressee.url().url()))); | urls.push_back(Kolab::Url(toStdString(addressee.url().url().url()))); | ||||
} | } | ||||
const QString &blogUrl = addressee.custom(QLatin1String("KADDRESSBOOK"), QLatin1String("BlogFeed")); | const QString &blogUrl = addressee.custom(QLatin1String("KADDRESSBOOK"), QLatin1String("BlogFeed")); | ||||
if (!blogUrl.isEmpty()) { | if (!blogUrl.isEmpty()) { | ||||
urls.push_back(Kolab::Url(toStdString(blogUrl), Kolab::Url::Blog)); | urls.push_back(Kolab::Url(toStdString(blogUrl), Kolab::Url::Blog)); | ||||
} | } | ||||
c.setUrls(urls); | c.setUrls(urls); | ||||
std::vector<Kolab::Address> addresses; | std::vector<Kolab::Address> addresses; | ||||
Show All 21 Lines | if (!addressee.nickName().isEmpty()) { | ||||
c.setNickNames(std::vector<std::string>() << toStdString(addressee.nickName())); | c.setNickNames(std::vector<std::string>() << toStdString(addressee.nickName())); | ||||
} | } | ||||
const QString &spouse = addressee.custom(QLatin1String("KADDRESSBOOK"), QLatin1String("X-SpousesName")); | const QString &spouse = addressee.custom(QLatin1String("KADDRESSBOOK"), QLatin1String("X-SpousesName")); | ||||
if (!spouse.isEmpty()) { | if (!spouse.isEmpty()) { | ||||
c.setRelateds(std::vector<Kolab::Related>() << Kolab::Related(Kolab::Related::Text, toStdString(spouse), Kolab::Related::Spouse)); | c.setRelateds(std::vector<Kolab::Related>() << Kolab::Related(Kolab::Related::Text, toStdString(spouse), Kolab::Related::Spouse)); | ||||
} | } | ||||
c.setBDay(fromDate(KDateTime(addressee.birthday(), KDateTime::ClockTime))); | c.setBDay(fromDate(KDateTime(addressee.birthday(), KDateTime::ClockTime))); | ||||
c.setAnniversary(fromDate(KDateTime(QDate::fromString( addressee.custom(QLatin1String("KADDRESSBOOK"), QLatin1String("X-Anniversary")), Qt::ISODate ), KDateTime::ClockTime))); | c.setAnniversary(fromDate(KDateTime(QDate::fromString( addressee.custom(QLatin1String("KADDRESSBOOK"), QLatin1String("X-Anniversary")), Qt::ISODate ), KDateTime::Spec(KDateTime::ClockTime)))); | ||||
if (!addressee.photo().isEmpty()) { | if (!addressee.photo().isEmpty()) { | ||||
std::string mimetype; | std::string mimetype; | ||||
const std::string &photo = fromPicture(addressee.photo(), mimetype); | const std::string &photo = fromPicture(addressee.photo(), mimetype); | ||||
c.setPhoto(photo, mimetype); | c.setPhoto(photo, mimetype); | ||||
} | } | ||||
//TODO | //TODO | ||||
// c.setGender(); | // c.setGender(); | ||||
// c.setLanguages(); | // c.setLanguages(); | ||||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |