Ejemplo n.º 1
0
std::vector<std::string> ContactEditController::nameSuggestionsFromVCard(VCard::ref vcard) {
	std::vector<std::string> suggestions;
	if (!vcard->getNickname().empty()) {
		suggestions.push_back(vcard->getNickname());
	}
	if (!vcard->getFullName().empty()) {
		suggestions.push_back(vcard->getFullName());
	}
	if (!vcard->getGivenName().empty()) {
		std::string suggestedName;
		suggestedName = vcard->getGivenName();
		boost::algorithm::trim(suggestedName);
		suggestions.push_back(suggestedName);
	}
	return suggestions;
}
Ejemplo n.º 2
0
void QtVCardWidget::setVCard(VCard::ref vcard) {
    clearFields();
    this->vcard = std::make_shared<VCard>(*vcard);
    ui->photoAndName->setFormattedName(P2QSTRING(vcard->getFullName()));
    ui->photoAndName->setNickname(P2QSTRING(vcard->getNickname()));
    ui->photoAndName->setPrefix(P2QSTRING(vcard->getPrefix()));
    ui->photoAndName->setGivenName(P2QSTRING(vcard->getGivenName()));
    ui->photoAndName->setMiddleName(P2QSTRING(vcard->getMiddleName()));
    ui->photoAndName->setFamilyName(P2QSTRING(vcard->getFamilyName()));
    ui->photoAndName->setSuffix(P2QSTRING(vcard->getSuffix()));
    ui->photoAndName->setAvatar(vcard->getPhoto(), vcard->getPhotoType());

    for (const auto& address : vcard->getEMailAddresses()) {
        if (address.isInternet) {
            QtVCardInternetEMailField* internetEmailField = new QtVCardInternetEMailField(this, ui->cardFields);
            internetEmailField->initialize();
            internetEmailField->setInternetEMailAddress(address);
            appendField(internetEmailField);
        }
    }

    for (const auto& telephone : vcard->getTelephones()) {
        QtVCardTelephoneField* telField = new QtVCardTelephoneField(this, ui->cardFields);
        telField->initialize();
        telField->setTelephone(telephone);
        appendField(telField);
    }

    for (const auto& address : vcard->getAddresses()) {
        QtVCardAddressField* addressField = new QtVCardAddressField(this, ui->cardFields);
        addressField->initialize();
        addressField->setAddress(address);
        appendField(addressField);
    }

    for (const auto& label : vcard->getAddressLabels()) {
        QtVCardAddressLabelField* addressLabelField = new QtVCardAddressLabelField(this, ui->cardFields);
        addressLabelField->initialize();
        addressLabelField->setAddressLabel(label);
        appendField(addressLabelField);
    }

    if (!vcard->getBirthday().is_not_a_date_time()) {
        QtVCardBirthdayField* bdayField = new QtVCardBirthdayField(this, ui->cardFields);
        bdayField->initialize();
        bdayField->setBirthday(vcard->getBirthday());
        appendField(bdayField);
    }

    for (const auto& jid : vcard->getJIDs()) {
        QtVCardJIDField* jidField = new QtVCardJIDField(this, ui->cardFields);
        jidField->initialize();
        jidField->setJID(jid);
        appendField(jidField);
    }

    if (!vcard->getDescription().empty()) {
        QtVCardDescriptionField* descField = new QtVCardDescriptionField(this, ui->cardFields);
        descField->initialize();
        descField->setDescription(vcard->getDescription());
        appendField(descField);
    }

    for (const auto& org : vcard->getOrganizations()) {
        QtVCardOrganizationField* orgField = new QtVCardOrganizationField(this, ui->cardFields);
        orgField->initialize();
        orgField->setOrganization(org);
        appendField(orgField);
    }

    for (const auto& role : vcard->getRoles()) {
        QtVCardRoleField* roleField = new QtVCardRoleField(this, ui->cardFields);
        roleField->initialize();
        roleField->setRole(role);
        appendField(roleField);
    }

    for (const auto& title : vcard->getTitles()) {
        QtVCardTitleField* titleField = new QtVCardTitleField(this, ui->cardFields);
        titleField->initialize();
        titleField->setTitle(title);
        appendField(titleField);
    }

    for (const auto& url : vcard->getURLs()) {
        QtVCardURLField* urlField = new QtVCardURLField(this, ui->cardFields);
        urlField->initialize();
        urlField->setURL(url);
        appendField(urlField);
    }

    relayoutToolButton();
    setEditable(editable);
}