• Skip to content
  • Skip to link menu
KDE API Documentation - basepersonsdatasource.cpp Source File (KPeople)
  • KDE Home
  • Contact Us
 

KPeople

  • frameworks
  • kpeople
  • src
  • backends
basepersonsdatasource.cpp
1 /*
2  Copyright (C) 2013 Martin Klapetek <mklapetek@kde.org>
3  Copyright (C) 2013 David Edmundson <davidedmundson@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 #include "basepersonsdatasource.h"
21 
22 #include <QDebug>
23 
24 #include "backends/abstractcontact.h"
25 #include "defaultcontactmonitor_p.h"
26 
27 using namespace KPeople;
28 
29 class KPeople::BasePersonsDataSourcePrivate
30 {
31 public:
32  QWeakPointer<AllContactsMonitor> m_allContactsMonitor;
33  QHash<QString, QWeakPointer<ContactMonitor> > m_contactMonitors;
34 };
35 
36 BasePersonsDataSource::BasePersonsDataSource(QObject *parent, const QVariantList &args)
37  : QObject(parent),
38  d_ptr(new BasePersonsDataSourcePrivate)
39 {
40  Q_UNUSED(args)
41 }
42 
43 BasePersonsDataSource::~BasePersonsDataSource()
44 {
45  delete d_ptr;
46 }
47 
48 AllContactsMonitorPtr BasePersonsDataSource::allContactsMonitor()
49 {
50  Q_D(BasePersonsDataSource);
51 
52  //if there is currently no watcher, create one
53  AllContactsMonitorPtr c;
54  if (!d->m_allContactsMonitor.toStrongRef()) {
55  c = AllContactsMonitorPtr(createAllContactsMonitor());
56  d->m_allContactsMonitor = c;
57  }
58 
59  return d->m_allContactsMonitor.toStrongRef();
60 }
61 
62 ContactMonitorPtr BasePersonsDataSource::contactMonitor(const QString &contactUri)
63 {
64  Q_D(BasePersonsDataSource);
65 
66  ContactMonitorPtr c;
67  if (!d->m_contactMonitors[contactUri].toStrongRef()) {
68  c = ContactMonitorPtr(createContactMonitor(contactUri));
69  d->m_contactMonitors[contactUri] = c;
70  }
71  return d->m_contactMonitors[contactUri].toStrongRef();
72 }
73 
74 ContactMonitor *BasePersonsDataSource::createContactMonitor(const QString &contactUri)
75 {
76  return new DefaultContactMonitor(contactUri, allContactsMonitor());
77 }
KPeople::ContactMonitor
This class loads data for a single contact from a datasource.
Definition: contactmonitor.h:42
KPeople
The KPeople namespace contains all the classes for Libkpeople.
This file is part of the KDE documentation.
Documentation copyright © 1996-2015 The KDE developers.
Generated on Fri Feb 13 2015 15:16:39 by doxygen 1.8.9.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KPeople

Skip menu "KPeople"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List

Class Picker

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal