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 { PeriodRole = Qt::UserRole };
24 explicit FreePeriodModel(QObject *parent = nullptr);
25 ~FreePeriodModel() override;
26
27 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
28 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
29 [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
30 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
31
32public Q_SLOTS:
33 void slotNewFreePeriods(const KCalendarCore::Period::List &freePeriods);
34
35private:
36 /** Splits period blocks in the provided list, so that each period occurs on one day */
37 [[nodiscard]] KCalendarCore::Period::List splitPeriodsByDay(const KCalendarCore::Period::List &freePeriods);
38
39 [[nodiscard]] CALENDARSUPPORT_NO_EXPORT QString day(int index) const;
40 [[nodiscard]] CALENDARSUPPORT_NO_EXPORT QString date(int index) const;
41 [[nodiscard]] CALENDARSUPPORT_NO_EXPORT QString stringify(int index) const;
42 [[nodiscard]] CALENDARSUPPORT_NO_EXPORT QString tooltipify(int index) const;
43
45 friend class FreePeriodModelTest;
46};
47}
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 Oct 4 2024 12:05:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.