VcardModel.hpp 2.07 KB
Newer Older
Ronan Abhamon's avatar
Ronan Abhamon committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#ifndef VCARD_MODEL_H_
#define VCARD_MODEL_H_

#include <linphone++/linphone.hh>
#include <QObject>

// =============================================================================

class VcardModel : public QObject {
  Q_OBJECT;

  Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY vcardUpdated);
  Q_PROPERTY(QString avatar READ getAvatar WRITE setAvatar NOTIFY vcardUpdated);
  Q_PROPERTY(QVariantMap address READ getAddress WRITE setAddress NOTIFY vcardUpdated);
  Q_PROPERTY(QVariantList sipAddresses READ getSipAddresses NOTIFY vcardUpdated);
  Q_PROPERTY(QVariantList companies READ getCompanies NOTIFY vcardUpdated);
  Q_PROPERTY(QVariantList emails READ getEmails NOTIFY vcardUpdated);
  Q_PROPERTY(QVariantList urls READ getUrls NOTIFY vcardUpdated);

20
  friend class ContactModel;
Ronan Abhamon's avatar
Ronan Abhamon committed
21 22 23 24 25 26

public:
  VcardModel (std::shared_ptr<linphone::Vcard> vcard) : m_vcard(vcard) {}

  ~VcardModel () = default;

27 28
  QString getUsername () const;

Ronan Abhamon's avatar
Ronan Abhamon committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
public slots:
  bool addSipAddress (const QString &sip_address);
  void removeSipAddress (const QString &sip_address);
  bool updateSipAddress (const QString &old_sip_address, const QString &sip_address);

  bool addCompany (const QString &company);
  void removeCompany (const QString &company);
  bool updateCompany (const QString &old_company, const QString &company);

  bool addEmail (const QString &email);
  void removeEmail (const QString &email);
  bool updateEmail (const QString &old_email, const QString &email);

  bool addUrl (const QString &url);
  void removeUrl (const QString &url);
  bool updateUrl (const QString &old_url, const QString &url);

signals:
  void vcardUpdated ();

private:
  void setUsername (const QString &username);

  QString getAvatar () const;
53
  bool setAvatar (const QString &path);
Ronan Abhamon's avatar
Ronan Abhamon committed
54 55

  QVariantMap getAddress () const;
56
  bool setAddress (const QVariantMap &address);
Ronan Abhamon's avatar
Ronan Abhamon committed
57 58 59 60 61 62 63 64 65 66 67 68

  QVariantList getSipAddresses () const;
  QVariantList getCompanies () const;
  QVariantList getEmails () const;
  QVariantList getUrls () const;

  std::shared_ptr<linphone::Vcard> m_vcard;
};

Q_DECLARE_METATYPE(VcardModel *);

#endif // VCARD_MODEL_H_