8#include "phonenumber.h"
9#include "parametermap_p.h"
11#include <KLocalizedString>
17using namespace KContacts;
33 Private(
const Private &other)
38 mNumber = other.mNumber;
44 ParameterMap mParamMap;
48 : d(new Private(
Home))
53 : d(new Private(type))
55 d->mNumber = cleanupNumber(number);
69 if (d->mId != other.d->mId) {
73 if (d->mNumber != other.d->mNumber) {
77 if (d->mType != other.d->mType) {
81 if (d->mParamMap != other.d->mParamMap) {
90 return !(other == *
this);
102bool PhoneNumber::isEmpty()
const
104 return d->mNumber.isEmpty();
119 d->mNumber = cleanupNumber(number);
130 result.
reserve(d->mNumber.size());
131 for (
const auto &c : d->mNumber) {
151 return typeLabel(type());
170 return i18nc(
"Undefined phone type",
"Telephone number");
172 return i18nc(
"Home phone",
"Home");
174 return i18nc(
"Work phone",
"Work");
176 return i18n(
"Messenger");
178 return i18nc(
"Preferred phone",
"Preferred");
180 return i18n(
"Voice");
184 return i18nc(
"Mobile Phone",
"Mobile");
186 return i18nc(
"Video phone",
"Video");
188 return i18n(
"Mailbox");
190 return i18n(
"Modem");
192 return i18nc(
"Car Phone",
"Car");
198 return i18n(
"Pager");
200 return i18nc(
"another type of phone",
"Other");
213 return i18n(
"Preferred Number");
218 label =
i18n(
"Home Fax");
222 }
else if (type &
Work) {
223 label =
i18n(
"Work Fax");
231 for (
const auto f : list) {
250bool PhoneNumber::isPreferred()
const
252 return type() &
Pref;
255bool PhoneNumber::supportsSms()
const
257 return type() &
Cell;
263 str += QStringLiteral(
" Id: %1\n").
arg(d->mId);
264 str += QStringLiteral(
" Type: %1\n").
arg(typeLabel(d->mType));
265 str = d->mParamMap.toString();
266 str += QStringLiteral(
" Number: %1\n").
arg(d->mNumber);
272void PhoneNumber::setParams(
const ParameterMap ¶ms)
274 d->mParamMap = params;
277ParameterMap PhoneNumber::params()
const
282QDataStream &KContacts::operator<<(QDataStream &s,
const PhoneNumber &phone)
284 return s << phone.d->mId <<
static_cast<uint
>(phone.d->mType) << phone.d->mNumber << phone.d->mParamMap;
287QDataStream &KContacts::operator>>(QDataStream &s,
PhoneNumber &phone)
290 s >> phone.d->mId >>
type >> phone.d->mNumber >> phone.d->mParamMap;
296#include "moc_phonenumber.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
KCOREADDONS_EXPORT QString randomString(int length)
bool isEmpty() const const
QString & append(QChar ch)
QString arg(Args &&... args) const const
bool isEmpty() const const
void reserve(qsizetype size)
QString simplified() const const