File indexing completed on 2024-06-09 05:08:36

0001 /*
0002   This file is part of KOrganizer.
0003 
0004   SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org>
0005   SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
0006 
0007   SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0008 */
0009 #pragma once
0010 
0011 #include "eventview.h"
0012 #include <Akonadi/IncidenceChanger>
0013 #include <KCalendarCore/Journal>
0014 
0015 class QScrollArea;
0016 
0017 namespace EventViews
0018 {
0019 class JournalDateView;
0020 
0021 /**
0022  * This class provides a journal view.
0023 
0024  * @short View for Journal components.
0025  * @author Cornelius Schumacher <schumacher@kde.org>, Reinhold Kainhofer <reinhold@kainhofer.com>
0026  * @see EventView
0027  */
0028 class EVENTVIEWS_EXPORT JournalView : public EventView
0029 {
0030     Q_OBJECT
0031 public:
0032     explicit JournalView(QWidget *parent = nullptr);
0033     ~JournalView() override;
0034 
0035     [[nodiscard]] int currentDateCount() const override;
0036     [[nodiscard]] Akonadi::Item::List selectedIncidences() const override;
0037     [[nodiscard]] KCalendarCore::DateList selectedIncidenceDates() const override
0038     {
0039         return {};
0040     }
0041 
0042     void appendJournal(const Akonadi::Item &journal, const Akonadi::CollectionCalendar::Ptr &calendar, QDate dt);
0043 
0044     /** documentation in baseview.h */
0045     void getHighlightMode(bool &highlightEvents, bool &highlightTodos, bool &highlightJournals);
0046 
0047     bool eventFilter(QObject *, QEvent *) override;
0048 
0049 public Q_SLOTS:
0050     // Don't update the view when midnight passed, otherwise we'll have data loss (bug 79145)
0051     void dayPassed(const QDate &) override
0052     {
0053     }
0054 
0055     void updateView() override;
0056     void flushView() override;
0057 
0058     void showDates(const QDate &start, const QDate &end, const QDate &preferredMonth = QDate()) override;
0059     void showIncidences(const Akonadi::Item::List &incidences, const QDate &date) override;
0060 
0061     void changeIncidenceDisplay(const Akonadi::Item &incidence, Akonadi::IncidenceChanger::ChangeType);
0062     void setIncidenceChanger(Akonadi::IncidenceChanger *changer) override;
0063     void newJournal();
0064 Q_SIGNALS:
0065     void flushEntries();
0066     void setIncidenceChangerSignal(Akonadi::IncidenceChanger *);
0067     void journalEdited(const Akonadi::Item &journal);
0068     void journalDeleted(const Akonadi::Item &journal);
0069     void printJournal(const KCalendarCore::Journal::Ptr &, bool preview);
0070 
0071 protected:
0072     void clearEntries();
0073 
0074 private:
0075     Akonadi::CollectionCalendar::Ptr findCalendar(const KCalendarCore::Journal::Ptr &journal) const;
0076 
0077     QScrollArea *mSA = nullptr;
0078     QWidget *mCurrentWidget = nullptr;
0079     QMap<QDate, EventViews::JournalDateView *> mEntries;
0080     Akonadi::IncidenceChanger *mChanger = nullptr;
0081     //    DateList mSelectedDates;  // List of dates to be displayed
0082 };
0083 }