KPeople

basepersonsdatasource.cpp
1 /*
2  SPDX-FileCopyrightText: 2013 Martin Klapetek <[email protected]>
3  SPDX-FileCopyrightText: 2013 David Edmundson <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7 
8 #include "basepersonsdatasource.h"
9 
10 #include "backends/abstractcontact.h"
11 #include "defaultcontactmonitor_p.h"
12 
13 using namespace KPeople;
14 
15 class KPeople::BasePersonsDataSourcePrivate
16 {
17 public:
18  QWeakPointer<AllContactsMonitor> m_allContactsMonitor;
20 };
21 
22 BasePersonsDataSource::BasePersonsDataSource(QObject *parent, const QVariantList &args)
23  : QObject(parent)
24  , d_ptr(new BasePersonsDataSourcePrivate)
25 {
26  Q_UNUSED(args)
27 }
28 
29 BasePersonsDataSource::~BasePersonsDataSource()
30 {
31  delete d_ptr;
32 }
33 
34 AllContactsMonitorPtr BasePersonsDataSource::allContactsMonitor()
35 {
36  Q_D(BasePersonsDataSource);
37 
38  // if there is currently no watcher, create one
39  AllContactsMonitorPtr c = d->m_allContactsMonitor.toStrongRef();
40  if (!c) {
41  c = AllContactsMonitorPtr(createAllContactsMonitor());
42  d->m_allContactsMonitor = c;
43  }
44 
45  return c;
46 }
47 
48 ContactMonitorPtr BasePersonsDataSource::contactMonitor(const QString &contactUri)
49 {
50  Q_D(BasePersonsDataSource);
51 
52  ContactMonitorPtr c = d->m_contactMonitors[contactUri].toStrongRef();
53  if (!c) {
54  c = ContactMonitorPtr(createContactMonitor(contactUri));
55  d->m_contactMonitors[contactUri] = c;
56  }
57  return c;
58 }
59 
60 ContactMonitor *BasePersonsDataSource::createContactMonitor(const QString &contactUri)
61 {
62  return new DefaultContactMonitor(contactUri, allContactsMonitor());
63 }
64 
65 BasePersonsDataSourceV2::BasePersonsDataSourceV2(QObject *parent, const QVariantList &args)
66  : BasePersonsDataSource(parent, args)
67 {
68 }
This class loads data for a single contact from a datasource.
Q_D(Todo)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jan 27 2022 22:42:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.