1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/*
Copyright (C) 2013 David Edmundson <davidedmundson@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef METACONTACT_H
#define METACONTACT_H
#include <QSharedDataPointer>
#include "backends/abstractcontact.h"
#include <kpeople/kpeople_export.h>
namespace KPeople
{
class MetaContactData;
class MetaContact
{
public:
MetaContact();
/** Create a 'MetaContact' from a single contact*/
MetaContact(const QString &contactUri, const AbstractContact::Ptr &contact);
/** Create a MetaContact with a given person ID and a map of all associated contacts*/
MetaContact(const QString &personUri, const QMap<QString, AbstractContact::Ptr> &contacts);
MetaContact(const MetaContact &other);
~MetaContact();
MetaContact &operator=(const MetaContact &other);
QString id() const;
bool isValid() const;
QStringList contactUris() const;
AbstractContact::List contacts() const;
AbstractContact::Ptr contact(const QString &contactUri);
const AbstractContact::Ptr &personAddressee() const;
//update one of the stored contacts in this metacontact object
//@return the index of the contact which was inserted
int insertContact(const QString &contactUri, const AbstractContact::Ptr &contact);
int updateContact(const QString &contactUri, const AbstractContact::Ptr &contact);
int removeContact(const QString &contactUri);
private:
//does the real inserting contacts. Split so that we don't call the expensive "reload" function
//multiple times at startup
int insertContactInternal(const QString &contactUri, const AbstractContact::Ptr &contact);
void reload();
QSharedDataPointer<MetaContactData> d;
};
}
Q_DECLARE_TYPEINFO(KPeople::MetaContact, Q_MOVABLE_TYPE);
#endif // METACONTACT_H
|