10using namespace KContacts;
16VCard::VCard(
const VCard &vcard)
17 : mLineMap(vcard.mLineMap)
25VCard &VCard::operator=(
const VCard &vcard)
31 mLineMap = vcard.mLineMap;
45 for (
const auto &[lineId, l] : mLineMap) {
51void VCard::addLine(
const VCardLine &line)
53 auto it = findByLineId(line.identifier());
54 if (it != mLineMap.end()) {
55 it->list.append(line);
57 const LineData newdata{line.identifier(), {line}};
58 auto beforeIt = std::lower_bound(mLineMap.begin(), mLineMap.end(), newdata);
59 mLineMap.insert(beforeIt, newdata);
63VCardLine::List VCard::lines(
const QString &identifier)
const
65 auto it = findByLineId(identifier);
66 return it != mLineMap.cend() ? it->list : VCardLine::List{};
69VCardLine VCard::line(
const QString &identifier)
const
71 auto it = findByLineId(identifier);
72 return it != mLineMap.cend() && !it->list.isEmpty() ? it->list.at(0) : VCardLine{};
75static const char s_verStr[] =
"VERSION";
77void VCard::setVersion(Version version)
82 if (version == v2_1) {
83 line.setIdentifier(QStringLiteral(
"2.1"));
84 }
else if (version == v3_0) {
85 line.setIdentifier(QStringLiteral(
"3.0"));
86 }
else if (version == v4_0) {
87 line.setIdentifier(QStringLiteral(
"4.0"));
91 if (it != mLineMap.end()) {
92 it->list.append(line);
95 auto beforeIt = std::lower_bound(mLineMap.begin(), mLineMap.end(), newData);
96 mLineMap.insert(beforeIt, newData);
100VCard::Version VCard::version()
const
103 if (versionEntryIt == mLineMap.cend()) {
107 const VCardLine line = versionEntryIt->list.at(0);
KIOCORE_EXPORT QStringList list(const QString &fileClass)
void append(QList< T > &&value)
void reserve(qsizetype size)