KPeople

basepersonsdatasource.cpp
1/*
2 SPDX-FileCopyrightText: 2013 Martin Klapetek <mklapetek@kde.org>
3 SPDX-FileCopyrightText: 2013 David Edmundson <davidedmundson@kde.org>
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
13using namespace KPeople;
14
15class KPeople::BasePersonsDataSourcePrivate
16{
17public:
18 QWeakPointer<AllContactsMonitor> m_allContactsMonitor;
20};
21
22BasePersonsDataSource::BasePersonsDataSource(QObject *parent, const QVariantList &args)
23 : QObject(parent)
24 , d_ptr(new BasePersonsDataSourcePrivate)
25{
26 Q_UNUSED(args)
27}
28
29BasePersonsDataSource::~BasePersonsDataSource()
30{
31 delete d_ptr;
32}
33
34AllContactsMonitorPtr 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
48ContactMonitorPtr 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
60ContactMonitor *BasePersonsDataSource::createContactMonitor(const QString &contactUri)
61{
62 return new DefaultContactMonitor(contactUri, allContactsMonitor());
63}
64
65BasePersonsDataSourceV2::BasePersonsDataSourceV2(QObject *parent, const QVariantList &args)
66 : BasePersonsDataSource(parent, args)
67{
68}
69
70#include "moc_basepersonsdatasource.cpp"
This class loads data for a single contact from a datasource.
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.