CalendarSupport

incidenceattachmentmodel.h
1/*
2 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
3 Author: Stephen Kelly <stephen@kdab.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#pragma once
9
10#include <Akonadi/Attribute>
11#include <Akonadi/Item>
12
13#include <KCalendarCore/Incidence>
14
15#include <QAbstractListModel>
16
17#include <memory>
18
19namespace Akonadi
20{
21}
22
23namespace CalendarSupport
24{
25class IncidenceAttachmentModelPrivate;
26
27class IncidenceAttachmentModel : public QAbstractListModel
28{
30 Q_PROPERTY(int attachmentCount READ rowCount NOTIFY rowCountChanged)
31
32public:
33 enum Roles {
34 AttachmentDataRole = Qt::UserRole,
35 MimeTypeRole,
36 AttachmentCountRole,
37
38 UserRole = Qt::UserRole + 100
39 };
40
41 explicit IncidenceAttachmentModel(const QPersistentModelIndex &modelIndex, QObject *parent = nullptr);
42
43 explicit IncidenceAttachmentModel(const Akonadi::Item &item, QObject *parent = nullptr);
44
45 explicit IncidenceAttachmentModel(QObject *parent = nullptr);
46
47 ~IncidenceAttachmentModel() override;
48
49 KCalendarCore::Incidence::Ptr incidence() const;
50
51 void setItem(const Akonadi::Item &item);
52 void setIndex(const QPersistentModelIndex &modelIndex);
53
54 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
55
56 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
57
58 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
59 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
60
62 void rowCountChanged();
63
64private:
65 Q_DECLARE_PRIVATE(IncidenceAttachmentModel)
66 std::unique_ptr<IncidenceAttachmentModelPrivate> const d_ptr;
67
68 Q_PRIVATE_SLOT(d_func(), void resetModel())
69 Q_PRIVATE_SLOT(d_func(), void itemFetched(Akonadi::Item::List))
70};
71}
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
UserRole
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.