MauiKit Calendar

attachmentsmodel.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 <QMimeDatabase>
9
10class AttachmentsModel : public QAbstractListModel
11{
13 Q_PROPERTY(KCalendarCore::Incidence::Ptr incidencePtr READ incidencePtr WRITE setIncidencePtr NOTIFY incidencePtrChanged)
14 Q_PROPERTY(KCalendarCore::Attachment::List attachments READ attachments NOTIFY attachmentsChanged)
15 Q_PROPERTY(QVariantMap dataroles READ dataroles CONSTANT)
16
17public:
18 enum Roles {
19 AttachmentRole = Qt::UserRole + 1,
20 LabelRole,
21 MimeTypeRole,
22 IconNameRole,
23 DataRole,
24 SizeRole,
25 URIRole,
26 };
27 Q_ENUM(Roles);
28
29 explicit AttachmentsModel(QObject *parent = nullptr, KCalendarCore::Incidence::Ptr incidencePtr = nullptr);
30 ~AttachmentsModel() override = default;
31
32 KCalendarCore::Incidence::Ptr incidencePtr();
33 void setIncidencePtr(KCalendarCore::Incidence::Ptr incidence);
35 QVariantMap dataroles();
36
37 QVariant data(const QModelIndex &idx, int role) const override;
38 QHash<int, QByteArray> roleNames() const override;
39 int rowCount(const QModelIndex &parent = {}) const override;
40
41 Q_INVOKABLE void addAttachment(const QString &uri);
42 Q_INVOKABLE void deleteAttachment(const QString &uri);
43
45 void incidencePtrChanged();
46 void attachmentsChanged();
47
48private:
50 QVariantMap m_dataRoles;
51 QMimeDatabase m_mimeDb;
52};
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
T qobject_cast(QObject *object)
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:50:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.