File indexing completed on 2025-03-23 13:45:10
0001 // SPDX-FileCopyrightText: 2021 Alexey Andreyev <aa13q@ya.ru> 0002 // 0003 // SPDX-License-Identifier: LicenseRef-KDE-Accepted-GPL 0004 0005 #include "contact-utils.h" 0006 0007 #include <KPeople/PersonData> 0008 #include <QSharedPointer> 0009 0010 #include "contact-phone-number-mapper.h" 0011 0012 static QSharedPointer<KPeople::PersonData> contactData(const QString &contact) 0013 { 0014 const QString uri = ContactPhoneNumberMapper::instance().uriForNumber(contact); 0015 return QSharedPointer<KPeople::PersonData>(new KPeople::PersonData(uri)); 0016 } 0017 0018 ContactUtils::ContactUtils(QObject *parent) 0019 : QObject(parent) 0020 { 0021 } 0022 0023 QString ContactUtils::displayString(const QString &contact) 0024 { 0025 auto person = contactData(contact); 0026 const QString name = person->name(); 0027 if (!name.isEmpty()) { 0028 return name; 0029 } 0030 return contact; 0031 } 0032 0033 QString ContactUtils::imageSource(const QString &contact) 0034 { 0035 auto person = contactData(contact); 0036 // TODO: implement photo sharing via image source 0037 return QString(); 0038 } 0039 0040 void ContactUtils::changeCountryCode(const QString &countryCode) 0041 { 0042 ContactPhoneNumberMapper::instance().changeCountry(countryCode); 0043 }