CalendarSupport

freebusyitemmodel.h
1/*
2 SPDX-FileCopyrightText: 2010 Casey Link <unnamedrambler@gmail.com>
3 SPDX-FileCopyrightText: 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#pragma once
9
10#include "calendarsupport_export.h"
11
12#include "freebusyitem.h"
13
14#include <QAbstractItemModel>
15#include <QTimer>
16
17#include <memory>
18
19class ItemPrivateData;
20
21namespace CalendarSupport
22{
23/**
24 * The FreeBusyItemModel is a 2-level tree structure.
25 *
26 * The top level parent nodes represent the freebusy items, and
27 * the 2nd-level child nodes represent the FreeBusyPeriods of the parent
28 * freebusy item.
29 */
30class FreeBusyItemModelPrivate;
31class CALENDARSUPPORT_EXPORT FreeBusyItemModel : public QAbstractItemModel
32{
33 Q_OBJECT
34public:
35 enum Roles {
36 AttendeeRole = Qt::UserRole,
37 FreeBusyRole,
38 FreeBusyPeriodRole
39 };
40
41 explicit FreeBusyItemModel(QObject *parent = nullptr);
42 ~FreeBusyItemModel() override;
43
44 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
45 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
46 [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
47 [[nodiscard]] QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
48 [[nodiscard]] QModelIndex parent(const QModelIndex &child) const override;
49 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
50
51 void addItem(const FreeBusyItem::Ptr &freebusy);
52
53 void clear();
54 void removeAttendee(const KCalendarCore::Attendee &attendee);
55 void removeItem(const FreeBusyItem::Ptr &freebusy);
56 void removeRow(int row);
57
58 [[nodiscard]] bool containsAttendee(const KCalendarCore::Attendee &attendee);
59
60 /**
61 * Queues a reload of free/busy data.
62 * All current attendees will have their free/busy data
63 * redownloaded from Akonadi.
64 */
65 void triggerReload();
66
67 /**
68 * cancel reloading
69 */
70 void cancelReload();
71
72 /**
73 * Reload FB items
74 */
75 void reload();
76
77public Q_SLOTS:
78 void slotInsertFreeBusy(const KCalendarCore::FreeBusy::Ptr &fb, const QString &email);
79
80protected:
81 void timerEvent(QTimerEvent *) override;
82
83private:
84 // Only download FB if the auto-download option is set in config
85 CALENDARSUPPORT_NO_EXPORT void autoReload();
86
87 CALENDARSUPPORT_NO_EXPORT void setFreeBusyPeriods(const QModelIndex &parent, const KCalendarCore::FreeBusyPeriod::List &list);
88 CALENDARSUPPORT_NO_EXPORT void updateFreeBusyData(const FreeBusyItem::Ptr &);
89
90 std::unique_ptr<FreeBusyItemModelPrivate> const d;
91};
92}
const QList< QKeySequence > & reload()
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.