File indexing completed on 2024-05-12 07:52:03
0001 /* 0002 SPDX-FileCopyrightText: 2013 David Edmundson <davidedmundson@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #ifndef METACONTACT_H 0008 #define METACONTACT_H 0009 0010 #include "backends/abstractcontact.h" 0011 #include <QSharedDataPointer> 0012 0013 #include <kpeople/kpeople_export.h> 0014 0015 namespace KPeople 0016 { 0017 class MetaContactData; 0018 0019 class MetaContact 0020 { 0021 public: 0022 MetaContact(); 0023 0024 /** Create a 'MetaContact' from a single contact*/ 0025 MetaContact(const QString &contactUri, const AbstractContact::Ptr &contact); 0026 0027 /** Create a MetaContact with a given person ID and a map of all associated contacts*/ 0028 MetaContact(const QString &personUri, const QMap<QString, AbstractContact::Ptr> &contacts); 0029 MetaContact(const MetaContact &other); 0030 ~MetaContact(); 0031 0032 MetaContact &operator=(const MetaContact &other); 0033 0034 QString id() const; 0035 bool isValid() const; 0036 0037 QStringList contactUris() const; 0038 AbstractContact::List contacts() const; 0039 0040 AbstractContact::Ptr contact(const QString &contactUri); 0041 const AbstractContact::Ptr &personAddressee() const; 0042 0043 // update one of the stored contacts in this metacontact object 0044 //@return the index of the contact which was inserted 0045 0046 int insertContact(const QString &contactUri, const AbstractContact::Ptr &contact); 0047 0048 int updateContact(const QString &contactUri, const AbstractContact::Ptr &contact); 0049 0050 int removeContact(const QString &contactUri); 0051 0052 private: 0053 // does the real inserting contacts. Split so that we don't call the expensive "reload" function 0054 // multiple times at startup 0055 int insertContactInternal(const QString &contactUri, const AbstractContact::Ptr &contact); 0056 0057 void reload(); 0058 0059 QSharedDataPointer<MetaContactData> d; 0060 }; 0061 } 0062 0063 Q_DECLARE_TYPEINFO(KPeople::MetaContact, Q_RELOCATABLE_TYPE); 0064 0065 #endif // METACONTACT_H