CalendarSupport

freeperiodmodel.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 <KCalendarCore/Period>
13
14#include <QAbstractTableModel>
15
16namespace CalendarSupport
17{
18/// Model representing the free-busy periods
19class CALENDARSUPPORT_EXPORT FreePeriodModel : public QAbstractTableModel
20{
21 Q_OBJECT
22public:
23 enum Roles {
24 PeriodRole = Qt::UserRole
25 };
26 explicit FreePeriodModel(QObject *parent = nullptr);
27 ~FreePeriodModel() override;
28
29 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
30 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
31 [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
32 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
33
34public Q_SLOTS:
35 void slotNewFreePeriods(const KCalendarCore::Period::List &freePeriods);
36
37private:
38 /** Splits period blocks in the provided list, so that each period occurs on one day */
39 [[nodiscard]] KCalendarCore::Period::List splitPeriodsByDay(const KCalendarCore::Period::List &freePeriods);
40
41 [[nodiscard]] CALENDARSUPPORT_NO_EXPORT QString day(int index) const;
42 [[nodiscard]] CALENDARSUPPORT_NO_EXPORT QString date(int index) const;
43 [[nodiscard]] CALENDARSUPPORT_NO_EXPORT QString stringify(int index) const;
44 [[nodiscard]] CALENDARSUPPORT_NO_EXPORT QString tooltipify(int index) const;
45
47 friend class FreePeriodModelTest;
48};
49}
Model representing the free-busy periods.
UserRole
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:07:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.