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

0001 /*
0002   This file is part of KOrganizer.
0003 
0004   SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org>
0005 
0006   SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0007 */
0008 #pragma once
0009 
0010 #include "eventview.h"
0011 
0012 #include <Akonadi/IncidenceChanger>
0013 
0014 #include <KIconLoader>
0015 
0016 #include <QTextBrowser>
0017 #include <QUrl>
0018 
0019 namespace EventViews
0020 {
0021 class WhatsNextTextBrowser : public QTextBrowser
0022 {
0023     Q_OBJECT
0024 public:
0025     explicit WhatsNextTextBrowser(QWidget *parent)
0026         : QTextBrowser(parent)
0027     {
0028     }
0029 
0030     /** Reimplemented from QTextBrowser to handle links. */
0031     void doSetSource(const QUrl &name, QTextDocument::ResourceType type = QTextDocument::UnknownResource) override;
0032 
0033 Q_SIGNALS:
0034     void showIncidence(const QUrl &url);
0035 };
0036 
0037 /**
0038   This class provides a view of the next events and todos
0039 */
0040 class EVENTVIEWS_EXPORT WhatsNextView : public EventViews::EventView
0041 {
0042     Q_OBJECT
0043 public:
0044     explicit WhatsNextView(QWidget *parent = nullptr);
0045     ~WhatsNextView() override;
0046 
0047     [[nodiscard]] int currentDateCount() const override;
0048     [[nodiscard]] Akonadi::Item::List selectedIncidences() const override
0049     {
0050         return {};
0051     }
0052 
0053     [[nodiscard]] KCalendarCore::DateList selectedIncidenceDates() const override
0054     {
0055         return {};
0056     }
0057 
0058     [[nodiscard]] bool supportsDateNavigation() const
0059     {
0060         return true;
0061     }
0062 
0063 public Q_SLOTS:
0064     void updateView() override;
0065     void showDates(const QDate &start, const QDate &end, const QDate &preferredMonth) override;
0066     void showIncidences(const Akonadi::Item::List &incidenceList, const QDate &date) override;
0067 
0068     void changeIncidenceDisplay(const Akonadi::Item &, Akonadi::IncidenceChanger::ChangeType);
0069 
0070 protected:
0071     void appendEvent(const Akonadi::CollectionCalendar::Ptr &,
0072                      const KCalendarCore::Incidence::Ptr &,
0073                      const QDateTime &start = QDateTime(),
0074                      const QDateTime &end = QDateTime());
0075     void appendTodo(const Akonadi::CollectionCalendar::Ptr &, const KCalendarCore::Incidence::Ptr &);
0076 
0077 private Q_SLOTS:
0078     EVENTVIEWS_NO_EXPORT void showIncidence(const QUrl &);
0079 
0080 private:
0081     EVENTVIEWS_NO_EXPORT void createTaskRow(KIconLoader *kil);
0082     WhatsNextTextBrowser *const mView;
0083     QString mText;
0084     QDate mStartDate;
0085     QDate mEndDate;
0086 
0087     Akonadi::Item::List mTodos;
0088 };
0089 }