Commit 4b21c066 authored by camilo higuita's avatar camilo higuita

mix kpeople and vacrd parsing data

parent bd059f6f
...@@ -53,26 +53,28 @@ static FMH::MODEL vCardData(const QString &url) ...@@ -53,26 +53,28 @@ static FMH::MODEL vCardData(const QString &url)
} }
VCardConverter converter; VCardConverter converter;
Addressee adr = converter.parseVCard(file.readAll()); Addressee adr = converter.parseVCard(file.readAll());
qDebug()<< adr.url().toString() <<adr.customs() << adr.formattedName() << adr.fullEmail(); qDebug()<< adr.url().toString() <<adr.customs() << adr.formattedName() << adr.fullEmail();
res = { {FMH::MODEL_KEY::ID, QStringLiteral("vcard:/")+url}, res = {
{FMH::MODEL_KEY::N, adr.name()}, // {FMH::MODEL_KEY::ID, QStringLiteral("vcard:/")+url},
// {FMH::MODEL_KEY::N, adr.name()},
{FMH::MODEL_KEY::ORG, adr.organization()}, {FMH::MODEL_KEY::ORG, adr.organization()},
{FMH::MODEL_KEY::GENDER, adr.gender().gender()}, {FMH::MODEL_KEY::GENDER, adr.gender().gender()},
{FMH::MODEL_KEY::TITLE, adr.title()}, {FMH::MODEL_KEY::TITLE, adr.title()},
{FMH::MODEL_KEY::NOTE, adr.note()}, {FMH::MODEL_KEY::NOTE, adr.note()},
{FMH::MODEL_KEY::URL, adr.url().toString()}, {FMH::MODEL_KEY::URL, adr.url().toString()},
{FMH::MODEL_KEY::FAV, adr.custom("fav", "fav")}, {FMH::MODEL_KEY::FAV, adr.custom("fav", "fav")},
{FMH::MODEL_KEY::EMAIL, adr.emails().join(",")}, // {FMH::MODEL_KEY::EMAIL, adr.emails().join(",")},
{FMH::MODEL_KEY::TEL, [phones = adr.phoneNumbers(PhoneNumber::Cell)]() // {FMH::MODEL_KEY::TEL, [phones = adr.phoneNumbers(PhoneNumber::Cell)]()
{ // {
return std::accumulate(phones.begin(), phones.end(), QStringList(), [](QStringList &value, const PhoneNumber &number) -> QStringList // return std::accumulate(phones.begin(), phones.end(), QStringList(), [](QStringList &value, const PhoneNumber &number) -> QStringList
{ // {
return value << number.number(); // return value << number.number();
}); // });
}().join(",") // }().join(",")
}, // },
{FMH::MODEL_KEY::PHOTO, adr.photo().url()} {FMH::MODEL_KEY::PHOTO, adr.photo().url()}
}; };
...@@ -83,29 +85,27 @@ static FMH::MODEL vCardData(const QString &url) ...@@ -83,29 +85,27 @@ static FMH::MODEL vCardData(const QString &url)
void LinuxInterface::getContacts() void LinuxInterface::getContacts()
{ {
QDirIterator it(this->path, {"*.vcf"}, QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); // QDirIterator it(this->path, {"*.vcf"}, QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
while(it.hasNext()) // while(it.hasNext())
this->m_contacts << vCardData(it.next()); // this->m_contacts <<
// KPeople::PersonsModel model; KPeople::PersonsModel model;
// for(auto i = 0 ; i< model.rowCount(); i++) for(auto i = 0 ; i< model.rowCount(); i++)
// { {
// const auto uri = model.get(i, KPeople::PersonsModel::PersonUriRole).toString(); const auto uri = model.get(i, KPeople::PersonsModel::PersonUriRole).toString();
// KPeople::PersonData person(uri); KPeople::PersonData person(uri);
// this->m_contacts << FMH::MODEL { auto contact = FMH::MODEL {
// {FMH::MODEL_KEY::ID, person.personUri()}, {FMH::MODEL_KEY::ID, person.personUri()},
// {FMH::MODEL_KEY::N, person.name()}, {FMH::MODEL_KEY::N, person.name()},
// {FMH::MODEL_KEY::FAV, person.contactCustomProperty(FMH::MODEL_NAME[FMH::MODEL_KEY::FAV]).toString()}, {FMH::MODEL_KEY::EMAIL, person.email()},
// {FMH::MODEL_KEY::EMAIL, person.email()}, {FMH::MODEL_KEY::TEL, person.contactCustomProperty("phoneNumber").toString()},
// {FMH::MODEL_KEY::TEL, person.contactCustomProperty("phoneNumber").toString()}, // {FMH::MODEL_KEY::PHOTO, person.pictureUrl().toString()}
// {FMH::MODEL_KEY::PHOTO, person.pictureUrl().toString()}}; };
//qDebug() << "CUSTOM RPOP" << person.contactCustomProperty(FMH::MODEL_NAME[FMH::MODEL_KEY::FAV]).toString(); this->m_contacts << contact.unite(vCardData(QString(uri).replace("vcard:/", "")));
//qDebug() << "CUSTOM RPOP" << person.contactCustomProperty("fav"); }
//qDebug()<< person.contactCustomProperty("phoneNumber").toString();
//}
emit this->contactsReady(this->m_contacts); emit this->contactsReady(this->m_contacts);
} }
......
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