File indexing completed on 2024-05-12 05:21:25
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 0010 #pragma once 0011 0012 #include <EventViews/EventView> 0013 0014 #include <KCalendarCore/IncidenceBase> //for KCalendarCore::DateList typedef 0015 0016 #include <QDate> 0017 #include <QList> 0018 #include <QObject> 0019 0020 class CalendarView; 0021 class KOAgendaView; 0022 class KOJournalView; 0023 class KOListView; 0024 class KOTimelineView; 0025 class KOTodoView; 0026 class KOWhatsNextView; 0027 namespace KOrg 0028 { 0029 class BaseView; 0030 class MultiAgendaView; 0031 class MonthView; 0032 } 0033 0034 namespace Akonadi 0035 { 0036 class Item; 0037 } 0038 0039 class KConfig; 0040 class QTabWidget; 0041 0042 /** 0043 This class manages the views of the calendar. It owns the objects and handles 0044 creation and selection. 0045 */ 0046 class KOViewManager : public QObject 0047 { 0048 Q_OBJECT 0049 public: 0050 enum RangeMode { 0051 NO_RANGE, 0052 DAY_RANGE, 0053 WORK_WEEK_RANGE, 0054 WEEK_RANGE, 0055 NEXTX_RANGE, 0056 OTHER_RANGE // for example, showing 8 days 0057 }; 0058 0059 explicit KOViewManager(CalendarView *); 0060 ~KOViewManager() override; 0061 0062 /** changes the view to be the currently selected view */ 0063 void showView(KOrg::BaseView *); 0064 0065 void readSettings(KConfig *config); 0066 void writeSettings(KConfig *config); 0067 0068 KOrg::BaseView *currentView(); 0069 0070 void setDocumentId(const QString &); 0071 0072 void updateView(); 0073 void updateView(QDate start, QDate end, QDate preferredMonth); 0074 0075 void goMenu(bool enable); 0076 void raiseCurrentView(); 0077 0078 void connectView(KOrg::BaseView *); 0079 void addView(KOrg::BaseView *, bool isTab = false); 0080 0081 [[nodiscard]] Akonadi::Item currentSelection(); 0082 0083 /** 0084 * If there's a selected incidence, it's date is returned, otherwise 0085 * an invalid QDate is returned. 0086 */ 0087 [[nodiscard]] QDate currentSelectionDate(); 0088 0089 KOAgendaView *agendaView() const 0090 { 0091 return mAgendaView; 0092 } 0093 0094 KOrg::MultiAgendaView *multiAgendaView() const 0095 { 0096 return mAgendaSideBySideView; 0097 } 0098 0099 KOTodoView *todoView() const 0100 { 0101 return mTodoView; 0102 } 0103 0104 KOrg::MonthView *monthView() const 0105 { 0106 return mMonthView; 0107 } 0108 0109 void updateMultiCalendarDisplay(); 0110 0111 /** 0112 * Returns true if agenda is the current view. 0113 * 0114 * Never use the pointer returned by agendaView() 0115 * to know if agenda is selected, because agenda has other modes 0116 * (tabbed, side by side). Use this function instead. 0117 */ 0118 [[nodiscard]] bool agendaIsSelected() const; 0119 0120 /** 0121 Return the current range mode: 0122 week, work week, day or nextX days, etc. 0123 */ 0124 [[nodiscard]] RangeMode rangeMode() const 0125 { 0126 return mRangeMode; 0127 } 0128 0129 Q_SIGNALS: 0130 void configChanged(); 0131 void datesSelected(const KCalendarCore::DateList &); 0132 0133 public Q_SLOTS: 0134 void showWhatsNextView(); 0135 void showListView(); 0136 void showAgendaView(); 0137 void showTodoView(); 0138 void showTimeLineView(); 0139 void showMonthView(); 0140 void showJournalView(); 0141 void showEventView(); 0142 0143 void selectDay(); 0144 void selectWorkWeek(); 0145 void selectWeek(); 0146 void selectNextX(); 0147 0148 void connectTodoView(KOTodoView *todoView); 0149 0150 void zoomInHorizontally(); 0151 void zoomOutHorizontally(); 0152 void zoomInVertically(); 0153 void zoomOutVertically(); 0154 0155 /** 0156 Notifies all views that an update is needed. This means that the 0157 next time CalendarView::updateView() is called, views won't try to be smart 0158 and ignore the update for performance reasons. 0159 */ 0160 void addChange(EventViews::EventView::Change change); 0161 0162 private Q_SLOTS: 0163 void currentAgendaViewTabChanged(int index); 0164 void addCalendar(const Akonadi::CollectionCalendar::Ptr &calendar); 0165 void removeCalendar(const Akonadi::CollectionCalendar::Ptr &calendar); 0166 0167 private: 0168 QWidget *widgetForView(KOrg::BaseView *) const; 0169 QList<KOrg::BaseView *> mViews; 0170 CalendarView *const mMainView; 0171 QList<Akonadi::CollectionCalendar::Ptr> mCalendars; 0172 0173 KOAgendaView *mAgendaView = nullptr; 0174 KOrg::MultiAgendaView *mAgendaSideBySideView = nullptr; 0175 KOListView *mListView = nullptr; 0176 KOTodoView *mTodoView = nullptr; 0177 KOWhatsNextView *mWhatsNextView = nullptr; 0178 KOJournalView *mJournalView = nullptr; 0179 KOTimelineView *mTimelineView = nullptr; 0180 KOrg::MonthView *mMonthView = nullptr; 0181 KOrg::BaseView *mCurrentView = nullptr; 0182 0183 KOrg::BaseView *mLastEventView = nullptr; 0184 QTabWidget *mAgendaViewTabs = nullptr; 0185 int mAgendaViewTabIndex = 0; 0186 0187 RangeMode mRangeMode = NO_RANGE; 0188 };