MauiKit Calendar

attendeesmodel.h
1// SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com>
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <KCalendarCore/Calendar>
7#include <QAbstractListModel>
8#include <QDebug>
9/**
10 *
11 */
12class AttendeeStatusModel : public QAbstractListModel
13{
15
16public:
17 enum Roles {
18 DisplayNameRole = Qt::UserRole + 1,
19 ValueRole,
20 };
21 Q_ENUM(Roles);
22
23 explicit AttendeeStatusModel(QObject *parent = nullptr);
24 ~AttendeeStatusModel() override = default;
25
26 QVariant data(const QModelIndex &idx, int role) const override;
27 QHash<int, QByteArray> roleNames() const override;
28 int rowCount(const QModelIndex &parent = {}) const override;
29
30private:
31 QHash<int, QString> m_status;
32};
33
34class AttendeesModel : public QAbstractListModel
35{
37 Q_PROPERTY(KCalendarCore::Incidence::Ptr incidencePtr READ incidencePtr WRITE setIncidencePtr NOTIFY incidencePtrChanged)
38 Q_PROPERTY(KCalendarCore::Attendee::List attendees READ attendees NOTIFY attendeesChanged)
39 Q_PROPERTY(AttendeeStatusModel *attendeeStatusModel READ attendeeStatusModel NOTIFY attendeeStatusModelChanged)
40 Q_PROPERTY(QList<qint64> attendeesAkonadiIds READ attendeesAkonadiIds NOTIFY attendeesAkonadiIdsChanged)
41
42public:
43 enum Roles {
44 CuTypeRole = Qt::UserRole + 1,
45 DelegateRole,
46 DelegatorRole,
47 EmailRole,
48 FullNameRole,
49 IsNullRole,
50 NameRole,
51 RoleRole,
52 RSVPRole,
53 StatusRole,
54 UidRole
55 };
56 Q_ENUM(Roles);
57
58 explicit AttendeesModel(QObject *parent = nullptr, KCalendarCore::Incidence::Ptr incidencePtr = nullptr);
59 ~AttendeesModel() override = default;
60
61 KCalendarCore::Incidence::Ptr incidencePtr() const;
62 void setIncidencePtr(const KCalendarCore::Incidence::Ptr incidence);
63 KCalendarCore::Attendee::List attendees() const;
64 void updateAkonadiContactIds();
65 AttendeeStatusModel *attendeeStatusModel();
66 QList<qint64> attendeesAkonadiIds() const;
67
68 QVariant data(const QModelIndex &idx, int role) const override;
69 bool setData(const QModelIndex &idx, const QVariant &value, int role) override;
70 QHash<int, QByteArray> roleNames() const override;
71 int rowCount(const QModelIndex &parent = {}) const override;
72
73 Q_INVOKABLE void addAttendee(qint64 itemId = qint64(), const QString &email = QString());
74 Q_INVOKABLE void deleteAttendee(int row);
75 Q_INVOKABLE void deleteAttendeeFromAkonadiId(qint64 itemId);
76
78 void incidencePtrChanged();
79 void attendeesChanged();
80 void attendeeStatusModelChanged();
81 void attendeesAkonadiIdsChanged();
82
83private:
85 AttendeeStatusModel m_attendeeStatusModel;
86 QList<qint64> m_attendeesAkonadiIds;
87 QVariantMap m_dataRoles;
88};
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.