/
calendarcontactmodel.h
45 lines (33 loc) · 1.11 KB
/
calendarcontactmodel.h
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
#ifndef CALENDARCONTACTMODEL_H
#define CALENDARCONTACTMODEL_H
#include <QAbstractListModel>
#include "calendardata.h"
class CalendarContactModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
enum ContactRoles {
NameRole = Qt::UserRole,
EmailRole
};
explicit CalendarContactModel(QObject *parent = nullptr);
virtual ~CalendarContactModel();
int rowCount(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const;
int count() const;
Q_INVOKABLE void append(const QString &name, const QString &email);
Q_INVOKABLE void prepend(const QString &name, const QString &email);
Q_INVOKABLE void remove(int index);
Q_INVOKABLE bool hasEmail(const QString &email) const;
Q_INVOKABLE QString name(int index) const;
Q_INVOKABLE QString email(int index) const;
QList<CalendarData::EmailContact> getList();
signals:
void countChanged();
protected:
virtual QHash<int, QByteArray> roleNames() const;
private:
QList<CalendarData::EmailContact> m_contacts;
};
#endif