File indexing completed on 2025-01-05 04:47:39

0001 /*
0002   SPDX-FileCopyrightText: 2000, 2001, 2004 Cornelius Schumacher <schumacher@kde.org>
0003   SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
0004   SPDX-FileCopyrightText: 2010 Andras Mantia <andras@kdab.com>
0005   SPDX-FileCopyrightText: 2010 Casey Link <casey@kdab.com>
0006 
0007   SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include "calendarsupport_export.h"
0013 
0014 #include <KCalendarCore/FreeBusy>
0015 
0016 namespace CalendarSupport
0017 {
0018 /**
0019  * The FreeBusyItem is the whole line for a given attendee..
0020  */
0021 class CALENDARSUPPORT_EXPORT FreeBusyItem
0022 {
0023 public:
0024     using Ptr = QSharedPointer<FreeBusyItem>;
0025 
0026     /**
0027      * @param parentWidget is passed to Akonadi when fetching free/busy data.
0028      */
0029     FreeBusyItem(const KCalendarCore::Attendee &attendee, QWidget *parentWidget);
0030     ~FreeBusyItem() = default;
0031 
0032     KCalendarCore::Attendee attendee() const;
0033     void setFreeBusy(const KCalendarCore::FreeBusy::Ptr &fb);
0034     KCalendarCore::FreeBusy::Ptr freeBusy() const;
0035 
0036     [[nodiscard]] QString email() const;
0037     void setUpdateTimerID(int id);
0038     [[nodiscard]] int updateTimerID() const;
0039 
0040     void startDownload(bool forceDownload);
0041     void setIsDownloading(bool d);
0042     [[nodiscard]] bool isDownloading() const;
0043 
0044 Q_SIGNALS:
0045     void attendeeChanged(const KCalendarCore::Attendee &attendee);
0046     void freebusyChanged(const KCalendarCore::FreeBusy::Ptr fb);
0047 
0048 private:
0049     const KCalendarCore::Attendee mAttendee;
0050     KCalendarCore::FreeBusy::Ptr mFreeBusy;
0051 
0052     // This is used for the update timer
0053     int mTimerID = 0;
0054 
0055     // Only run one download job at a time
0056     bool mIsDownloading = false;
0057 
0058     QWidget *const mParentWidget;
0059 };
0060 }