ContactsListModel.hpp 1.15 KB
Newer Older
Ronan Abhamon's avatar
Ronan Abhamon committed
1 2
#ifndef CONTACTS_LIST_MODEL_H_
#define CONTACTS_LIST_MODEL_H_
3 4

#include <QAbstractListModel>
5
#include <linphone++/linphone.hh>
6

7
class ContactModel;
8 9

// ===================================================================
10

11
class ContactsListModel : public QAbstractListModel {
12 13
  friend class ContactsListProxyModel;

14 15 16 17 18
  Q_OBJECT;

public:
  ContactsListModel (QObject *parent = Q_NULLPTR);

19
  int rowCount (const QModelIndex &index = QModelIndex()) const {
Ronan Abhamon's avatar
Ronan Abhamon committed
20 21 22
    return m_list.count();
  }

23 24 25
  QHash<int, QByteArray> roleNames () const;
  QVariant data (const QModelIndex &index, int role) const;

26 27 28
  bool removeRow (int row, const QModelIndex &parent = QModelIndex());
  bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex());

29
public slots:
30 31
  // See: http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership
  // The returned value must have a explicit parent or a QQmlEngine::CppOwnership.
32
  ContactModel *mapSipAddressToContact (const QString &sipAddress) const;
33

34 35
  void removeContact (ContactModel *contact);

36 37
private:
  QList<ContactModel *> m_list;
Ronan Abhamon's avatar
Ronan Abhamon committed
38
  std::shared_ptr<linphone::FriendList> m_linphone_friends;
39 40
};

Ronan Abhamon's avatar
Ronan Abhamon committed
41
#endif // CONTACTS_LIST_MODEL_H_