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

KPeople

  • frameworks
  • kpeople
  • src
  • backends
defaultcontactmonitor.cpp
1 /*
2  Abstract class to load a monitor changes for a single contact
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 "defaultcontactmonitor_p.h"
21 
22 DefaultContactMonitor::DefaultContactMonitor(const QString &contactUri, const AllContactsMonitorPtr &allContactsWatcher):
23  ContactMonitor(contactUri),
24  m_allContactsMonitor(allContactsWatcher)
25 {
26  connect(allContactsWatcher.data(), SIGNAL(contactAdded(QString,AbstractContact::Ptr)), SLOT(onContactAdded(QString,AbstractContact::Ptr)));
27  connect(allContactsWatcher.data(), SIGNAL(contactRemoved(QString)), SLOT(onContactRemoved(QString)));
28  connect(allContactsWatcher.data(), SIGNAL(contactChanged(QString,AbstractContact::Ptr)), SLOT(onContactChanged(QString,AbstractContact::Ptr)));
29 
30  const QMap<QString, AbstractContact::Ptr> &contacts = m_allContactsMonitor->contacts();
31  QMap<QString, AbstractContact::Ptr>::const_iterator it = contacts.constFind(contactUri);
32  if (it != contacts.constEnd()) {
33  setContact(it.value());
34  }
35 }
36 
37 void DefaultContactMonitor::onContactAdded(const QString &id, const AbstractContact::Ptr &contact)
38 {
39  if (id == contactUri()) {
40  setContact(contact);
41  }
42 }
43 
44 void DefaultContactMonitor::onContactChanged(const QString &id, const AbstractContact::Ptr &contact)
45 {
46  if (id == contactUri()) {
47  setContact(contact);
48  }
49 }
50 
51 void DefaultContactMonitor::onContactRemoved(const QString &id)
52 {
53  if (id == contactUri()) {
54  setContact(AbstractContact::Ptr());
55  }
56 }
57 
58 #include "defaultcontactmonitor.moc"
KPeople::ContactMonitor::setContact
void setContact(const AbstractContact::Ptr &contact)
Sets or updates the contact and emits contactChanged Subclasses should call this when data is loaded ...
Definition: contactmonitor.cpp:44
KPeople::ContactMonitor::contactChanged
void contactChanged()
Emitted whenever the contact changes.
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