KPeople

declarativepersondata.cpp
1 /*
2  SPDX-FileCopyrightText: 2013 David Edmundson <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6 
7 #include "declarativepersondata.h"
8 
9 #include "../persondata.h"
10 #include "avatarimageprovider.h"
11 #include "kpeople_debug.h"
12 #include <imageprovideruri_p.h>
13 
14 #include <QStringBuilder>
15 
16 DeclarativePersonData::DeclarativePersonData(QObject *parent)
17  : QObject(parent)
18  , m_person(nullptr)
19 {
20  connect(this, &DeclarativePersonData::personChanged, this, &DeclarativePersonData::photoImageProviderUriChanged);
21 }
22 
23 void DeclarativePersonData::setPersonUri(const QString &id)
24 {
25  if (id == m_id) {
26  return;
27  }
28 
29  m_id = id;
30  delete m_person;
31  if (m_id.isEmpty()) {
32  m_person = nullptr;
33  } else {
34  m_person = new KPeople::PersonData(id, this);
35  connect(m_person, &KPeople::PersonData::dataChanged, this, &DeclarativePersonData::photoImageProviderUriChanged);
36  }
37 
38  Q_EMIT personChanged();
39 }
40 
41 KPeople::PersonData *DeclarativePersonData::person() const
42 {
43  return m_person;
44 }
45 
46 QString DeclarativePersonData::photoImageProviderUri() const
47 {
48  return ::photoImageProviderUri(m_id);
49 }
50 
51 QString DeclarativePersonData::personUri() const
52 {
53  return m_id;
54 }
55 
56 #include "moc_declarativepersondata.cpp"
Allows to query the information about a given person.
Definition: persondata.h:34
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void dataChanged()
One of the contact sources has changed.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Sep 26 2023 04:06:46 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.