File indexing completed on 2024-05-05 16:16:34
0001 /* 0002 Abstract class to load a monitor changes for a single contact 0003 SPDX-FileCopyrightText: 2013 David Edmundson <davidedmundson@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #ifndef CONTACTMONITOR_H 0009 #define CONTACTMONITOR_H 0010 0011 #include <QObject> 0012 0013 #include <kpeoplebackend/kpeoplebackend_export.h> 0014 0015 #include "abstractcontact.h" 0016 0017 namespace KPeople 0018 { 0019 class ContactMonitorPrivate; 0020 0021 /** 0022 * This class loads data for a single contact from a datasource. 0023 * 0024 * Datasources should subclass this and call setContact() when the contact loads or changes. 0025 * It is used for optimising performance over loading all contacts and filtering the results. 0026 * Subclasses are expected to be asynchronous in loading data. 0027 * 0028 * @since 5.8 0029 */ 0030 class KPEOPLEBACKEND_EXPORT ContactMonitor : public QObject 0031 { 0032 Q_OBJECT 0033 public: 0034 ContactMonitor(const QString &contactUri); 0035 ~ContactMonitor() override; 0036 0037 /** 0038 * The ID of the contact being loaded 0039 */ 0040 QString contactUri() const; 0041 0042 /** 0043 * The currently loaded information on this contact. 0044 */ 0045 AbstractContact::Ptr contact() const; 0046 Q_SIGNALS: 0047 /** 0048 * Emitted whenever the contact changes 0049 */ 0050 void contactChanged(); 0051 0052 protected: 0053 /** 0054 * Sets or updates the contact and emits contactChanged 0055 * Subclasses should call this when data is loaded or changes 0056 */ 0057 void setContact(const AbstractContact::Ptr &contact); 0058 0059 private: 0060 Q_DISABLE_COPY(ContactMonitor) 0061 Q_DECLARE_PRIVATE(ContactMonitor) 0062 ContactMonitorPrivate *d_ptr; 0063 }; 0064 0065 } 0066 typedef QSharedPointer<KPeople::ContactMonitor> ContactMonitorPtr; 0067 0068 #endif // CONTACTMONITOR_H