Eventviews

agendaview.h
1/*
2 SPDX-FileCopyrightText: 2000, 2001, 2003 Cornelius Schumacher <schumacher@kde.org>
3 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
4 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
5 SPDX-FileContributor: Kevin Krammer <krake@kdab.com>
6 SPDX-FileContributor: Sergio Martins <sergio@kdab.com>
7
8 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
9*/
10#pragma once
11
12#include "eventview.h"
13#include "eventviews_export.h"
14#include "viewcalendar.h"
15
16#include <KCalendarCore/Todo>
17
18#include <memory>
19
20class KConfig;
21
22class QSplitter;
23
24namespace EventViews
25{
26namespace CalendarDecoration
27{
28class Decoration;
29}
30
31class TimeLabels;
32class TimeLabelsZone;
33
34class Agenda;
35class AgendaItem;
36class AgendaView;
37
38class EventIndicatorPrivate;
39
40class EventIndicator : public QWidget
41{
43public:
44 enum Location { Top, Bottom };
45 explicit EventIndicator(Location loc = Top, QWidget *parent = nullptr);
46 ~EventIndicator() override;
47
48 void changeColumns(int columns);
49
50 void enableColumn(int column, bool enable);
51
52protected:
53 void paintEvent(QPaintEvent *event) override;
54 bool eventFilter(QObject *, QEvent *) override;
55
56private:
57 std::unique_ptr<EventIndicatorPrivate> const d;
58};
59
60class AgendaViewPrivate;
61
62/**
63 AgendaView is the agenda-like view that displays events in a single
64 or multi-day view.
65*/
66class EVENTVIEWS_EXPORT AgendaView : public EventView
67{
68 Q_OBJECT
69public:
70 explicit AgendaView(const PrefsPtr &preferences, QDate start, QDate end, bool isInteractive, bool isSideBySide = false, QWidget *parent = nullptr);
71
72 explicit AgendaView(QDate start, QDate end, bool isInteractive, bool isSideBySide = false, QWidget *parent = nullptr);
73
74 ~AgendaView() override;
75
76 enum {
77 MAX_DAY_COUNT = 42 // (6 * 7)
78 };
79
80 void addCalendar(const Akonadi::CollectionCalendar::Ptr &calendar) override;
81 void removeCalendar(const Akonadi::CollectionCalendar::Ptr &calendar) override;
82
83 /** Returns number of currently shown dates. */
84 [[nodiscard]] int currentDateCount() const override;
85
86 /** returns the currently selected events */
87 [[nodiscard]] Akonadi::Item::List selectedIncidences() const override;
88
89 /** returns the currently selected incidence's dates */
90 [[nodiscard]] KCalendarCore::DateList selectedIncidenceDates() const override;
91
92 /** return the default start/end date/time for new events */
93 bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay) const override;
94
95 /** start-datetime of selection */
96 [[nodiscard]] QDateTime selectionStart() const override;
97
98 /** end-datetime of selection */
99 [[nodiscard]] QDateTime selectionEnd() const override;
100
101 /** returns true if selection is for whole day */
102 [[nodiscard]] bool selectedIsAllDay() const;
103
104 /** make selected start/end invalid */
105 void deleteSelectedDateTime();
106
107 /** returns if only a single cell is selected, or a range of cells */
108 [[nodiscard]] bool selectedIsSingleCell() const;
109
110 /* reimp from EventView */
111 virtual void addCalendar(const ViewCalendar::Ptr &cal);
112
113 QSplitter *splitter() const;
114
115 // FIXME: we already have startDateTime() and endDateTime() in the base class
116
117 /** First shown day */
118 [[nodiscard]] QDate startDate() const;
119 /** Last shown day */
120 [[nodiscard]] QDate endDate() const;
121
122 /** Update event belonging to agenda item
123 If the incidence is multi-day, item is the first one
124 */
125 void updateEventDates(AgendaItem *item, bool addIncidence, Akonadi::Collection::Id collectionId);
126
127 [[nodiscard]] QList<bool> busyDayMask() const;
128
129 /**
130 * Return calendar object for a concrete incidence.
131 * this function is able to use multiple calendars
132 * TODO: replace EventsView::calendar()
133 */
134 virtual KCalendarCore::Calendar::Ptr calendar2(const KCalendarCore::Incidence::Ptr &incidence) const;
135 virtual KCalendarCore::Calendar::Ptr calendar2(const QString &incidenceIdentifier) const;
136
137 void showDates(const QDate &start, const QDate &end, const QDate &preferredMonth = QDate()) override;
138
139 void showIncidences(const Akonadi::Item::List &incidenceList, const QDate &date) override;
140
141 void clearSelection() override;
142
143 void startDrag(const Akonadi::Item &);
144
145 void readSettings();
146 void readSettings(const KConfig *);
147 void writeSettings(KConfig *);
148
149 void enableAgendaUpdate(bool enable);
150 void setIncidenceChanger(Akonadi::IncidenceChanger *changer) override;
151
152 void zoomInHorizontally(QDate date = QDate());
153 void zoomOutHorizontally(QDate date = QDate());
154
155 void zoomInVertically();
156 void zoomOutVertically();
157
158 void zoomView(const int delta, QPoint pos, const Qt::Orientation orient = Qt::Horizontal);
159
160 void clearTimeSpanSelection();
161
162 // Used by the timelabelszone
163 void updateTimeBarWidth();
164 /** Create labels for the selected dates. */
165 void createDayLabels(bool force);
166
167 void createTimeBarHeaders();
168
169 void setChanges(EventView::Changes) override;
170
171 void setTitle(const QString &title);
172
173Q_SIGNALS:
174 void showNewEventPopupSignal();
175 void showIncidencePopupSignal(const Akonadi::CollectionCalendar::Ptr &, const Akonadi::Item &, const QDate &);
176 void zoomViewHorizontally(const QDate &, int count);
177
178 void timeSpanSelectionChanged();
179
180protected:
181 /** Fill agenda using the current set value for the start date */
182 void fillAgenda();
183
184 void connectAgenda(Agenda *agenda, Agenda *otherAgenda);
185
186 /**
187 Set the masks on the agenda widgets indicating, which days are holidays.
188 */
189 void setHolidayMasks();
190
191 void removeIncidence(const KCalendarCore::Incidence::Ptr &inc);
192
193public Q_SLOTS:
194 void updateView() override;
195 void updateConfig() override;
196 /** reschedule the todo to the given x- and y- coordinates.
197 Third parameter determines all-day (no time specified) */
198 void slotIncidencesDropped(const KCalendarCore::Incidence::List &incidences, const QPoint &, bool);
199 void slotIncidencesDropped(const QList<QUrl> &incidences, const QPoint &, bool);
200 void startDrag(const KCalendarCore::Incidence::Ptr &);
201
202protected Q_SLOTS:
203 void updateEventIndicatorTop(int newY);
204 void updateEventIndicatorBottom(int newY);
205
206 /** Updates data for selected timespan */
207 void newTimeSpanSelected(const QPoint &start, const QPoint &end);
208 /** Updates data for selected timespan for all day event*/
209 void newTimeSpanSelectedAllDay(const QPoint &start, const QPoint &end);
210 /**
211 Updates the event indicators after a certain incidence was modified or
212 removed.
213 */
214 void updateEventIndicators();
215 void scheduleUpdateEventIndicators();
216
217 void alignAgendas();
218
219protected:
220 void showEvent(QShowEvent *showEvent) override;
221 bool eventFilter(QObject *object, QEvent *event) override;
222
223private:
224 void slotIncidenceSelected(const KCalendarCore::Incidence::Ptr &incidence, QDate date);
225 void slotShowIncidencePopup(const KCalendarCore::Incidence::Ptr &incidence, QDate date);
226 void slotEditIncidence(const KCalendarCore::Incidence::Ptr &incidence);
227 void slotShowIncidence(const KCalendarCore::Incidence::Ptr &incidence);
228 void slotDeleteIncidence(const KCalendarCore::Incidence::Ptr &incidence);
229
230 void init(QDate start, QDate end);
231 bool filterByCollectionSelection(const KCalendarCore::Incidence::Ptr &incidence);
232 void setupTimeLabel(TimeLabels *timeLabel);
233 bool displayIncidence(const KCalendarCore::Incidence::Ptr &incidence, bool createSelected);
234
235 friend class TimeLabelsZone;
236 friend class MultiAgendaViewPrivate;
237 friend class MultiAgendaView;
238 Agenda *agenda() const;
239 Agenda *allDayAgenda() const;
240
241 friend class AgendaViewPrivate;
242 std::unique_ptr<AgendaViewPrivate> const d;
243};
244}
This class describes the widgets that represent the various calendar items in the agenda view.
Definition agendaitem.h:61
AgendaView is the agenda-like view that displays events in a single or multi-day view.
Definition agendaview.h:67
EventView is the abstract base class from which all other calendar views for event data are derived.
Definition eventview.h:67
Shows one agenda for every resource side-by-side.
Q_SCRIPTABLE Q_NOREPLY void start()
Namespace EventViews provides facilities for displaying incidences, including events,...
Definition agenda.h:33
Q_OBJECTQ_OBJECT
QObject * parent() const const
Orientation
virtual bool event(QEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:29 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.