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 { AttendeeRole = Qt::UserRole, FreeBusyRole, FreeBusyPeriodRole };
36
37 explicit FreeBusyItemModel(QObject *parent = nullptr);
38 ~FreeBusyItemModel() override;
39
40 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
41 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
42 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
43 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
44 QModelIndex parent(const QModelIndex &child) const override;
45 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
46
47 void addItem(const FreeBusyItem::Ptr &freebusy);
48
49 void clear();
50 void removeAttendee(const KCalendarCore::Attendee &attendee);
51 void removeItem(const FreeBusyItem::Ptr &freebusy);
52 void removeRow(int row);
53
54 [[nodiscard]] bool containsAttendee(const KCalendarCore::Attendee &attendee);
55
56 /**
57 * Queues a reload of free/busy data.
58 * All current attendees will have their free/busy data
59 * redownloaded from Akonadi.
60 */
61 void triggerReload();
62
63 /**
64 * cancel reloading
65 */
66 void cancelReload();
67
68 /**
69 * Reload FB items
70 */
71 void reload();
72
73public Q_SLOTS:
74 void slotInsertFreeBusy(const KCalendarCore::FreeBusy::Ptr &fb, const QString &email);
75
76protected:
77 void timerEvent(QTimerEvent *) override;
78
79private:
80 // Only download FB if the auto-download option is set in config
81 CALENDARSUPPORT_NO_EXPORT void autoReload();
82
83 CALENDARSUPPORT_NO_EXPORT void setFreeBusyPeriods(const QModelIndex &parent, const KCalendarCore::FreeBusyPeriod::List &list);
84 CALENDARSUPPORT_NO_EXPORT void updateFreeBusyData(const FreeBusyItem::Ptr &);
85
86 std::unique_ptr<FreeBusyItemModelPrivate> const d;
87};
88}
KGuiItem clear()
const QList< QKeySequence > & reload()
UserRole
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:16:32 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.